4 ms·
A natively compiled language can be written in whatever language you feel is easiest to write the compiler in, so either the language you are most comfortable i
by dkersten 17y ago
A natively compiled language can be written in whatever language you feel is easiest to write the compiler in, so either the language you are most comfortable in or the language with the best parser/code gen libraries.
Once you can compile your languages source code, you could reimplement the compiler in your language, so that it is self hosted. Of course, you can't do this until you can compile your code, hence doing it in another language first.
If your language is interpreted or JIT compiled, running on some kind of VM, then obviously you won't be self hosting, so you need to use a lnaguage which is suitable for executing your language. Most people seem to choose C, I guess because its low level and they want to reduce overhead.
I myself find Python to be nice to write parsers and such in (and it plays nice with ANTLR), though my most successful code generator toy project was written in Clojure.
- eru 17y agoAnd it would be actually a sensible thing to write a C compiler in Python. C is not a very nice language to write complicated programs in --- and compilers don't need C's speed. They just need to produce (correct and) fast code, but they do not need to run bleedingly fast.
- smallblacksun 17y agoUm, what? You want your compilers to be very fast, otherwise you end up wasting a lot of developer time (and thus money) waiting for compilation.
- j_baker 17y agoEspecially for C. It just takes too long to compile.
- silentbicycle 17y agoC++ is far, far worse.
- barrkel 17y agoYou got that backwards. For most development, you want a fast compiler but you don't care so much about the runtime speed, so long as its correct. Also, the more optimizing the compiler, the higher the probability that you'll hit bugs, affecting correctness.
- eru 17y agoThen use a C-interpreter for development.