Archive for July, 2008

i86pc SunOS

When I finally figured out how to approach Solaris Express on a VMware virtual machine through the Remote Desktop option, I started looking for the compiler.

For some reason, Sun isn’t very happy about you using the GNU compilers, so they hid the files in the /usr/sfw/bin directory. Before I could call `gcc -dumpmachine`, I had to add the directory to the $PATH environment. That wasn’t as easy as it sounds unfortunately. After fiddling around on the web, and making scripts with various combinations like export PATH=/etcetc or PATH=/etc; export PATH, I couldn’t make it work except for on the command line itself without using a script.

After that, building applications seemed like a picknick. Solaris Express supports GTK+ by default, and for example the MySQL client libraries are easily installable. A few ln -s commands, and a few adjustments to the Makefiles, and you’re good to go.

The thing that was most curious though, was the fact that I had to statically link against -lnsl and -lsocket on network related code.

Add comment July 27, 2008

VMware X-server graphics

I mentioned in a post about Solaris that graphics in VMware are one big mess, and I’ve encountered similar pictures when installing some Linux distributions.

When I initially tried to install the VMware tools that contain special drivers, it asked me to install a compiler and compile things with the current kernel. Personally I think that’s just ridiculous, so I ended up not installing anything.

However, what I failed to notice was the fact that the display driver didn’t need any fancy compiling, it just needs you to run the config and enter your favourite resolution. So to get those graphics right, you need to run your /usr/bin/VMware-config-tools.pl and answer no to everytime the tool wants to compile something, and at the end after a dozen questions you’ll see a question about display resolution. Confirm your resolution and continue till the tool finishes. Then simply ctrl+backspace on your X environment console and voila the graphics are fine.

Add comment July 25, 2008

RSSViewer

Out of curiousity I wrote a C# .net application for compact framework. I wrote it in about a day or two, so it’s nothing fancy or perfect. But it may come in handy.

You should be able to add your favourite RSS or Atom feeds, download them, and read the descriptions or full articles offline (depending on how the feed is constructed). I added a few templates for common blog-sources, so you only have to enter the username, and on saving it tests the connection and determines the title of the blog.

When viewing the feed it attempts to download the feed xml, and on failure it tries to retreive the local document. So be sure to have enough space or install the application on a storage card.

I have another version lying around that highlights new articles, but it needs some debugging.

Download Here

Add comment July 20, 2008

Never perfect

Do we not just enjoy the incompatibilities, the quirks and the complications of the assemble-it-yourself-things? No we don’t, but developers and hardware assemblers get a real kick out of it.

I decided to buy a bare clean HP Proliant ML110 5G tower, and I connected some extra RAM, an extra 1Gbps card and 2 extra 250gb harddisks. So far, so good.

I forgot the Sata cables, so I didn’t connect the disks yet, and tried out Ubuntu Server and installed KVM + Virtual Manager – for ‘virtualisation’. Unfortunately it doesn’t work exactly like a charm, the speed was ok for the most part, but at some points at the installation of Windows 2003 Server, it stalled up to a point where I just fell asleep. So I let it rest, got the sata cables, installed the harddisks.

Since I wanted to use the extra disks to store large backups, and because I wanted to try out Sata Raid, I decided to enable and configure a raid array. And since I wanted to backup files across servers in a swift fassion, I decided to do a clean install of the Ubuntu Server edition again.

Ubuntu shows a nice surprise; no raid. Just 2 seperate disks. When I insert the HP smart-setup CD-rom that came with the Proliant, it seems HP doesn’t support its own products either. I guess it’s my own fault for buying a cheap pc.

So out of frustration I disabled raid again, and I popped in the Windows Server 2003 cdrom I got along with my VS2008 Pro/MSDN Pro subscription. A nice clean install, but naturally half of the hardware drivers weren’t available, so I had to download it – with the Internet explorer that blocks just about every website there is out of security reasons. After a few reboots I wanted to see what happened if I enabled raid again: bluescreen reboots. So it’s just 3 seperate harddisks from now on.

Since I didn’t dare to download Virtual Server from MSDN, I wanted to get back to the familiar VMWare Server. Upon installing however, several MSI Installer and security issues arise which had to be patched, but only after about 2 hours of searching the web. Installed and well, the installation of Windows XP Pro went like a charm on VMWare.

And then I wanted to be bold and reckless, and reached for an old OpenSolaris cdrom. But alas, the graphics are beyond legible and I couldn’t install. So a new version perhaps? Solaris Express? Same graphics issues, and more – it couldn’t read the dvd, but I didn’t know what the error meant. Once I pointed the VM configuration to the ISO itself instead of the physical cdrom drive, it finally worked.

Now I’m waiting for the text based installation to finish and I will pray for some proper graphics once it’s installed, because even the text based graphics are just beyond normal.

Not to mention that working on the actual Windows 2003 installation is faster via Remote Desktop than a physical screen, keyboard and mouse for some reason. I suspect that drivers are fighting eachother off on the same IO or Memory addresses as always.

Come to think of it, I had similar issues with text based installation on Windows 2003. I suppose the VMWare beta has issues supporting the 80×40 lines resolution as opposed to the 80×25.

“unknown console login:” … that sounds promising.

Ah, and the graphical login screen looks horrible.

Example of what I’m dealing with here:

Solution

Add comment July 11, 2008

New stuff

Add comment July 8, 2008

Coding style preferences

Every developer has a specific taste and experience for his or her coding style. But the styles wouldn’t be much different if the programming language or library that’s being used wasn’t so versatile. C-plusplus is one of those languages where there’s just too much customization freedom for my own taste, but others might differ.

After the time I got to spend on Java code in my early days, later on Object Pascal (Delphi), along with C and other things – my general style in programming is to use object-orientation to its fullest. Cplusplus however, isn’t just that. It’s the language where you can customize just about anything through operator overloading, function overloading, pointers, templates and whatever not. But the biggest thing most Cplusplus developers are dedicated to is STL and libraries like Boost that extend it.

My programming style and preference however forces me away from them. I somehow miss the point of STL, and I never get it to do what I want. So all of those vectors, iterators, streams, all go unused in favor of self-designed classes along with a lot of pointers.

But yes, limitations will force you to use certain aspects of a programming language. At some point where I wanted to create an event and property mechanism, I had to use templates simply because it was just too silly to use those objects when you needed to manually guess and cast everything to the right type.

And if you start on one thing, you will start to think about other aspects. For example operator overloading. I have my reservations with it, because I tend to use more dynamically allocated objects, and I want to actually know what I’m doing by the help of named functions.

I’m experimenting though, and I might be swayed to use << and += wherever it may prove to be a useful shortcut. I’m currently trying out += for events, I actually got the idea of course from C# where you can do something like eventname += new myeventfunction( myimplementation ). And with my template driven events I can have a similar syntax, which may be more useful than having to call some eventname.addEventHandler( new … ) function.

But generally I tend to avoid operators, if I want to be able to write myvariable++, I’ll use an integer as the variable.

Add comment July 7, 2008

The quick and dirty road to mobile apps

1. Download the CF 3.5 redistributable from here and keep your WM6 device connected while installing so you can install 3.5 on your mobile device as well.
2. Install “Windows SDK for Windows Server 2008 and .NET Framework 3.5″ from here
3. Install “Power Toys for .NET Compact Framework 3.5″ from here
4. Install “SharpDevelop 3.0″ from here
5. Choose New Solution, C# Compact Framework, Windows application, enter the name and wave your wand.
6. Compile, remove whatever line of code doesn’t work in the InitializeComponent() function, and recompile.
7. Move the .exe to your Windows Mobile device.

And I’m betting somewhere down the line it will fail for you, because I didn’t get this on my first attempt either. I’m hoping for plug and play on arrival of my VS 2008 Pro copy, though I doubt it. SharpDevelop does look nifty though, but anything’s better than GTK# with MonoDevelop (not that Mono actually works on my Vista64 system, but it works on Linux).

Somehow the 3.5 code gets either buggy through the compiler or the runtime on my mobile, but recompiling apps as 2.0 works fine.

Worth noting; when you decide to get the real deal Visual Studio 2008 Pro, it’s highly recommended you uninstall all your manually installed sdk’s and runtimes, or else you’ll notice an empty toolbox when you try to create CF projects in VS.

Add comment July 6, 2008

Testing

You don’t have to be a Microsoft or a .Net fan to like these kind of ideas: Pex – Automated Exploratory Testing for .NET

Well thought off automated testing mechanism. Of course it needs an interpreter for the code, but hey they wrote dot Net.

It’s inspiring to say the least.

Add comment July 4, 2008

The Threading Discussion

I always get cranky when reading discussions about Threads. For some reason a large group of programmers think coding threads is hard. And with every news article that touches the issue, the discussion reignites.

Yes, threads can be hard and complicated at times, especially when dealing with locks, mutex’s, semaphores, etc. but when you rewind your way of thinking there’s some easy guidelines that will make threading a second nature.

First one; think object-oriented. Thinking in a straight serialized way like the way for example the C-language is seen, limits your actual options. You need to think in separate units. When dealing with classes it’s easier to separate functionalities and make them function on their own without depending on others.

Second one; every application that has a user-interface is an opportunity to use threads. Everything the user clicks on can potentially spawn a new thread or reuse one.

The slight downside to a GUI application, is that some GUI’s don’t really like multithreading. GTK is one of them. The Win32 API is generally really cool about it, and Cocoa can do it as well. In environments like GTK, you have to think of a messaging system that hands over feedback in-between GUI thread iterations.

A simple system I have come up with for GTK, is to message and buffer function-pointers, so an entire custom function can handle all of the GUI changes.

Third; don’t over-think locking mechanisms nor mutexes. Think of ways to avoid communication between multiple threads that are running by giving the data they need in the beginning. If you simply have to, find a way to just use a limited amount of functions and centralize them so you can encase them with locks.

If you want to share an object filled with data, the easiest thing you can do is to make a copy with one synchronized function.

Fourth; think generic. If you’ve written a piece of code before, you can separate it into a new function or even a new object given specific variables. If you can do that, then you’re a step closer to figuring out if that piece of code can be threaded.

Fifth; Don’t write something you’re not yet done with. You see it all the time, even I succumb to the temptation quite often – functions that hint at something that’s not yet ready. Functions like newRecord() that append an empty object to an array, while you still have to fill in the values. Or public record counts that are incremented before the record has been added.

If you see a code snip like this;

void addNewValue( string myvalue ) {
   myValueCount++;
   resizeMyArrayTo( myValueCount );
   myValues[myValueCount-1] = myvalue;
   myvalue = myvalue + " my appendix";
}

You’re in serious need of a rewrite to this;

void addNewValue( string myvalue ) {
   myvalue = myvalue + " my appendix";
   resizeMyArrayTo( myValueCount + 1 );
   myValues[myValueCount] = myvalue;
   myValueCount++;
}

If you’re careful enough to make your code depend on variable assignments that have the least chance of being split into separate opcodes, then you don’t even have to use locks in most threaded environments. So sure, myValueCount++ will probably be split into 2 opcodes, one that increments a register, and one that assigns the value to the actual variable. So eventhough in an extremely rare case that those two opcodes get split, and at the same time another item wants to change the same variable, your variable will be off by 1, but at least your application won’t crash. In the first example your application has the potential to crash, as the variable that’s incremented before the actual value has been appended will give other threads the opportunity to access a non-existing object.

The same thing happens when you use things like this;

function doSomething( int i ) {
   CMyValue *obj = myTable->record[i]->newValue();
   obj->datatype = STR;
   obj->value = "this is my value"
}

Make your code prepare the object before you give it to someone else;

function doSomething( int i ) {
   CMyValue *obj = new CMyValue();
   obj->datatype = STR;
   obj->value = "this is my value"

   myTable->record[i]->appendValue( obj );
}

Threading is way of thinking, and once you’re able to think in that direction, it won’t seem so hard anymore.

Add comment July 2, 2008

Compatibility

I don’t really get why so many people are into remaining compatible with the Microsoft Windows API. While the operating system itself is very mature and well tested after so many years remaining compatible to predecessors, the basic concepts of the Windows API are not of this age anymore. I know this isn’t entirely Microsoft’s fault, Posix compatibility brought plenty of misery to the OS the same as the other OS’es.

Isn’t it time we started a new OS with an API that is Not compatible with Posix and Windows? Haven’t we had enough of all the workarounds we had to make up? For the future’s sake, someone has to be bold and be shouted at for their non-posix compatibility, I’m absolutely sure it will have potential (if properly documented of course).

Oh well. For the time being we’re stuck with the mess of the past, and we’ll have to keep writing our fancy wrappers…

Or better yet; Microsoft to remove all legacy, deprecated, inefficient, inconsistent and insecure API functions so we stop using them.

Add comment July 1, 2008


RSS Twitter

 

July 2008
S M T W T F S
« Jun   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

Blogroll

Meta