Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> you might want to take a moment to ponder the fact

> Well if one never stops to think about its potential merits

Listing some of those merits may be more productive than insisting people aren't thinking about it hard enough



I don't program in Zig, but I can think of a few reasons in principle:

1. WYSIWIG compiler: how many people have been complaining lately about C compilers eliminating code on them due to undefined behaviour? If you eliminate certain optimizations so your complier doesn't do this, like dead code/variable elimination, then what the code looks like is exactly what executes. This means some important optimizations may have to be done by hand. Eliminating dead variables could be one of them.

2. Arguably dead variables are a mistake. Either they're a (major) mistake because you neglected to include a value in your computation, or a (minor) mistake because you declared a superfluous variable that's never used.

3. If you want your code to be clear and as self-documenting as possible, unused variables are an impediment. I can't speak to the accuracy of Zig's analysis, but I can see how it would be annoying while working out an algorithm.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: