Ruby seems to be like crack, once you have some you want more, but that doesn’t necessarily mean that it is good for you. Paul Stovell recently posted up an article entitled Ruby for .NET Developers which does a really good job of pointing out some of the key features of developing on the Ruby platform (note that Ruby is a language AND a platform whereas .NET is a platform which has languages likes C#, VB.NET, IronPython and soon, IronRuby).
Paul lists out a few bullet points which highlight some of the syntactic differences, nothing that is really earth breaking but I did find the following things interesting:
- Ruby strings are not immutable.
- Ruby does its own scheduling.
I could probably get used to a runtime where strings weren’t immutable again but I don’t know if I really want to. In some instances mutable strings can have performance advantages over immutable strings, but if you aren’t careful you can introduce some really nasty bugs at the same time.
Ruby doing its own scheduling was what I found really alarming and it strikes me that it could be one of its biggest limiting factors. Early versions of the Java runtime used one single thread and quickly found out that they were missing out of the benefits of scheduling being done lower down in the stack. I am sure that Ruby will change this in the future as the amount of time and resources that can be mustered to support writing OS specific threading code increases. Maybe IronRuby might actually help the Ruby community in this respect.
Paul also made a big deal of the block syntax in Ruby and how closures work. In some instances the syntax can be more compact, but the argument that they are significantly better than something like C# anonymous methods is pretty weak, and even weaker once C# 3.5 ships and we get expression syntax. For example:
customers.ForEach(x => Console.WriteLine(c.Name));
I’ll have to double check on my Orcas machine that I can have an expression that returns a void value, but I suspect that I can. I’m not really suggesting that C# is better than Ruby, but I am suggesting that if you take a big sip of another cup of kool-aid you can often forget what your current language already has in terms of features.