Sunday 15 February 2009

Java Brain Damage

I don't generally buy into bashing Java, a trend all-too-fashionable among dynamic language programmers (and even C++ programmers, for some reason). But I just stumbled across something when writing Clojure that annoyed me: with a JFrame, getLayout doesn't return the object set by a previous setLayout(aLayout) call. Why? Because the layout actually gets set on the JFrame's content pane, and that's not what getLayout is looking at.

Now, I remember the days where JFrame.add triggered a runtime exception: "Don't use add! Use getContentPane().add() instead!" or something like that. Somewhere down the line, someone appears to have had the great idea of changing that so that add made sense on a JFrame by deferring to the content pane, but symmetry has been broken in the process. Nice!

Sunday 8 February 2009

Smalltalk: Why it's NOT Good

There's been a fair buzz in the Smalltalk blogs (here and here) about generally positive Smalltalk-applicability comments made on StackOverflow.

Now, I like to think of myself as a generalist, and a bit of a language geek. In my various jobs I've written a great deal of Smalltalk (VisualWorks), Java, C++, C and Perl, but have also spent a fair amount of fun time working with Squeak, SBCL Common Lisp, Clojure and Erlang. I'm a huge fan of Linux and Unix, and believe that the shell is a vastly under-used resource.

This is where I personally find Smalltalk to be annoying.

Don't get me wrong: it's an amazing language and development environment. With something like Eclipse, you write some arcane text files and--after running them through a compiler that you didn't really need the IDE for anyway--you have your application. With Smalltalk, the IDE is the application: you just iteratively refine it until it becomes what you want to ship. Awesome stuff.

But that same self-contained structure is what hurts it. When I write C, I tend to use Emacs, enhanced with a bunch of add-ons. I use the git source control system. I use diff and patch to throw experimental code snippets at colleagues, and they do the same with me.

However, my choices don't stop them from using Eclipse, and the master source repository being Subversion. Furthermore, when I need to write Java or Perl, I can use the vast majority of the tool stack that I've accumulated just by switching buffers in Emacs. Simply put, I get to transfer most of my skills between tools.

In Smalltalk, it's all-or-nothing. Shell tools are useless on the image. You can't edit code in your favourite editor (well, you can, but unless you're using GNU Smalltalk, it's inconvenient to the point of being unusable). On top of that, you need a special, integrated source control system that's most likely dictated by your vendor, with migration being difficult-to-impossible.

For me, this single-mindedness it what stops Smalltalk being my favourite language (well, that and a single-threaded virtual machine and non-native GUI widgets). For now, Perl retains that crown (despite it being fashionable to bash it these days), with Clojure looking very, very interesting as a possible successor...