Saturday, 9 April 2011

Visual Basic

Many people hate Visual Basic. It is produced by Microsoft, a company that attracts a great deal of derision (both rightly and wrongly). Secondly, many people see it as not being 'proper' programming, and a bit of a toy.

The second point is the most valid - although the language has been tided up in the last few years with the conversion to .NET, it is still a little noddy, and does not require a great deal of skill to knock up a simple program. Yet that is also its beauty, as it is an excellent rapid prototyping tool.

I was in a slight funk last weekend - I did not want to do any writing, nor any work on the website or around the house. My mind was totally focussed on the walk that I was planning for later in the week. Unfortunately I am incapable of lazing around and doing nothing. So whilst Sean Connery tried to steal Red October, I loaded Visual Basic 2010 onto my new laptop and had a play. I had not used Visual Basic for at least a year, and it was my first experience of the latest version.

A few months ago I wrote a post about MP3 players. At the time, I did a quick and dirty calculation about how long, in terms of duration, my MP3 collection was. The rough figure I came up with was 44 days.

So I decided to fend off boredom by working out a better figure. Within two hours I had created a Visual Basic program with front-end that scanned through my Podcasts and worked out the total duration of all the files (*). The figure: over 80 days of files, and growing by at least a day a week.

Of course, this could have been done in other languages, such as C, Perl or Python. But Visual Basic gave me a program that could run on any Windows PC without having to install any other languages or support infrastructure. In two hours I managed to write a program and User Interface that solved the problem at hand. I did it from a basis of not being an expert in the language, or in having used the latest version. What is more, it was fun.

There is no right or wrong programming language: they all have uses (yes, including Modula-3). A good programmer knows several languages, and picks the right one for the job in hand. A bad programmer weds himself to one language and uses it even when it is not appropriate.

So thank you, Microsoft, for Visual Basic. It does its job, and does it well.

(*) I use the track duration as reported within the file, which can be wrong. A better way would be to parse through the files and calculate the number of samples. This would be an easy change, but would take an eternity to run. The current system will do for the moment.

No comments: