5 ms·
That's the one thing keeping me from considering Zig for new projects right now. If some enterprising young developer is reading this and wants to make a name
by TakeBlaster16 4y ago
That's the one thing keeping me from considering Zig for new projects right now.
If some enterprising young developer is reading this and wants to make a name for themselves, you should fork the Zig compiler and change those errors to warnings. It would be an extremely popular project.
EDIT: I'll even give you a catchy project name. Wig: Zig with Warnings
- nicoburns 4y agoThere's actually already a patch for this posted on the github issue. It's only about a 5 line change.
- TakeBlaster16 4y agoThe patch works, but it's not efficient to have every user patch their own compiler on every release (and forgo the system package manager for upgrades). I was also envisioning adding a warning system, changing the checks to warnings instead of removing them completely, and adding a `-Werror` flag (or maybe `-Wno-error`). It would be a bit more than 5 lines, but still relatively low effort compared to how impactful the project would be.
- fuu_dev 4y agoIt might be good to add a respectful comment on the issue on github to emphasize the UX issues it creates. issue: https://github.com/ziglang/zig/issues/335 https://github.com/ziglang/zig/issues/335
- refulgentis 4y agoYou should also consider that optimizing for incorrectness and prototyping speed might not be the professionally responsible choice in 2022.
- alpaca128 4y agoUnused variables don't make a program incorrect. When you comment out unused variables to prevent Zig's compiler error you don't remove the dead code, you in fact make it more likely to stay in the codebase because now it's only visible to humans. While almost every other language will print out a clearly visible warning without disrupting the workflow. I can only see downsides and no upside in this design. Why would you slow down the development workflow for something any decent compiler will discard as basic optimization step? It's an error about something that has absolutely no impact on the resulting program and its execution, you can probably find a dozen better reasons for Zig to throw errors where it doesn't.
- TakeBlaster16 4y ago"Optimizing for incorrectness" is a funny way to describe the practice of enforcing lint checks as part of a CI pipeline.
- refulgentis 4y agoYou're right, the provocation here is engaging in intentionally choosing a language, and choosing Zig, is optimizing for incorrectness. I didn't mean the flag.
- suby 4y agoI also misinterpreted the comment. Either way, I don't see the harm in optimizing for prototyping speed. It's orthogonal to the safety issues.
- AndyKelley 4y agoYou're not alone. Fridays are my live streaming day and I've chosen today's topic to be the user experience of unused variable errors. I have an idea to solve this that can satisfy both parties - those who don't want to be bothered by such errors, and those who want the premise upheld that if Zig code compiles, it does not have any unused variables. In approximately 60 minutes I'll go live on https://www.twitch.tv/andrewrok/ https://www.twitch.tv/andrewrok/
- TakeBlaster16 4y agoNice to see you here. I'm not much of a twitch guy, but I'm glad this is on your radar and I'll read about it afterwards! If you're talking about the `zig fmt` idea, I'd like to draw your attention to a possible pitfall -- Silencing the errors with _ increases the risk that unused vars will be committed to the repo. https://news.ycombinator.com/item?id=32753079 https://news.ycombinator.com/item?id=32753079 I normally add the equivalent of `-Werror` to pre-commit and CI. But if those warnings are silenced directly in the source code, I can no longer rely on the compiler's guidance to clean up the code, and I would have to hope I could remember all the places I need to clean up before committing. In that way, solving this in the formatter could have the opposite effect on code quality than you intended. I _do_ want the compiler to yell at me... just not yet. Only when it comes time to commit. Overall I've been impressed reading about Zig's design. You clearly have good engineering taste and I respect you challenging the status quo and trying unconventional ideas, even if I may disagree from time to time. I'm itching to start using the language once this is solved!