March 2004
[ tirsen ] 14:58, Wednesday, 17 March 2004

As some may have noticed I'm a big Ruby fan.

Some wise person once said that learning a new programming language will change they way you think, if not it's no point learning a new language. I've done quite some bit of C# lately, but that hasn't really changed the way I think. It's basically more or less the same language as Java. Ruby fundamentally changes the way I think though. It's dynamically but strongly typed (strongly typed as: in Ruby "6" + "2" will give you "62" but in a loosely typed language like Perl or TCL that would give you 8) and it's got plenty of modern language features that really boosts your productivity.

People that think you only need one single language and that would give you everything you need should really try out some of these scripting languages for a while. In the beginning you're trying to do stuff like interfaces and abstract classes but after a while you just realize it's pointless. The compiler won't help you or protect you from yourself, there's only one way you know whether your code works or not: run it, test it. (In fact, this is the case in Java too, but the compiler gives you a false sense of security. I would say...)

I think Martin Fowler explains it best in his blog entry about enabling vs. directing. Ruby and other dynamically typed languages are enabling, they help a good programmer do a better job.

For this reason I really think it's great to see the Groovy JSR being submitted to the JCP. It might not be the only scripting language for the Java platform, but it's one that's particularly close to my heart. I think Java has always been a better platform for multi-language stuff than .NET so it's good to see this untapped resource being put to use.

Groovy's got a bunch of really nice Rubyesque features like closures, syntax for advanced data structures, inline strings and so on but it's also very tightly integrated into the Java platform. You can compile a Groovy script directly into a .class file and that's just going to be like any class in Java and vice versa you can reuse any Java class and library within Groovy. As James points out this binary compatability is way more important than syntactical similarities (although I must admit, I much prefer curly braces to the Pascalesque begin/end in Ruby). Groovy also avoids the magical implicit proc-variable and yield that is quite confusing and quite pointless in Ruby. In Groovy a closure is just like any other object, and you just invoke it. You can also do magical stuff like overriding invokeMethod. That sort of stuff is actually almost absurdly useful when doing framework stuff like remoting libraries, persistence or transparent proxies. (Yes, think poor mans AOP.) Unfortunately I don't see continuations making it into the language due to some quite significant JVM support for it. Continuations are really useful for implementing asynchrous processes like web applications without threads and can also be used to implement logic programming.

(And, yes, to Hani's dismay I will probably represent ThoughtWorks on the expert group once we get the paperwork sorted out. :-) )