by Chris Douce
There are two new programming languages battling for attention on my technology horizon. These languages are Ruby and Python and both are sometimes mentioned in the same breath. You seem to be able to do similar stuff with these newer languages than you can with older ones: PHP for web pages and my old favouite, Perl for 'glue code' and 'write once' utility scripts.
I have three questions, 'what would I learn by getting stuck into one of these new languages?', 'would I be able to work faster?' and 'can I afford to find the time when I know perfectly well that I can create a solution using one of the other languages that I am already familiar with?'
The expending of time learning a new language can be though of in economic terms - will it impact on the work that I have to do? It might do, but I have no feeling 'for the figures'. I have to make a judgement based on instinct. If I need a script, I write (or plagarise) some Perl code. If I need a web page, I might write some PHP (and perhaps even connect the two together somehow).
Every programmer will know there is more to learning a language than learning it's syntax. There are a range of coding idioms to get to grips with. There are likely to be some well known 'code' hangout places - sources for sources and programmer discussion. There is also the issue of the development tools: the libraries, an arcane command-line interface and maybe the blessing of an IDE.
Stepping further into a new language will present you with the new challenge of how to debug your code, and whether sets of mysterious looking libraries will be present on your chosen computing platform. As a new language novice you might make the mistake of choosing the 'wrong way of doing things', like choosing an iterative solution where the culture and structure of a language requires a recursive one.
You need guidance, so where might you look? You might search for opinions or code samples on the web. You might look for book reviews to find out which text book you should browse through.
The only way to really learn the predicalictions of a particular language is to go ahead and build something. When it comes to Python and what it can (or cannot) do, I am particularly interested in the One Laptop Per Child project (OLPC) from MIT. Since this laptop is something that geeks can meddle with it has inspired me to wonder whether I could write some code to solve some rather mundane XML editing problems. 'Perhaps I might be able to use the software on a desktop PC too?', I idly mused.
This is like putting the cart before the horse to some degree: wishing to write some code on some fancy new piece of kit before you have a complete picture of the problem that you wish to solve. But the very act of learning a new programming language, initiated from pure interest, may well be good for me even if the resulting software may not be of any practical use.
I have to make a conscious decision to open up my text book and fire up my tools so I can begin to grapple with a range of code samples. Even getting to this point can sometimes difficult. If I had a deadline to do something, perhaps I would push my book and tools to one side and use what I know has worked before.
Are Python and Ruby 'silver bullets'? Of course not, but they do represent an element of armoury that programmers can use to tackle problems. Just as Prolog helped me to understand recursion a little more, learning a new language may help me to reflect further on my experiences with the ones I already know.