News for hackers. Stuff that matters.
Re:Zig self hosted compiler is now capable of building itself by fouronnes3 on Saturday April 16, 2022 @09:51AM (#31052319)
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?
Re:Zig self hosted compiler is now capable of building itself by richardfey on Saturday April 16, 2022 @10:04AM (#31052411)
Most 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.
Re:Zig self hosted compiler is now capable of building itself by retrac on Saturday April 16, 2022 @12:19PM (#31053562)
The 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.

Re:Zig self hosted compiler is now capable of building itself by amelius on Saturday April 16, 2022 @01:46PM (#31054353)
If 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).
Re:Zig self hosted compiler is now capable of building itself by fasquoika on Saturday April 16, 2022 @12:45PM (#31053823)
GHC 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-p...

Re:Zig self hosted compiler is now capable of building itself by dottedmag on Saturday April 16, 2022 @09:57AM (#31052360)
C?
Re:Zig self hosted compiler is now capable of building itself by coder543 on Saturday April 16, 2022 @11:09AM (#31052902)
A lot of popular C compilers are actually written (at least partially) in C++ these days.
Re:Zig self hosted compiler is now capable of building itself by dottedmag on Sunday April 17, 2022 @04:01AM (#31059322)
In this case, C++?
Re:Zig self hosted compiler is now capable of building itself by kaba0 on Sunday April 17, 2022 @02:09PM (#31062865)
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.

Re:Zig self hosted compiler is now capable of building itself by dottedmag on Monday April 18, 2022 @10:24AM (#31071051)
This link is better: https://savannah.nongnu.org/projects/stage0: bits to asm to C, and then everything else follows.
Re:Zig self hosted compiler is now capable of building itself by viraptor on Saturday April 16, 2022 @10:16AM (#31052515)
You're commenting on an article about Zig which became self-hosted and can compile C. (There's also lots of other C compilers available)
Re:Zig self hosted compiler is now capable of building itself by dundarious on Saturday April 16, 2022 @10:43AM (#31052710)
Zig 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. (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.

Re:Zig self hosted compiler is now capable of building itself by skrebbel on Saturday April 16, 2022 @01:31PM (#31054218)
TypeScript
Re:Zig self hosted compiler is now capable of building itself by mkl on Sunday April 17, 2022 @09:46AM (#31060766)