Thursday 21 July 2011

Unified Compilation

In my previous post, I mentioned unified compilation, but in this post I'm going to go into a little more depth. So what is unified compilation? Quite simply, unified compilation is the idea that everything gets compiled at one time, unless you have a desperate need for a C interface and run-time loading. As a static-favouring language, that would mean at compile-time. Now, I've already expressed the idea that all code could be expressed as a meta-function, and this is just the next step in that line of reasoning. This would imply that basically all "DeadMG++" code would be shipped as meta-functions that add the code to the compiler structures.

The downsides, as they are, are quite simple- you can't change your code without a re-compile. The other potential downside is longer compile-times. Now, the language offers for some serious compile-time optimizations that I've already discussed, mostly involving compiling functions to assembly and then executing them to compile the program, but quite simply, it's doing a lot more work at compile-time, so I'm not that bothered about longer compile-times, and the users see a real ease of use benefit from it. Ultimately, programmer time is more valuable than compiler time. Compiler time, you can solve by throwing money at the problem. Programmers need training, experience, offices, that sort of thing.

The upsides are very numerous. The very best optimization, as the whole program is known at once. Shipping "templates" that aren't in source code form, don't take forever and a million compiler-specific changes to make work. Compile-time reflection (and run-time reflection can be likely implemented on top of it) and other meta-programming. Type inference across library boundaries. No binary compatibility problems with using complex types, throwing exceptions, adding overloads, or anything like that. Code for different architectures and platforms could be shipped as a single library. It would be similar to how managed code works, except it would operate at compile-time. And be better, of course.

This doesn't exclude dynamic loading. I would expect that the very minimum would be expressed as a dynamic load, if any, and then the rest would be in pre-compiled static loading format.

No comments:

Post a Comment