Live data from Hacker News

Zig self hosted compiler is now capable of building itself

github.com

101–110 of 285 posts

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

#101
post #42

Earlier quoted context omitted.

Well, OCaml Rust compiler also didn't use LLVM and used its own lightweight code generator and I think self-hosted Rust compiler frontend was in fact faster than OCaml Rust compiler frontend.

With both projects, how much of the improvement is simply building for the second time?

For Rust, I think improvement was almost entirely due to LLVM producing faster code. That's not applicable to Zig case, since both old and new compiler use LLVM. I don't know enough about Zig to answer.

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

#102

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 recommend C. Once you get the hang of it, it's as fast as writing Rust code (and you don't have to think about borrow checks).

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

#103
post #73

Earlier quoted context omitted.

From talking to a Googler the reason why Google devotes resources to Kotlin is that there was and still is a large external demand from the Android development community for Kotlin.

Kotlin adoption was triggered from inside, with some anti-Java attitude. https://talkingkotlin.com/the-first-kotlin-commit-in-android...

My information was from someone from the team working on jetpack compose. So maybe the answer I was given comes from a different context.

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

#104

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.

Faster feedback loop is a much better development experience.

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

#105
post #58
post #40

Earlier quoted context omitted.

Happy to see the C backend coming along. LLVM is a major barrier to use on esoteric embedded devices.

You can also target C through Wasm. https://github.com/WebAssembly/wabt/tree/main/wasm2c

My genuine question is what sort of code-size and/or performance impact the translation imposes.

The simple example in the README.md seems straightforward enough, but I wonder if there are any pathological explosions in practice.

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

#106
post #99

Earlier quoted context omitted.

> 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.

An apple to apple comparison is impossible because rustboot compiled a very different language. But I suspect suitably updated rustboot would be still faster because compilation time is dominated by LLVM.

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

#107

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

The original OCaml compiler didn't have essentially any of the static analysis that Rust would eventually be known for. Rust in 2011 (when rustc bootstrapped) was dramatically different from what would later stabilize in 2015.

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

#108
post #97
post #93

Earlier quoted context omitted.

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.

But also said that it's basically irrelevant. Hence my confusion.

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

#109
post #95
post #29

Earlier quoted context omitted.

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.

The general purpose allocator in the zig standard library has protections against use after free bugs.

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

#110

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.

The longer the delay between writing some chunk of code, and executing it, the more valuable mental context is lost. I find it way more productive to work in small chunks iteratively, testing as I go along, rather than writing for a long chunk of time, then running tests and figuring out what bugs are making tests fail.
Post reply on HN