• HiddenLayer5@lemmy.ml
    link
    fedilink
    English
    arrow-up
    76
    arrow-down
    2
    ·
    edit-2
    1 year ago

    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.

    • space_comrade [he/him]@hexbear.net
      link
      fedilink
      English
      arrow-up
      17
      ·
      1 year ago

      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.

      • Sloogs@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        8
        ·
        edit-2
        1 year ago

        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.

        • skeletorsass [she/her]@hexbear.net
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          Too many patterns. If you do not do this every author will have a different use of the language and you will have to read a book of documentation each time you change files.

    • philm@programming.dev
      link
      fedilink
      arrow-up
      17
      ·
      1 year ago

      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?

      • flame3244@lemmy.world
        link
        fedilink
        arrow-up
        27
        ·
        1 year ago

        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.

        • nomadjoanne@lemmy.world
          link
          fedilink
          arrow-up
          6
          ·
          1 year ago

          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.

          • flame3244@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 year 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.

        • AstridWipenaugh@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          1 year ago

          The underscore is used in production code too. It’s a legitimate way to tell the compiler to discard the object because you don’t intend to use the pointer/value.

      • HiddenLayer5@lemmy.ml
        link
        fedilink
        English
        arrow-up
        12
        ·
        edit-2
        1 year ago

        Never really coded in Go outside of trying it out, but as far as I know it’s a hard error.

    • flame3244@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      I think this is a good thing. The styles are just opinions anyway and forcing everyone to just follow a single style takes a lot of bikeshedding away, which I really like.