Under The Hood: How the ColdFusion Compiler Works

07 Dec 2006

I must say I work with a really amazing team at work, and there is rarely a day we don't get into complex technical discussions about anything from "what algorithm is the best to do x" to getting into deep geeky details about how certain platforms work such as the Hotspot compiler in Java. Granted we aren't a typical CF development shop (I've actually been working exclusively in Java for the past couple of months for instance), so we have a wide variety of programmers and skill sets and so forth on the team. In general we'd rather hire smart people with solid backgrounds than someone who has 80 years of experience in Ajax.Net and RubyGroovyFlex 2.0 on their resume, and over time I think it's proved to be a very valuable asset.

We've talked about how CF translates into Java many times over the past couple of years and some of the inherent performance problems with weak typing (at some point it still has to be converted back to static typing-- this is a basic theoretical problem that any dynamically typed language has). I showed my co-worker (and primarily Java programmer) Rod the "what is wrong with the ColdFusion compiler" post, and he has a very well written response to how ColdFusion translates its own dynamically typed tag based syntax down to statically typed Java code. Of course the high level Computer Science answer would just be "it translates CFML to Java using a parser generator then recompiles it, duh", but instead he goes into the details of the implementation of the parser generator as to how it types the dynamic variables at the Java level. He doesn't really ever do any ColdFusion, so be easy on him in the comments if you have a bone to pick on the CF side. ;)

A related thing to note that he doesn't cover is how much faster it is to instantiate objects in cfscript rather than CFML on a percentage basis. Just some food for thought. I can do a follow-up post on this in particular topic if anyone is interested.

I cover a slightly similar topic to this in an upcoming CFDJ article, so stay tuned. :)