Friday, December 7, 2007

Dynamic Languages for a New World

Long ago, almost a lifetime now, I was a Perl developer. Perl 5 had just come out and I was a happy camper. Then, I started coding some very large programs, and I wasn't happy anymore. Moved away from Perl to C++ and pretty much stayed there for the last decade.

With my recent incursions in Java world and Java EE, I felt there was a lot of good technologies I could use in there but one part still bothered me, namely JSP and AJAX. JSP seems to be a capable technology but JSP and Ajax seems to be a marriage made in hell.

The prospect of writing HTML, CSS and JavaScript by hand, even with the help of toolkits like jMaki, is something that has always scared me so I kept on looking. I finally came across Google's web toolkit. I was happy again, full Java on the server and compile down Java to JavaScript on the client.

Now, I already knew about IronPython and JRuby, I decided to look around for a Perl for .Net and Java just to see what was available. Well, needless, to say I didn't find much except a discontinued Perl on .Net product from ActiveState and abandoned Perl on Java project. Signs of Perl's waning popularity I suppose.

I did come across a number of interpreters however, and I was quite surprised by the ample choice that was available, mainly:
  • IronPython. C# implementation of the Python language. Licensed under the MS Public License. Impressive but I never liked Python much, I'm too much of a braces ('{', '}') man myself.
  • IronRuby. C# implementation of the Ruby language. Also licensed under the MS Public License.
  • JRuby. Java implementation of the Ruby language. Triple licensed, available under the LGPL.
  • Jython. Java implementation of the Python language. Licensed under the Python Foundation License.
Of all these interpreters, Jython is the oldest and is the only one who is not employed by either Sun or Microsoft to work on his interpreter. Sun and Microsoft announced their support of JRuby and IronPython at around the same time, and Microsoft added support for IronRuby this year when it became clear that Ruby on Rails was going to make Ruby considerably more popular than Python.

Now, I tried all these languages and none of them felt right. All of them felt odd because of the importance of maintaining compatibility to their C counterpart. Is it a Ruby string or a Java string? A Python string or .Net one? To both questions, it depends on the context of what that module is importing.

I was a little bit discouraged. I felt Java everywhere except mobiles and C# on mobiles was just too monogamous. I like to spices things up but at the same time I didn't feel like moving away from GWT was a good move.

Well, it turns out that there are open source scripting languages being built natively on Java and .Net at Codehaus.org. Groovy for Java and Boo for .Net.

Both support support static typing instead of just duck typing. Now, I don't know much about Boo, I'm not looking to complement C# since I only use that on mobiles. I will say this however, Boo is supported by the very good SharpDevelop IDE, including visual form design and everything.

Groovy on the other hand has been a really good experience especially considering I use NetBeans and the Groovy plugin for that IDE is still incomplete. I get a first class citizen of the Java platform. At first, due to the fact that I wanted to use GWT, I was planning to limit my use of Groovy to testing code, i.e. write my JUnit stuff in Groovy. After all, I couldn't write Groovy code for GWT right? That things compiles Java down to JavaScript, it won't know what to do with my Groovy code right?

Enter Grails. Now, I can't for the life of me think of why anyone would use JRuby on Rails, i.e. using Rails from JRuby instead of Ruby, but I can see why a lot of Java developers would migrate from JSP/jMaki to Grails.

Grails follows the Rails philosophy of RAD web development but also features a GWT plugin. Unlike Rails, production deploys of Grails are done to a standard Java EE container using a WAR file.

Now, I can only imagine doing all my web services and back end stuff in Java, doing the web front end using Groovy and GWT, just very exciting times. Now, I'm still in the process of learning and using Grails and still fiddling to see how good GWT support is in Grails but exciting times nonetheless.

2 comments:

Raphaƫl Valyi said...

"Unlike Rails, production deploys of Grails are done to a standard Java EE container using a WAR file."

That's the way JRuby on Rails can be deployed too...

OK, make your bet, mine is on the other one...

Unknown said...

Yes, I know. I was talking about Ruby on Rails here.

I am unwilling to bet to Rails vs Grails in Java land. I will say this however, that JRuby on Rails found such a passionate advocate, that is good enough for me.

However, I now think both systems will find a user base instead of one versus the other.