4 ms·
Are there any languages out there that can only be compiled by a compiler written in their own language? Presumably because the original pre-dogfood compiler st
by fouronnes3 5y ago
Are there any languages out there that can only be compiled by a compiler written in their own language? Presumably because the original pre-dogfood compiler stopped being maintained years ago. So that if we somehow lost all binaries of the current compiler, that language would effectively be lost?
- dottedmag 5y agoC?
- viraptor 5y agoYou're commenting on an article about Zig which became self-hosted and can compile C. (There's also lots of other C compilers available)
- dundarious 5y agoZig compiles C/C++ by deferring the vast majority of the work to libclang, which is written in C++. Also note Zig is self-hosted when using the LLVM backend, which means deferring to C++ for much of the code generation. There is no "end-to-end Zig" self-hosted compiler yet, because the Zig native backends are not as near completion. See the creator's comment about the breakdown: https://news.ycombinator.com/item?id=31052234 https://news.ycombinator.com/item?id=31052234. (I'm excited about this progress, so this is not meant as any kind of knock on Zig, which I think is quite impressive) But you're right that C is not a good example.
- coder543 5y agoA lot of popular C compilers are actually written (at least partially) in C++ these days.
- dottedmag 5y agoIn this case, C++?
- kaba0 4y agohttps://guix.gnu.org/manual/en/html_node/Preparing-to-Use-the-Bootstrap-Binaries.html https://guix.gnu.org/manual/en/html_node/Preparing-to-Use-th... The Guix project likes bootstrappility very much. They basically host a tiny assembly C-compiler (only for a subset of C) which can compile a C compiler written in C for the whole subset that can bootstrap the whole ecosystem.
- dottedmag 4y agoThis link is better: https://savannah.nongnu.org/projects/stage0 https://savannah.nongnu.org/projects/stage0: bits to asm to C, and then everything else follows.
- richardfey 5y agoMost modern languages cannot be compiled anymore with their original pre-dogfood compiler, but we have the sources of the older versions so you can bootstrap them in a sequence.
- deleted 5y ago[deleted]
- retrac 5y agoThe Haskell GHC compiler is written mostly in Haskell. Rust's compiler is also written in Rust, these days. TypeScript's compiler is in TypeScript. It's a pretty common state of affairs, actually. Often arises out of the second or third implementation of the compiler being much better than the first attempts, probably coupled with the momentum of people using the language who can contribute to the tooling because it's in the same language.
- fasquoika 5y agoGHC is nearly impossible to bootstrap if you don't consider the vendored transpiled C code to be source. Versions of GHC not dependent on GHC were never public AFAIK. https://elephly.net/posts/2017-01-09-bootstrapping-haskell-part-1.html https://elephly.net/posts/2017-01-09-bootstrapping-haskell-p...
- skrebbel 5y agoTypeScript
- mkl 4y agoNope: https://github.com/swc-project/swc https://github.com/swc-project/swc
- amelius 5y agoIf your language (call it X) can only be compiled by a compiler written in X, then you can always create an X-to-C transpiler (it doesn't need to be efficient, and it can even leak memory, as long as it can complete the bootstrapping process).