4 ms·
Hmmm my conclusion was drawn from the following languages having their main compiler written in that language: Haskell, Java, Scala, OCaml, Kotlin, C++, C#, F#,
by pharmakom 6y ago
Hmmm my conclusion was drawn from the following languages having their main compiler written in that language: Haskell, Java, Scala, OCaml, Kotlin, C++, C#, F#, Rust, Go, Nim, Zig...
Not criticising any of these choices, but one has to wonder why. Most of these compilers were rewrites after a bootstrap implementation was created in an existing language.
- gpderetta 6y agoat least two reasons come to mind: simplified bootstrapping and being a testcase and a source for feature requests for the language itself (especially important early on when there are few large codebases in that language).
- pharmakom 6y agoIs it a good test case though? If the language is designed for writing compilers then sure, but I imagine most people using TypeScript (for example) just want to write full-stack web applications.
- MaxBarraclough 6y agoI agree that TypeScript isn't an obvious choice for writing a compiler, but self-hosting still has advantages. It tests out the language at scale, and there's the 'dogfooding' aspect that the compiler developers use the language they created (although as you say they're using it for an unusual purpose).
- pjmlp 6y agoDepends, https://www.infoworld.com/article/3436840/microsoft-proposes-static-typescript-for-embedded-systems.html https://www.infoworld.com/article/3436840/microsoft-proposes... https://www.microsoft.com/en-us/research/blog/rocket-fast-embedded-typescript-for-makecode-arcade/ https://www.microsoft.com/en-us/research/blog/rocket-fast-em...
- wrycoder 6y agoWirth (Pascal, Modula, Oberon) believes that the best performance test for a compiler is how fast it can compile itself.
- MaxBarraclough 6y agoI'm not sure that really stands up. Assembly languages would always win, no? Forth would also do very well.
- MaxBarraclough 6y ago> my conclusion was drawn from the following languages having their main compiler written in that language: Haskell, Java, Scala, OCaml, Kotlin, C++, C#, F#, Rust, Go, Nim, Zig... I don't see a problem, all those languages seem well suited to implementing a compiler. For comparison, the Bash scripting language would be a nightmare. > Most of these compilers were rewrites after a bootstrap implementation was created in an existing language. Sure, how else would they do it?
- atq2119 6y ago> Sure, how else would they do it? Write the very first version of the compiler for language X in X. Then hand-translate that compiler source to some other language or assembly. Then you don't ever have to rewrite the compiler.