News for hackers. Stuff that matters.
Re:Game Jam 2 Results by TakeBlaster16 on Friday September 09, 2022 @09:51AM (#32779221)
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

Re:Game Jam 2 Results by AndyKelley on Friday September 09, 2022 @04:37PM (#32784614)
You'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/

Re:Game Jam 2 Results by TakeBlaster16 on Friday September 09, 2022 @08:56PM (#32786631)
Nice 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

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!

Re:Game Jam 2 Results by nicoburns on Friday September 09, 2022 @09:52AM (#32779239)
There's actually already a patch for this posted on the github issue. It's only about a 5 line change.
Re:Game Jam 2 Results by TakeBlaster16 on Friday September 09, 2022 @10:12AM (#32779485)
The 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.
Re:Game Jam 2 Results by fuu_dev on Friday September 09, 2022 @03:24PM (#32783727)
It 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

Re:Game Jam 2 Results by refulgentis on Friday September 09, 2022 @12:54PM (#32781743)
You should also consider that optimizing for incorrectness and prototyping speed might not be the professionally responsible choice in 2022.
Re:Game Jam 2 Results by alpaca128 on Friday September 09, 2022 @02:08PM (#32782835)
Unused 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.

Re:Game Jam 2 Results by TakeBlaster16 on Friday September 09, 2022 @02:17PM (#32782946)
"Optimizing for incorrectness" is a funny way to describe the practice of enforcing lint checks as part of a CI pipeline.
Re:Game Jam 2 Results by refulgentis on Friday September 09, 2022 @02:21PM (#32782991)
You'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.
Re:Game Jam 2 Results by suby on Friday September 09, 2022 @03:32PM (#32783831)
I also misinterpreted the comment. Either way, I don't see the harm in optimizing for prototyping speed. It's orthogonal to the safety issues.