High-Level Source Code Synthesis and the Host Language
High level source code synthesis
The Mynx programming language uses high-level language (HLL) code synthesis. Instead of generating a direct binary for a JVM .class or CLR assembly, Java source (of the most elementary kind to avoid a specific version of Java) and C# source (with the same restriction) is created--raw source code.
Later, a C/C++ compiler could be used to generate binary libraries and executables for a platform. Code synthesis is code generation, but I use a different terminology to emphasis the distinction of code generation from code synthesis.
Raw Source Code
The raw source code (which must be a valid class in the host language) is then compiled into a binary using a back end compiler. The binary can then be moved to another directory, put in a archive file, or processed by another library.
The CodeDom is a really cool idea in .NET, one that Java has finally caught up to formalizing in Java 6--although before in Java there were work arounds and libraries to compile code on the fly. Effectively, instead of assembly that is interpreted, or assembled into a binary form, the HLL source code is the assembly.
Advantages of Raw Source Code Synthesis
The advantages of using HLL source code synthesis are:
- simplicity - simplifies code synthesis or code generation.
- flexibility - code synthesis can be adapted for features.
- versatile - synthesized code can add code for tracing, debugging, profiling.
- utility - HLL source code can be used in host language (in theory language inter-operable).
- abstraction - source code can use HLL features without specifics (such as reflection).
Disadvantages of Raw Source Code Synthesis
There is no free lunch, so it follows that there are disadvantages to HLL code synthesis. The disadvantages of using HLL source code synthesis are:
- collision - Java/C# rooted class hierarchy, so class names for methods and attributes might collide in the language during HLL code synthesis.
- entanglement - quirks in HLL features can cause problems; one host language to another might not be same code synthesis.
Summary
Like anything in engineer, there are trade-offs, but the disadvantages as compared to the advantages of HLL code synthesis are not intractable. The really big advantage is code synthesized in the HLL and compiled can be used on any platform the host language is available for. Another big advantage is as improvements are made in the host HLL and its platform, those advantages translate upward (no pun intended) to the language implemented in the host HLL. All the advantages make compensating, and working around the disadvantages worthwhile for programming language implementation.
Labels: code generation, code synthesis, high-level language, mynx, Mynx compiler, source code synthesis

