Friday, December 26, 2008

Antlr, a reflection

I worked with ANTLR, attempting to build a small code generator. ANTLR, along with TextTemplate includes a complete toolchain for building everything required for a code generator, ANTLR includes both a parser generator and a tree walker generator, and TextTemplate is a full templating solution.

However, working with the ANTLR suite turned out to be harder than I was expecting. Debugging the generated AST transformation code required a lot more spelunking through generated code than I was happy with. ANTLR has good support for debugging parsers over text, but I couldn't get debugging tree walkers in the ANTLR tools working to my satisfaction.

I can see two alternate paths going forward. Either I take the lisp approach and build out tree transformation code using something like clojure, and learn to love emacs and clojure's REPL. Or I take the path of writing code in a programming language written by compiler writers to write compilers in. Two obvious examples include Haskell and Scala.

The reason I am persisting with figuring this out is that we are on the cusp of one of those interesting times when we get to re-write the world again. We re-wrote everything when PCs appeared, then we re-wrote it again when Windows beat out MS-DOS, then we re-wrote everything again when the web first appeared.

And we are going to do it again to allow people to be able to use applications inside their web browsers, disconnected from the web. This is different from traditional desktop applications, even though from the users perspective they appear to be the same. The new functionality is that data is being kept both on the client, in a web browser hosted sql datastore, as well as on the server.

Which means we are about to re-write all of the applications that business users use. Oh goody =)