this post was submitted on 14 Aug 2023
1393 points (97.9% liked)

Programmer Humor

19187 readers
1135 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] DarkDarkHouse@lemmy.sdf.org 192 points 1 year ago (4 children)

As your future colleague wondering what the hell that variable is for, thanks Go.

[–] Willem@kutsuya.dev 68 points 1 year ago

I prefer for it to be just a warning so I can debug without trouble, the build system will just prevent me from completing the pull request with it (and any other warning).

[–] iforgotmyinstance@lemmy.world 42 points 1 year ago

Changing it will bring down the entire system.

We've spent ten million dollars and do not know why.

[–] Nioxic@lemmy.world 26 points 1 year ago (1 children)

Isnt the syntax highlighting it as mever used?

So why would they wonder?

[–] Camilo@discuss.tchncs.de -2 points 1 year ago

If it is a pure value, I'd assume yes, but if it is tied to a side effect (E.g. write its value to a file), then it would be not used but still could break your app if removed.

I'm not familiar with rust language specifically, but generally that's what could happen

[–] MJBrune@beehaw.org 25 points 1 year ago (3 children)

A quick "find all references" will point out it's not used and can be deleted if it accidentally gets checked in but ideally, you have systems in place to not let it get checked into the main branch in the first place.

[–] Flarp@kbin.social 27 points 1 year ago

Yeah that should be looked for in a CI line check, not a compilation requirement

[–] aport@programming.dev 9 points 1 year ago (1 children)

You mean a system like the compiler

[–] MJBrune@beehaw.org 14 points 1 year ago* (last edited 1 year ago) (1 children)

Or a linter. Or code reviews. Or anything else. The nice thing is that if the compiler doesn't demand something, it can be given to the engineer as an option. The compiler should have the option to do it. The option could even be defaulted on. Afaik there is no way in Golang to disable that error (this is the line that does it: https://github.com/golang/go/blob/04fb929a5b7991ed0945d05ab8015c1721958d82/src/go/types/stmt.go#L67-L69). like --no-pedantics or such. Golang's compiler openly refuses to give engineers more choices in what they think is the best system to handle it.

[–] aport@programming.dev -5 points 1 year ago (1 children)

Who needs an option to leave unused variables around the code base? Lazybones?

[–] MJBrune@beehaw.org 5 points 1 year ago

You've literally never commented out a line or two but left the variable declaration while debugging?

[–] anemoia_one@lemmynsfw.com 5 points 1 year ago* (last edited 1 year ago)

Yeah any compiler should support environments or config files. Our CI would never work with without --env “stage”