Thursday, February 15, 2007

Languages and compilation speed

Yesterday, I went to visit Electric Cloud, a company that provides a suite of tools for building large applications, including a build manager and a distributed make system. While I was there I met the CEO, John Ousterhout, the designer of Tcl/Tk. He made an interesting observation about large compilations: in visits to customers with large codebases to compile, they had found that C++ code compiled the slowest, next was C, while Java was the fastest mainstream language to compile. The position of C++ does not surprise me, but Java being faster than C did--although, to be honest, I'd never given the matter much thought.

Because this discussion was a branch off the main topic, I didn't get to pursue it further, but Ousterhout did attribute it in passing to the efficiency of Java compilers. Without more info, though, I'm not sure I'm convinced that it's a question of compiler efficiency. I suspect that not needing to generate native code is a big factor, as is the simplified linking step.

2 comments:

Anonymous said...

I would agree that surely this has to do with linking in large part, and I know that another huge challenge is the preprocessor.

Anonymous said...

Just to clarify my comment to Andrew: I think it is *language* properties, more than properties of particular compilers, that make Java compile so much faster. C++ is a very complex language and features like templates, though quite useful, make it very difficult to build fast compilers. Java is a much simpler language, hence faster to compile. Compiling to an intermediate language rather than machine code also reduces the work a Java compiler must do.