So, it may seem unusually stupid to be rewriting the Epoch compiler again as the core work behind R12. After all, R11 is barely out the door, and surely there's time to do something like, oh, say, make the language a bit more powerful?
Unfortunately, adding more features and richness to the language has hit a point of diminishing returns - not because of the language's completeness (which is not to say it's anywhere near complete), but rather because of iteration time. It's gotten to the point where compiling even the relatively trivial Era source code takes about 30 seconds. This is not acceptable.
R12 will, therefore, feature a rewritten compiler. The VM and remainder of the toolchain will remain in place; all that's really going away is the parser and the AST decoration layer.
Here's an executive summary of the changes coming in R12:
- Replacing boost::spirit::classic with something faster
- Replacing the extensively ad hoc code generation mechanism with a proper AST decoration layer
- Optimizing certain elements of the compiler chain for speed and memory usage
- Implementing separate compilation to further reduce program compile times
Right now I'm playing with boost::spirit::qi, the successor to spirit classic; it reports a roughly 20x speed increase in certain small test cases, but has some downsides. In particular, I can't seem to reliably compile the parser using qi, because it generates so much code that Visual C++ literally reports an out-of-memory error. Moreover, I don't know how well qi scales to nontrivial grammars like that used by Epoch.
So there's a good chance I may bite the bullet and go deploy a more traditional parser generation framework for the next release, because I can't afford to have my tools crapping themselves on relatively straightforward code. I really don't want to do this, because it'll make dynamic parsing a righteous pain in the ass, but what has to be done has to be done.
I hope to improve the ~30 second build time for Era to under a second. That ought to be enough for the next Epoch release, I think!
On the plus side, I'm a good bit down the road of generating a proper AST representation using qi and fusion, which is actually going fairly well and hasn't been much of a pain. So far function definitions are being parsed correctly and the AST is populated with them, but there's no support for statements or general expressions or entity calls yet. So obviously lots of work left to do.
I had dimly hoped, at one point, to get the compiler running again by the end of the weekend; but with the complete redesign of the AST generation mechanism, it'll take the rest of today just to reach a point where the AST is getting populated to begin with. After that I'll have to rewrite all the decoration logic, the semantic checking logic, and the code generation subsystem.
Blargh. Obviously this will end up being the multi-week ordeal that I dreaded it would become.