News for hackers. Stuff that matters.
Re:The Zen of Go by toolz on Sunday February 23, 2020 @09:01AM (#22396846)
Making a strong conflicting statement without even attempting to justify it feels very much like cargo culting.

I personally would want a warning but I believe computers should do what we want them to rather than we should do what they want us to.

Re:The Zen of Go by pishpash on Sunday February 23, 2020 @09:08AM (#22396871)
It's not the computer wanting you to do this, it's the collective arrogance and pedantry of Google designers wanting you to do this. Therein lies the rub. When the compiler detects the unused variable, it doesn't warn you, nor does it remove the variable as it knows exactly how, but one-ups you to force your hand.

You see, even if this is the right choice, the way it's carried out is douchey, and so I perfectly understand somebody calling it garbage to express a sentiment.

Re:The Zen of Go by makapuf on Sunday February 23, 2020 @05:57PM (#22400144)
You cannot remove an unused variable, you just dont refer to a stack place or register with it. Removing a variable would modify your source code. The compiler can only make you do it by pretending it refuses to understand it.
Re:The Zen of Go by sagichmal on Sunday February 23, 2020 @09:10AM (#22396878)
I want my programming language compiler (my computer) to prevent my colleagues from leaving unused variables in their programs.
Re:The Zen of Go by ofrzeta on Sunday February 23, 2020 @09:17AM (#22396909)
Why does it have to be the compiler? The thing about unused variables seems quite arbitrary to me. There are also other things the Go compiler doesn't enforce.

Why not pick a tool that's specialized for stuff like that, like a style checker. Put it into the build pipeline and let the build fail if the code doesn't adhere to your standards.

Re:The Zen of Go by sagichmal on Sunday February 23, 2020 @09:37AM (#22396996)
Because I don't want unused variables to be something other people can opt-in to. I want all source code to be free of unused variables always.
Re:The Zen of Go by masklinn on Sunday February 23, 2020 @04:49PM (#22399776)
> There are also other things the Go compiler doesn't enforce.

Importantly, there are a number of almost certain bugs the Go compiler is happy to let through without even a warning.

Like not rebinding the result of append(), or not checking the error returned by a function.

Re:The Zen of Go by pishpash on Sunday February 23, 2020 @09:13AM (#22396893)
Or you can use social skills to talk to your colleagues instead of using Go compiler as some sort of passive-aggressive bludgeon.
Re:The Zen of Go by edflsafoiewq on Sunday February 23, 2020 @11:35AM (#22397738)
If I look at languages where unused variables are a compiler warning, I don't see people leaving unused variables in their programs.