archives

Cross-platform idiomatic code generation

Some languages cross-compile. Things like Xtend and Shen generate source code, whereas things like Bigloo and Fantom target bytecode. For some reason I day dream about tools to translate a Nice Language into Regular Day Job Languages while somehow maintaining an idiomatic source-level code style in each of those.

Model driven design tools talk about it sometimes: Practical Model-to-Code Transformation in Four Object-Oriented Languages. Admittedly that's constraining things a bit since they are all OO, and not e.g. 1 OO, 1 FP, 1 Logic target.

This paper describes a practical framework that generates idiomatic code in four different object- oriented languages, Java, C++, Eiffel and C#, starting from an intermediate model expressed as an XML parse tree. Effort was directed towards ensuring that the generated systems executed with identical semantics.