One never wants to write Java in Ruby. But sometimes, you don't have a choice. Libraries are typically not language agnostic. A library reflects the language it's written in. Write a library in A, try to use it in B, and you'll see an aesthetic clash resulting from a mismatch of idioms. This mismatch is why it can be so unpleasant to use languages other than Java on the JVM. Most of the libraries on the JVM were written in Java, and therefore expect to be interacted with in a Java way. So when you fire up your fancy new dynamic language, with literal maps and lists, and blocks and procs and yields and dynamic this and vararg that, you discover none of those fancy features are applicable to your libraries, because they weren't written with those things in mind. This isn't so much of a problem for JRuby, because they do go out of their way to make Java look more like Ruby, but I find it's a major problem in a language like Clojure; which to begin with, doesn't resemble Java at all (i.e. isn't OO) and has very few in the way of native libraries. When I compare the user experience of writing Common Lisp code with Common Lisp libraries, it looks and feels so much better than writing Clojure code with Java libraries. All the fancy lisp in the world can't save you from the evil Java library monster.
I think one of the things the Clojure community has to do, besides come up with their own libraries, is to start writing native Clojure wrappers around Java libraries. I'm not sure if such a project is feasible, but I know that I'd rather write separate bindings than pollute my Clojure code with Javaness. Honestly I wonder if issues like these will get more attention now that virtual machines are becoming this great big multi-language platforms. Maybe someone will find a magic solution. Skinnable language agnostic libraries! With Java, Clojure, Ruby, and Python stylesheets, get yours now!
Thursday, October 16, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment