Why compile to C?
I mentioned previously that I am targetting C but did not give a reason. Why not use LLVM instead, or go straight to machine code?
Generating C does have some drawbacks, such as:
- The need to install a C compiler
- Not being able to generate machine code at run time
- Risk of undefined behavior creeping into Newton
But for me, being able to read and edit the generated code trumps all of the above.
Readability is important since the compiler has not been battle-tested yet, so I must be able to verify the generated code line by line, and that is harder to do with low-level code simply because there are more lines to read.
Editing the code is important because the first version will not be very optimized and I may need to remove some inefficiencies manually, for instance in the standard library or a future product written in Newton.
Stefan