Penguins.mooh.org

Good-bye Ruby Tuesday, I really have to fly

Another week, another post. In an attempt to make it at least look like I'm doing some work here, I'm going to talk a bit about programming here. If you are not a geek, you'll can wait around till tomorrow when I will talk about less geeky things (promise). I've got a paper to critically review for a group meeting tomorrow...

In the process of preparing for a presentation I've got to give in Florence, I realised that I should really have something somewhat original or interesting to talk about. I basically figured that I should do a quick little experiment involving performing a theoretical treatment on some theoretically generated sugars. The idea makes sense to me at least. Back at the ranch, it would have just been a simple matter of writing a few tiny scripts to manipulate a well established series of modules and database access modules to generate the data I was after. I don't have any of those little bits and pieces now - so I've got to basically start from scratch. This is a bit of a mixed blessing to most programmers out there - by starting from scratch you can implement a clean design, but you can spend months getting your code back up to the level that you had before. There's also the problem that the API which you used - while it may not be the best one - was the one you were most familiar with, and your design decisions are somewhat subliminally affected by it.

Starting from scratch also gives you the freedom to discard with any legacies that you had to deal with in previous projects. One of the big legacies is programming language. The de-facto standard for bioinformatics is Perl, a swiss-army-knife which makes any problem look like a nail. I've programmed a lot in perl now, and my days of being confused by it's syntax (since I came from a land of Java/C) are long since past. It's a great hackable language, and I'm never surprised at how versatile it is. This is beginning to sound like a love-letter to Perl, and with that set-up for the punch-line, I can't resist the urge to say that I've been cheating on Perl with Ruby.

Beyond the sheen of a new language - what exactly does Ruby have that Perl doesn't? Object oriented programming is the key. I realise people like to claim that Perl is an object oriented language, but whenever I see people say it, there's a cheeky look on their faces - because they know fully well that perl doesn't really do the whole object oriented thing in a rigourous way. For example, class constants aren't inherited, and breaking encapsulation is easy. Ruby doesn't implement a whole object oriented languge - but I think it's a whole lot better at it than perl. It manages to encapsulate data quite well in it's objects, but is lacking in some aspects of its implementation. Things like method overloading (which is a very useful trick to use) are notably absent. That said, it includes a whole bunch of cool tricks like prototyping, and dynamically adding methods to objects at runtime, as well as a module you can use to implement things like method overloading. The language ends up like a strange mix between JavaScript/ECMAscript. This type of functionality is achievable in perl - but not in a very consistent way. You would end up placing overloaded methods in the hash (which inevitably is used to model the object) using argument sniffing to dispatch the methods, and you'd have to find specific hacks to get the constants from a class inherited by all it's child classes. It's just not 100% intuitive.

Ruby is a "better" (or more well designed) language than Perl, I've got no doubt about that. But is it the right language to use? For all of Perl's problems, you can be sure that if you're in the middle of a medium to large-sized project, and there's some limitation in your design that you never even thought about (Yes, I know about software engineering), you can at the very least work around it in perl to get the program done. Can Ruby do that? Is there anything like CPAN for Ruby? Can you write poetry in Ruby? I've also thought about Java, and it's not really appropriate at this stage of development. Given that the point of my PhD is to actually learn things, I'm going to stick with Ruby, but Perl 6 might woo me back over. Regardless (or rather because) of my decision, I still haven't managed to actually collect the data, or run an experiment yet. Not entirely true actually - I've got one running at the moment, generating all possible isoforms of a tree.

1 comment

Anonymous *

Have you considered extending the API of Debian's excellent apt-get package management system? Really, if you think about it for a moment, each carbohydrate structure is really like a distribution, and the individual monosaccharides are packages.

Can you imagine the power of being able to create a new glycan structure by issuing an 'apt-get install newglycanstructure'!!?!

Oh God I have to find a new gag.

Post a comment