Live data from Hacker News

Zig Is Self-Hosted Now, What's Next?

kristoff.it

21–30 of 159 posts

Re: Zig Is Self-Hosted Now, What's Next?

#21
post #5
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

I don't know about Zig specifically, but things using LLVM tend to be absurd memory hogs. I remember having to disable parallel compilation for clang to prevent OOM issues.

Yeah, 9.6GB of RAM seems like a really small number when you're talking about LLVM.

Re: Zig Is Self-Hosted Now, What's Next?

#22
post #11

Earlier quoted context omitted.

I'm not so familiar with Zig, are you saying that the compiler fails to compile correct (i.e. according to spec) code?

We're using the C++ compiler rather than the self-hosted compiler because the self-hosted compiler does not yet support async. Yes, it sometimes fails to compile correct code (by crashing) or compiles correct code to incorrect code.

No post body was provided.

Re: Zig Is Self-Hosted Now, What's Next?

#23
post #6
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

Hey, back in the day, I used a Pascal compiler on CP/M that worked with 64K.

Compilers like that would go directly from text -> machine instructions, step by step (or to very close approximation) because that is all you had the time and memory for.

Modern compilers lex then parse into tree structures and then do lots of mutations and traversals of that tree to optimize in different ways for different architectures, and more code is included at once to make more optimizations possible and on and on and on.

Re: Zig Is Self-Hosted Now, What's Next?

#24
post #12
post #11

Earlier quoted context omitted.

I'm not so familiar with Zig, are you saying that the compiler fails to compile correct (i.e. according to spec) code?

Yeah, theres a surprising amount of stuff that's buggy, think `if` or `recursive structs with pointers` level stuff.

Can you substantiate this further? I don't see how basic stuff like that could be subtly buggy, the Zig devs are very qualified IMO.

Re: Zig Is Self-Hosted Now, What's Next?

#25
post #3

Correctness please. Zig is a way too simple language to justify all the really easy to hit bugs. I'd give everything for a zig compiler that's 10 times as slow but actually compiles my code. Also testing infrastructure. Zig really needs fuzzing and property testing tooling build-in. Hitting stage 2 with arbitrary autogenerated zig code and IR, would have really helped detect regressions for example.

eh. if it isn't fast, then there's no point using it either. the c++ i have to compile at work takes 16 minutes to test some crap. that is prohibitively slow.

Re: Zig Is Self-Hosted Now, What's Next?

#26

Earlier quoted context omitted.

We're using the C++ compiler rather than the self-hosted compiler because the self-hosted compiler does not yet support async. Yes, it sometimes fails to compile correct code (by crashing) or compiles correct code to incorrect code.

Quoted post unavailable.

i hope not. i like the idea of zig but bad stewards can ruin an otherwise good project

Re: Zig Is Self-Hosted Now, What's Next?

#27
post #12

Earlier quoted context omitted.

Yeah, theres a surprising amount of stuff that's buggy, think `if` or `recursive structs with pointers` level stuff.

Can you substantiate this further? I don't see how basic stuff like that could be subtly buggy, the Zig devs are very qualified IMO.

Here's a pretty substantial bug from just a week ago: https://github.com/ziglang/zig/issues/13211

Re: Zig Is Self-Hosted Now, What's Next?

#28
post #15

Earlier quoted context omitted.

Looks like your complaint was a known tradeoff. > The self-hosted compiler brings many advantages, but it did cost us a significant amount of effort and time. While Zig is still going up in popularity and starting to make a tiny dent in the industry, people that have been following along for long enough will know that this work has reduced our momentum in the last two years. > Bug fixes in the compiler have been ofte…

Your quoted sentence talks about bugs in the old C++ compiler, I'm talking about bugs in both compilers. Pretty much all of the talks and blog posts on the `in-Zig` compiler are about better performance, lower memory footprint, e.t.c. I would much rather have heard a talk about how they improved correctness through automatic testing, formal methods, simple language design e.t.c. A language that (does or doesn't) comp…

I see the acknowledgements of the bugs in the old compiler, but what bugs in the new compiler are you talking about? Also, a recurring theme in zig has been the advantages of their simple language design.

Re: Zig Is Self-Hosted Now, What's Next?

#30
post #3

Correctness please. Zig is a way too simple language to justify all the really easy to hit bugs. I'd give everything for a zig compiler that's 10 times as slow but actually compiles my code. Also testing infrastructure. Zig really needs fuzzing and property testing tooling build-in. Hitting stage 2 with arbitrary autogenerated zig code and IR, would have really helped detect regressions for example.

Yep, I've also run into a myriad of gotchas while building things or poking around in written code. Just last week I was trying to build someone's year old repo that blew up on nightly, yet compiled on 0.9 just fine.

But - it's plastered all over the entire project that it is a work in progress. This post itself is talking about how for loops are getting broken. It's an ambitious project with a talented and ambitious team, and their vision and execution so far has been awesome. I'm not using Zig for anything resembling production code at the moment - because it's going to break. But when it stabilizes - there is a lot of potential.

Post reply on HN