2012-06-26

Ruby

Since I’ve been playing with re-implementing things, I went ahead and also implemented the site rendering script in Ruby.

I also got a fair way to re-implementing the table of contents generation in Ruby, but I’m having a bit of trouble with getting the current working filename to output.

So far my thoughts are …

Ruby looks a little cleaner than Perl to my eyes for most statements. However, there are places where I couldn’t figure out how to do things as concisely as I can in Perl. And although Ruby looks cleaner, I don’t know that it’s actually clearer than the Perl code. Where in Perl, the language itself gives you a fair amount of clues about what operations are actually going on, in Ruby you really need to know what class / object you are talking about to understand what the methods are doing.

Sometimes, the arguments to a Ruby object method really don’t make sense out of the context of knowing that the method takes something as a special case to change it’s behaviour. For example, gets takes nil as an argument to mean that it should read all lines available from the file or input stream.

One could argue that Perl requires you to recognize what context (list or scalar) you are in to understand the behaviour of the operator, but in my experience that is usually fairly evident from the immediate surrounding code (although to be fair, that may also require looking up function definitions that you are not familiar with).

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s