Wednesday, May 27, 2009

Unique, just like everybody else

Recently my place of work started using Redmine, a fantastic project management web application. Redmine is written in the Ruby programming language, which generates a fair amount of hype in web development circles.

The reason for this hype, the language and the Rails framework are all things I am largely ignorant of. I’ve been dimly aware of the Ruby on Rails phenomenon for some time now but until now had yet to pay it any attention. It could be the real deal, or it could be just another in a long line of computing fads. And even if it is the former, that alone still wouldn’t justify learning it.

But there’s no harm in a casual glance, so a “why Ruby?” search and five minutes of sifting through the results led me to 10 unique ruby language features. Perfect. After reading Unique Feature #1 I was haunted by a sense of déjà vu. Unique Feature #2 wasn’t even uncommon. The end result of having my hopes built up and then promptly dashed by either extreme myopia or a fundamental misunderstanding of what the word “unique” actually means is the remainder of this post. As a counterpoint to the aforelinked article, I give you:

10 (not so) unique ruby language features

  1. In Ruby, everything is an object.
    As they are in Smalltalk and, more recently, Python. The same is almost true of the .NET Framework languages where all types are objects and methods can be called on everything except numeric literals.
  2. Code blocks which can be passed as a parameter to a method.
    Off the top of my head, Perl and JavaScript allow the passing of both named and anonymous functions as arguments to other functions. You can also assign functions as properties to objects in both.
  3. Implicit return value in methods.
    Like subroutines in Perl?
  4. Everything is open! All inbuilt classes can be modified at runtime.
    Like JavaScript’s prototype object?
  5. Missing unary operators.
    There is no post- or pre-increment operator in Ruby. Granted, this is pretty uncommon, but touting the lack of a standard feature as a selling point is stretching it.
  6. It’s possible to change multiple values in a single statement.
    See Perl: @array[3, 5] = ('foo', 'bar');
  7. Mutable strings.
    Strings are mutable in C++. It’s also a bad idea from a performance and thread-safety perspective, so even if this was unique it still wouldn’t be a good thing.
  8. Zero and empty strings do not evaluate as false.
    This is exactly how Lisp does it.
  9. Native regular expression support.
    One word: Perl.
  10. The last character of a method name indicates its behaviour.
    After reading the Ruby documentation I can only conclude that this is simply a programmers’ convention, which isn’t a feature at all. I’m happy to be corrected if I’ve got it all wrong.

So Ruby itself leaves me with a sense of disappointment for bringing nothing new to the table, and instead being relegated to the pedestrian status of yet another programming dialect. I say dialect because like most languages it isn’t sufficiently distinctive to warrant the term. Since Böhm and Jacopini realised that any algorithm can be represented by the three basic concepts of sequence, selection and iteration, followed by the more recent object-oriented craze, most languages offer fundamentally the same product wrapped up in different syntax. It’s all slightly different ways of doing much the same thing. I’d be impressed by some genuine innovation or crazy left-field idea, like a language that could automatically manage threading and CPU cores like Java and .NET manage memory. That might be interesting.