March 2008 Archive

Development tools on Windows vs Linux

March 12th, 2008

As far as desktop systems go, for email, internet and basic office functionality, there’s no denying that Windows rules the roost. I would argue that Linux is actually not difficult to set up and use, it’s just different and probably has a perception problem, but therein lies the problem.

But from a developers point of view using Linux as the platform has many advantages over Windows. Try writing a simple “Hello world” program in C or C++ on a fresh Windows install an then compile and run it. You can’t.

Simply put, most Linux distributions come with compilers (gcc in this case) installed out of the box and many more are available with an ‘apt-get’ or ‘yum install’ command. You don’t even have to do this from the command line these days as most distributions have friendly graphical install programs that put anything Windows has to shame.

Want Python or Perl, Apache or MySQL again it’s a few clicks away along with hundreds (thousands?) of other tools. Plus once they’re installed the OS takes care of notifying you (and optionally installing) any updates so you’ll never be left with 3 year old, unpatched software on your computer.

The last time I checked my Windows install I had many applications that were way out of date but the effort required to check up and manually update each one individually was just too much effort.

On a related note I have been using Eclipse as my IDE of choice, mainly because of it’s support of both Python and C++ using the Pydev and CDT modules. So I thought I’d give it a try on Windows.

After downloading and installing Python then installing the Pydev module, getting Python to work was not too difficult. Next came C++ support, it involves installing MinGW following the instructions on download page, then configuring Eclipse using these instructions.

If you’re very lucky it will all work first time, but don’t count on it. And god help you if you decide to update any packages at a later date.

Compared to all this the development tools on Linux are a breeze. Linux may or may not be ready for the desktop for the average user (if there is such a person) but when it comes to the power user or developer it’s already ahead in my books.

Programming for Performance or Simplicity

March 11th, 2008

I was recently writing some code to be run from a command line that recursively walks through a network folder and all sub folders compiling a list of all the files, their last modified date and their size.

Since writing VBScript is quick and dirty I tend to start with that and in most cases it works just fine. However when speed really matter it’s just not up to the job.

The network directory contains about 35,000 files in 3,200 folders consuming 45.4GB of disk space. The script should simply gather the data required and write it to a flat text file (delimited with semi-colons). When I ran the VBScript it took 306 seconds (5 minutes and 6 seconds) to gather the data.

Not too bad but not fast enough. So I decided to write the same script both in Python and C++. Python is a very high level scripting language, so nowhere near as fast as a complied language like C++, but I wanted to see how it compared to VBScript. Here’s the results for the 3 programs.

Language Files indexed Time taken (seconds) Files per Second
VBScript 34999 306 114.4
Python 35018 68.5 511.2
C++ 35017 13.9 2519.2

Of course, as expected, for real performance C++ outstrips the scripting languages by a mile but Python also fairs pretty well.

When I also consider how simple the code is and how long it took to develop I think Python is the clear winner unless every ounce of performance is vital. Developing real world programs in Python is extremely easy and the code is fast.

I use another short script in Python to parse Apache log files and it amazes me how fast it runs. The current log is over 122,000 lines (27.1MB of data) long but the script parses the file and outputs the results to a text file in just over a second! Very impressive for an interpreted language.

Accidentally Wiped my Windows Partition

March 6th, 2008

After all the testing with creating bootable USB drives and trying many different distributions I guess the inevitable had to happen. At some point in my partitioning/formatting of the USB drive I’ve typed

/sbin/mkfs.vfat -F 32 /dev/sda1

instead of

/sbin/mkfs.vfat -F 32 /dev/sdb1

Only a small error, replacing sdb1 with sda1, but the result is that I reformatted my main Windows XP Professional NTFS partition to FAT32 and in the process lost Windows. I’m not bothered about data loss as I keep anything important in my Linux partition that’s also backed up to a NAS device. What I’m really bothered about is the prospect of reinstalling Windows. In my experience it goes something like this:

  1. Boot using my Acer install disk (pre SP1 from 2003).
  2. Wait 30 minutes for install to complete.
  3. Reboot, listen to annoyingly loud music while setting my computer preferences for the first time.
  4. Reboot again.
  5. Spend 2 hours (minimum) customizing and uninstalling the crap put on my computer.
  6. Go to Windows update and start the painful process of getting a pre SP1 XP Professional computer to SP2. This usually requires 50 to 100 updates along with maybe 3 reboots on the way. Allow at least 3 hours for this with a fast internet connection.

If all goes well the whole process will take an entire evening. Not forgetting that the fresh Windows install will overwrite my mbr so making my dual boot laptop into a single boot Windows only machine requiring me to boot into a live Linux distribution and then installing GRUB on the mbr again. Phew!

Compared to this exercise in time wasting, installing any new Linux distribution these days seems like a walk in the park. I’ll just have to be extra careful in future when formatting drives.

Blog down for a week

March 6th, 2008

My web host decided to move my blog and main site (http://bobpeers.com) to a new server with a new IP address without any notification whatsoever.

They updated the records for people using their name servers, however I use Zoneedit (and thoroughly recommend them) so my DNS records were left pointing to the old server and IP address.

To make things worse I’ve been away on holiday for the whole time without internet access so never noticed and to top it off it seems that my last blog post has somehow disappeared. To say I’m not pleased would be an understatement……