Live data from Hacker News

Zig self hosted compiler is now capable of building itself

github.com

91–100 of 285 posts

Re: Zig self hosted compiler is now capable of building itself

#91

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?

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

#92

I was thinking of learning Rust but it seems a bit overkill due to manual memory management as compared to languages with similar speed like Nim, Zig, and Crystal. How would one compare these languages? Is it worth learning Rust or Zig and dealing with the borrow checker or manual memory management in general, or are GC languages like Nim or Crystal good enough? I'm not doing any embedded programming by the way, just…

I've found that Go is not elegant enough for me and Rust is too difficult to write (I started using Rust in 2015 and after years of trying I eventually realized Rust doesn't make sense for most apps), so I'm all in on Crystal. Despite not having much prior Ruby experience, I absolutely love the language.

Crystal doesn't have built-in support for parallelism, let alone production-grade support. This is a significant lack for a modern language.

For a language that is around 8 years old, this may be a serious problem, since the surrounding ecosystem has been probably written without parallelism in mind, and it may take a very long time to be updated (if ever).

Re: Zig self hosted compiler is now capable of building itself

#93

Best alternative to C, built with solid foundation to ensure fast compile speed, fast iteration, and easy to maintain code

I don't understand why people want fast compile speeds so much. My day job is/was writing C on something that requires 30+ minutes for one compilation run. It feels like people want fast compilation speeds because they need to keep running their software for some reason. Fast compilation speeds are a nice to have but basically irrelevant for normal developing of software in my experience.

Sorry I may have missed the sarcasm.

Your day job project takes half an hour to compile and you don't see the point in speeding that up?

Re: Zig self hosted compiler is now capable of building itself

#94

I was thinking of learning Rust but it seems a bit overkill due to manual memory management as compared to languages with similar speed like Nim, Zig, and Crystal. How would one compare these languages? Is it worth learning Rust or Zig and dealing with the borrow checker or manual memory management in general, or are GC languages like Nim or Crystal good enough? I'm not doing any embedded programming by the way, just…

> or are GC languages like Nim or Crystal good enough?

Any programming language is good enough for their own use cases :) It's a matter of understanding which the use cases are.

I'm a big Rust fan, but I nonetheless believe that the use cases for programming languages with manual memory management are comparatively small, in particular, since GC has been improved a lot in the last decade.

For undecided people, I conventionally suggest Golang. Those who at some point need deep control, will recognize it and change accordingly.

Re: Zig self hosted compiler is now capable of building itself

#95
post #29

Earlier quoted context omitted.

Thanks for the detailed answer! I have more questions, if you'll indulge me: If I understood it correctly, you think smart pointers and reference counting are bad habits. Why? Especially the smart pointers bit. Why does Zig use less memory than other languages? Is it inherent to Zig, or can it be reproduced in other languages?

I think Zig prefers explicit memory management, because allocations may fail and should be handled explicitly, and because automatic deallocations lead to hard-to-predict lifetimes (excess memory usage, and bugs for resource handles that are destructed at hard to predict moments). These are things that a "systems language" programmer should put in the work to do correctly/near-optimally, and not ask the compiler to j…

And as we know from C, every developer is quite capable of taking care of use after free possible bugs.

Re: Zig self hosted compiler is now capable of building itself

#96

Earlier quoted context omitted.

imo, most code can do just fine with GC. modern GCs can be relatively low overhead even with guaranteed small pauses (10ms). furthermore, most code that can't handle pauses can be written to not allocate any memory (so GC can be temporarily turned off). as such, the only two places where you need manual allocation are for OS development, and hard real time requirements.

When tail latency (high-percentile latency) is important GC is not a good choice. Wait-free (threads progress independently) concurrent algorithms also need wait-free memory reclamation with bounded memory usage to be able to guarantee progress. But most software are throughput-oriented.

Additionally, not all GCs are made alike, and languages like D, F#, C#, Nim, Swift, among others, also offer value types and manual memory management, if desired.

Re: Zig self hosted compiler is now capable of building itself

#97
post #93

Earlier quoted context omitted.

I don't understand why people want fast compile speeds so much. My day job is/was writing C on something that requires 30+ minutes for one compilation run. It feels like people want fast compilation speeds because they need to keep running their software for some reason. Fast compilation speeds are a nice to have but basically irrelevant for normal developing of software in my experience.

Sorry I may have missed the sarcasm. Your day job project takes half an hour to compile and you don't see the point in speeding that up?

GP did say it is a nice to have.

Re: Zig self hosted compiler is now capable of building itself

#98
post #75

Earlier quoted context omitted.

Why do you trust the assembler you got from somewhere any more than a compiler?

Because hand written assembly is readable!

It might be, but have you also validated the microcode executing it?

Or the Verilog/VHDL for the logic gates used by the CPU, for that matter?

Re: Zig self hosted compiler is now capable of building itself

#99

Hello HN! Here is some context to decorate this announcement: The Zig self-hosted compiler codebase consists of 197,549 lines of code. There are several different backends, each at varying levels of completion. Here is how many behavior tests are passing: LLVM: 1101/1138 (97%) WASM: 919/1138 (81%) C: 740/1138 (65%) x86_64: 725/1138 (64%) arm: 490/1138 (43%) aarch64: 411/1138 (36%) As you might guess, the one that thi…

> written in Zig instead of C++, uses significantly less memory, and represents a modest performance improvement That's particularly interesting considering the rust compiler in rust has never been as fast as the original OCaml one

I wonder how much this statement still holds. I've never used the OCaml bootstrap compiler but performance wise, the rust compiler has improved incredibly since the 1.0 release.

Re: Zig self hosted compiler is now capable of building itself

#100

Hello HN! Here is some context to decorate this announcement: The Zig self-hosted compiler codebase consists of 197,549 lines of code. There are several different backends, each at varying levels of completion. Here is how many behavior tests are passing: LLVM: 1101/1138 (97%) WASM: 919/1138 (81%) C: 740/1138 (65%) x86_64: 725/1138 (64%) arm: 490/1138 (43%) aarch64: 411/1138 (36%) As you might guess, the one that thi…

it's so surprising to hear there was a Zig Meetup in Milan, I'd not expect a large enough community to exist there, pretty cool!
Post reply on HN