you are viewing a single comment's thread
view the rest of the comments
[–] 83 points 3 years ago* (last edited 3 years ago) (3 children)

Sometimes I think Go was specifically made for Google to dictate its own preferences on the rest of us like some kind of power play. It enforces one single style of programming too much.

  • source
  • hideshow 6 child comments
  • [–] 20 points 3 years ago (2 children)

    From what I've heard from Google employees Google is really stringent with their coding standards and they usually limit what you can do with the language. Like for C++ they don't even use half the fancy features C++ offers you because it's hard to reason about them.

    I guess that policy makes sense but I feel like it takes out all the fun out of the job.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 9 points 3 years ago* (1 child)

    Just about any place I know that uses C++ also does that with C++ so that's nothing unusual for C++ specifically. It's too big of a language to reason about very well if you don't, so you've gotta find a subset that works.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 18 points 3 years ago (2 children)

    Is this a hard error? Like it doesn't compile at all?

    Isn't there something like #[allow(unused)] in Rust you can put over the declaration?

  • source
  • parent
  • hideshow 4 child comments
  • [–] 27 points 3 years ago (3 children)

    Yes it is a hard error and Go does not compile then. You can do _ = foobar to fake variable usage. I think this is okay for testing purposes.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 29 points 3 years ago (1 child)

    I think that's even worse because it increases the likelihood you'll forget you faked that variable just for testing

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 3 years ago (1 child)

    Worse than not having a unused variable check at all? Dunno, the underscore assignment are very visible for me and stand out on every code read and review.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 3 years ago* (1 child)

    Yes, worse, because now if you want to use the underscore assignment to indicate that you really want to discard that variable - it gets confused with underscore assignments that were put there "temporarily" for experimentation purpose.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 9 points 3 years ago

    Exactly.

    Say I'm having some issue with a function. I comment out half the function to see if that's where the weirdness is. Golang says "unused variable, I refuse to compile this dogshit!" I completely fool Golang by just using _ = foo. Yes, I was correct, that's where the problem was. I rewrite that section of the code, and test it out, things work perfectly. Only now, it turns out I'm not using foo anymore, and Golang has no idea because I so cleverly fooled it with _ = foo.

    Now, something that could be caught by a linter and expressed as a warning is missed by the language police entirely, and may make it into production code.

    Police the code that people put into a repository / share with others. Don't police the code that people just want to test on their own.

  • source
  • parent
  • [–] 8 points 3 years ago (2 children)

    Ew, that's awful. Go is not one of my programming languages but I had always held it in high esteem because Ken Thompson and Rob Pike were involved in it.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 3 years ago

    Honestly, it does not happen often that I have a ln unused variable that I want to keep. In my mind it is the same thing when wanting to call a function that does not exists. Also my editor is highlighting error Long before I try to compile, so this is fine too for me.

  • source
  • parent