News for hackers. Stuff that matters.
Re:Zig Is Self-Hosted Now, What's Next? by j-pb on Tuesday October 25, 2022 @12:19PM (#33332663)
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.

Re:Zig Is Self-Hosted Now, What's Next? by dist1ll on Tuesday October 25, 2022 @12:50PM (#33333111)
I'm not so familiar with Zig, are you saying that the compiler fails to compile correct (i.e. according to spec) code?
Re:Zig Is Self-Hosted Now, What's Next? by anonymoushn on Tuesday October 25, 2022 @12:55PM (#33333158)
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.
Re:Zig Is Self-Hosted Now, What's Next? by puffoflogic on Tuesday October 25, 2022 @01:15PM (#33333435)
Watch out, the zig devs have said that actually all languages miscompile stuff routinely and if you say anything bad about zig online they'll brigade-flag your posts!
Re:Zig Is Self-Hosted Now, What's Next? by 8n4vidtmkvmk on Tuesday October 25, 2022 @01:31PM (#33333649)
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? by j-pb on Tuesday October 25, 2022 @12:53PM (#33333139)
Yeah, theres a surprising amount of stuff that's buggy, think `if` or `recursive structs with pointers` level stuff.
Re:Zig Is Self-Hosted Now, What's Next? by mattgreenrocks on Tuesday October 25, 2022 @01:28PM (#33333602)
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? by mirashii on Tuesday October 25, 2022 @01:32PM (#33333659)
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? by singularity2001 on Tuesday October 25, 2022 @02:41PM (#33334548)
"stage1 is expected to be broken in many ways and does not handle non-x86_64 C ABI at all."

so its self-hosted for x86_64 only so far, which is fine if communicated

Re:Zig Is Self-Hosted Now, What's Next? by somethingor on Tuesday October 25, 2022 @03:27PM (#33335037)
stage1 is the non-self-hosted compiler (the one written in C++)
Re:Zig Is Self-Hosted Now, What's Next? by kristoff_it on Tuesday October 25, 2022 @01:44PM (#33333827)
We do have a good number of known miscompilations, I can substantiate for the parent poster with a simple link: https://github.com/ziglang/zig/labels/miscompilation

It's also true that the self-hosted compiler has caused new bugs to pop up, which in turn made us write new behavior tests. To me that's to be expected with every project aimed at rewriting an existing system.

It's also true that proper testing infrastructure is critical, and we do have it, although the requirement of more than 8gb of ram has not played in our favor in the past. We plan to revamp our CI systems once we are done with this release.

That said, it's a v0 language. If you choose to use it, you know you're coming with us on a ride. The choice of how much to prioritize correctness vs progress is influenced by many things that are going on in the project and there is no one clear strategy that trumps all others.

Quoting j-pb from another comment:

> A language that (does or doesn't) compile your code in 0.1 seconds to a broken binary is worse than piping your code into dev/null.

Eh, yes, but also no. Obviously a compiler needs to work correctly to be useful, but our priority right now is to move the project forward using our best judgment, not ensure that it has maximal utility to early adopters. I do agree with the sentiment that the compiler needs to be reliable, it's just that Zig is v0 for a reason.

In concrete terms I think that once we're done with an initial adjustment phase, you will find that the compiler will have a steady increase in stability over time. That's how it was with the bootstrap compiler before we started the self-hosted work.

Also, quoting dist1 from up the comment tree:

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

Keeping in mind everything that I just wrote, note that Zig doesn't have a spec yet. Sometimes, some issues in the compiler are the result of discovering that a design choice needs to be amended.

Recent example of that: https://github.com/ziglang/zig/issues/12251

Re:Zig Is Self-Hosted Now, What's Next? by the_mitsuhiko on Tuesday October 25, 2022 @05:40PM (#33336528)
> Eh, yes, but also no. Obviously a compiler needs to work correctly to be useful, but our priority right now is to move the project forward using our best judgment, not ensure that it has maximal utility to early adopters.

I feel like I’m a potential early adopter and the amount of miscompilation I ran into playing around with it really made me lose interest. It seems like the priorities are set somewhere else entirely.

Re:Zig Is Self-Hosted Now, What's Next? by kristoff_it on Tuesday October 25, 2022 @06:21PM (#33336921)
Going by your own comment, you seem to not be an "early enough" adopter. That's totally fair, maybe Zig will be more interesting for you once it stabilizes more in the future.
Re:Zig Is Self-Hosted Now, What's Next? by the_mitsuhiko on Tuesday October 25, 2022 @06:32PM (#33337036)
I don’t believe this to be true.

Zig is 6 years old now going by Wikipedia. In comparison I use Rust in an more extensive way than Zig for almost 20 years now. I for sure wrote more Rust in 2012 when it was ~2 years? old than Zig last year, yet I don’t remember miscompilations on that level. The same is true for my recollection of using very early D which however at this point was in an earlier life of mine and very fuzzy.

Re:Zig Is Self-Hosted Now, What's Next? by kristoff_it on Tuesday October 25, 2022 @06:42PM (#33337159)
I'm not sure I understand your point. Zig is clearly too unstable for your liking, by your own admission.

If your point is that Rust was more stable (and why not, even an overall better project) at the same age, then I'm happy to immediately concede the point. But that doesn't really have any influence on the main question, does it?

Re:Zig Is Self-Hosted Now, What's Next? by the_mitsuhiko on Tuesday October 25, 2022 @07:03PM (#33337381)
The argument that you were making (unless I misunderstood you) is that there are more important issues for the language than correctness or appealing to early adopters to which I made the remark that this attitude is steering me away from the language.

Zig is in a weird spot because it has a similar momentum behind it than some other languages I was exited about, it has even more hype (and is very hype driven with streams and everything) yet it has from my experience with it much more stability issues. And I assume some of this comes from a relay complex compile time system that is harder to implement rigorously than some other things.

I also have to say that I find these responses unnecessarily combative.

Re:Zig Is Self-Hosted Now, What's Next? by kristoff_it on Tuesday October 25, 2022 @07:27PM (#33337615)
> The argument that you were making (unless I misunderstood you) is that there are more important issues for the language than correctness or appealing to early adopters to which I made the remark that this attitude is steering me away from the language.

Yes, and I still stand by my assertion. Next to you in the "early adopter spectrum" are people who can put up with more breakage on one side, and people who cannot put up with the current level on the other side. At any point in time the project will be somewhere along that spectrum and some people will be on one side of that line and others will be on the other.

Similarly, different things going on in the project will move the line in either direction. Switching to a new compiler implementation is unsurprisingly a source of bugs, if you want to use Zig now, you will have to accept the current state of things.

> it has even more hype (and is very hype driven with streams and everything)

Hype driven... you mean Andrew's 100 people streams? Or my 30 people streams? What hype-driving streams are you referring to. My YouTube channel with 4k subs (hit that milestone today btw)?

> I also have to say that I find these responses unnecessarily combative.

I really don't know what to tell you. If Zig is too broken for your liking, don't use it. If other projects at the same level of age/popularity/whatever had a level of breakage that you found tolerable, then great, and if Zig doesn't meet that standard, then it means, by definition, that it's too early for you to use it.

If you want to make a different point, then state it clearly, from the early adoption perspective, I don't see any argument to be discussed here.

Re:Zig Is Self-Hosted Now, What's Next? by username-404 on Thursday October 27, 2022 @09:15AM (#33357003)
> Hype driven... you mean Andrew's 100 viewer streams? Or my 30 viewer streams?

More like release notes with 1,000 upvotes on Reddit:

https://www.reddit.com/r/programming/comments/rl87pr/zig_pro...

Re:Zig Is Self-Hosted Now, What's Next? by pjmlp on Wednesday October 26, 2022 @01:11AM (#33340064)
2022 - 2010 ==> 12 years. :)
Re:Zig Is Self-Hosted Now, What's Next? by ksec on Wednesday October 26, 2022 @08:48AM (#33342846)
20 years? Something doesn't add up.
Re:Zig Is Self-Hosted Now, What's Next? by the_mitsuhiko on Wednesday October 26, 2022 @01:13PM (#33346616)
It’s a typo. Was supposed to say 10.
Re:Zig Is Self-Hosted Now, What's Next? by generalizations on Tuesday October 25, 2022 @12:54PM (#33333154)
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 often put on hold since fixing the bootstrap compiler was ultimately useless, and accepted feature proposals have been piling up because it would have required implementing everything twice.

Re:Zig Is Self-Hosted Now, What's Next? by j-pb on Tuesday October 25, 2022 @01:01PM (#33333255)
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) compile your code in 0.1 seconds to a broken binary is worse than piping your code into dev/null.

Re:Zig Is Self-Hosted Now, What's Next? by generalizations on Tuesday October 25, 2022 @01:34PM (#33333677)
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? by kristoff_it on Tuesday October 25, 2022 @01:48PM (#33333881)
See my reply in another comment tree https://news.ycombinator.com/item?id=33333827
Re:Zig Is Self-Hosted Now, What's Next? by 8n4vidtmkvmk on Tuesday October 25, 2022 @01:30PM (#33333629)
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? by thadt on Tuesday October 25, 2022 @01:42PM (#33333787)
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.

Re:Zig Is Self-Hosted Now, What's Next? by setr on Tuesday October 25, 2022 @01:48PM (#33333882)
> 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.

Isn’t that the point of nightly

Re:Zig Is Self-Hosted Now, What's Next? by thadt on Tuesday October 25, 2022 @01:53PM (#33333973)
Sure - but I believe it was due to a change in a language detail. I was just commenting that its not intended to be a particularly stable target quite yet.
Re:Zig Is Self-Hosted Now, What's Next? by Shish2k on Thursday October 27, 2022 @07:23AM (#33355970)
I need to use nightly because my code makes the stable compiler crash, so...
Re:Zig Is Self-Hosted Now, What's Next? by AndyKelley on Tuesday October 25, 2022 @01:50PM (#33333918)
If bugs are your concern, then this upcoming release is good news for you. Total number of open bug reports is 1,124. However if we remove bugs labeled "stage1" - that is - bugs that are no longer applicable because this release changes the default compiler to the self-hosted one - then the number drops to 514. It would be a fair characterization to say that this release cuts the number of known bugs in half. We have those stage1 bug reports still open because I mandated that every one must have test coverage before being closed, even though they are already fixed in master branch.

That said, I would humbly ask for you to trust my leadership on finding the balance on how much effort to spend on bug fixing versus how much to spend on progress. I think you underestimate how much is going to change before Zig tags 1.0. There are still a few experimental and exploratory changes planned, and when software specifications change, bugs are inevitably introduced. Spending the time to iron out 100% of the bugs found from fuzz testing, on a feature that ends up replaced with a different one that also needs to get debugged, is a waste of time, and a disservice to the wider user base of the project. We're better off finding the "sweet spot" for a swift journey, arriving at our destination early, and then busting out the hardcore QA.

I see https://github.com/ziglang/zig/issues/13211 mentioned elsewhere in this thread. I want to point out that getting the C ABI correct when using LLVM is a notoriously perilous process, as any other compiler dev reading HN today can attest, and this regression which lasted for a total of 6 days in master branch without ever gracing a tagged release, is a symptom of the fact that we actually addressed this C ABI problem at its core, added more test coverage, added an abstraction in the LLVM code generation, and fixed the C ABI for several targets.

And finally, I agree that fuzz testing should be integrated into Zig's unit testing system. That would be a nice enhancement.

Re:Zig Is Self-Hosted Now, What's Next? by kuramitropolis on Tuesday October 25, 2022 @03:13PM (#33334901)
Does/will Zig support the Actually Portable Executable format?

https://justine.lol/ape.html

Re:Zig Is Self-Hosted Now, What's Next? by DrNosferatu on Tuesday October 25, 2022 @06:07PM (#33336786)
Also have this very same question / “Cosmopolitan” Lib C. Zig Team?

Thanks in advance.

Re:Zig Is Self-Hosted Now, What's Next? by sobeston on Thursday October 27, 2022 @02:08PM (#33361554)
I believe where this stands is that if someone were to contribute and maintain this, then it could be part of the Zig compiler, however it is not something the Zig team themselves are planning on doing. Maybe give it a shot? I personally find the project interesting and fun but I'm not convinced that it's a good solution.
Re:Zig Is Self-Hosted Now, What's Next? by j-pb on Tuesday October 25, 2022 @04:03PM (#33335431)
The bug that's currently blocking me from any work using master is https://github.com/ziglang/zig/issues/12325

That's not really a bug related to unfinished features that might get replaced anyways, but simply one involving recursive structs with pointers between, i.e. linked lists.

Not detecting issues like these feels less like a "these parts are unfinished hence here be dragons" thing and more like a fundamental culture problem.

I'm fine with cutting myself every now and then with a sharp tool and cutting edge technology, but that can also be done while having a ever growing and mature core that promises at least some stability. The only alternative seems to be to pull a Hickey and work on it for two years without releasing anything.

Re:Zig Is Self-Hosted Now, What's Next? by nicoburns on Tuesday October 25, 2022 @06:05PM (#33336764)
You're using the master branch of a pre-1.0 tool, and you expect it to be stable without regressions? I feel like your expectations are too high.
Re:Zig Is Self-Hosted Now, What's Next? by rofrol on Wednesday October 26, 2022 @03:00AM (#33340651)
he just want to force zig devs to tackle his problems first.

Using phrases like "fundamental culture problem" or "at least some stability"

Re:Zig Is Self-Hosted Now, What's Next? by j-pb on Wednesday October 26, 2022 @03:32AM (#33340823)
Frankly I don't care if the problem gets fixed or not. I've already started a rewrite in Rust, and I don't plan on revisiting the Zig version until Zig has hit 1.0.

Coming from a Clojure background I generally agree with Hoare's "One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.", and in that sense Zig should easily be more correct than Rust which is much much much more complex.

The fact that that hasn't happened, with Rust being much more production ready for most of it's life, despite some major backwards compatibility breaking changes, leaves two possible answers for me:

1. The Rust developers are magically better programmers, which I believe to be false.

2. The rust community has a general culture for correctness and QA which the Zig community lacks.

Re:Zig Is Self-Hosted Now, What's Next? by AndyKelley on Wednesday October 26, 2022 @04:36AM (#33341206)
I'd be interested in some constructive feedback on your Zig experience. There's nothing I can do with the claim that Zig users have a culture problem, especially since the "the zig community" does not work on the compiler - it's just me and a handful of other people - and I'm not really able to evaluate the claim about Rust being in a more "production ready" state at a comparable point in its life. To be honest, these two points feel like nothing more than personal insults.

So, putting those aside, if you have any actionable experiences to share, such as other problems you ran into, what went well, what went poorly, what workarounds you tried, other experiences you had that could help inform the direction of the project, then these things would help make Zig shine when you revisit 1.0.

Re:Zig Is Self-Hosted Now, What's Next? by puffoflogic on Wednesday October 26, 2022 @01:57PM (#33347159)
At no point did a public release of rust miscompile `if (false)`. That alone justifies and proves correct the point that rust was more production ready, not only at a comparable point in its development but at all points in its development.

But you knew this already and are once again telling lies on the internet to defraud developers of their time. It's no wonder zig bugs go years without fixes since you spend all your time patrolling the internet for negative mentions of zig.

Re:Zig Is Self-Hosted Now, What's Next? by AndyKelley on Wednesday October 26, 2022 @05:27PM (#33349729)
I don't know how your HN account isn't banned yet. You keep showing up in every Zig thread, saying provably false things, and calling me names. Half your HN comments are [flagged][dead] for name calling.
Re:Zig Is Self-Hosted Now, What's Next? by ksec on Wednesday October 26, 2022 @08:41AM (#33342779)
Am I missing something here?

You are comparing a language which hit 1.0 and had seven years of additional refinement, to a language which is still at least 2-3 years away from 1.0 and spent most if not all its time in the past 12 months on self hosting compiler?

Re:Zig Is Self-Hosted Now, What's Next? by j-pb on Wednesday October 26, 2022 @11:30AM (#33345238)
> Am I missing something here?

Yes. I'm comparing the stability of very early Rust e.g. 0.x, to the stability of Zig now. Not Rust 1.6 with Zig 0.x.

Re:Zig Is Self-Hosted Now, What's Next? by pmarreck on Tuesday October 25, 2022 @09:44PM (#33338692)
> and then busting out the hardcore QA

This thinking seems... backward (or at least overall counterproductive/like more work) to me. Do you not have a test suite? At least, unit tests for core language features? It seems (with all due respect) a bit irresponsible not to have this, it would at least prevent most regressions in tested code for example (such as breaking "for" loops, as someone else mentioned)

Re:Zig Is Self-Hosted Now, What's Next? by kristoff_it on Tuesday October 25, 2022 @10:31PM (#33339055)
Zig has thousands of tests, but the problem space of a programming language is pretty big, making fuzzing and other similar techniques worth the effort in the long run. The discussion wasn't about the existence of basic unit tests.

https://github.com/ziglang/zig/tree/master/test

Re:Zig Is Self-Hosted Now, What's Next? by pmarreck on Wednesday October 26, 2022 @02:02PM (#33347213)
I also possibly misinterpreted someone else's comment about "for" breaking, assuming it was a regression instead of an intended syntax change which might have been covered by units. My bad