Inevitably people will ask “what language should I choose for my compiler?”.
The answer is really: “you can use any language, so all things being equal, pick one you’re good at.”
Of course there are caveats:
- You want it to go really fast? Then C is better than Python.
- Are you making a DSL? Then you probably want to do it in the host language.
- Do you want to experiment with some parsing techniques? Then some languages might be a
better fit than others
… and so on.
So when someone says something like “C is a bad choice for writing a compiler” as a general
statement, you know they are just it up as they go along.
The C3 compiler is written in C, and there is frankly no other language I could have picked
that would have been a substantially better choice. – Sure, writing it in C2 or Odin would
certainly have avoided some of C’s warts, but the difference would not have been significant.
And doing an OO-style C++, or worse, Java, would just have pushed the compiler to slower and
more bloated, wit