145 pointsby Hixon105 hours ago16 comments
  • chenxiaolong4 hours ago
    This release also fixes runtime.findnull() to be compatible with MTE on Android ([1] and [2]). This was the only thing preventing MTE from being enabled for apps that use gomobile on MTE-compatible Android OS's like GrapheneOS.

    [1] https://go-review.googlesource.com/c/go/+/749062

    [2] https://go-review.googlesource.com/c/go/+/751020

  • sbstp2 hours ago
    Go's standard library has always been it's strength, especially the crypto package! Lovely stuff.
  • mappu3 hours ago
    Automatically draining http response bodies is a risky silent behaviour change. I think it will be an improvement for most applications, but it's very subtle if you were relying on the old behaviour
    • gigatexal5 minutes ago
      Can you go more into this? I don’t quite follow
  • mayama3 hours ago
    Adding simd in std and even being used in map is nice. Would have to look for places to experiment with it in hot loops in code I have.
  • Hixon105 hours ago
    Some examples for the upcoming release https://go.dev/doc/go1.27
  • nu2ycombinator4 hours ago
    Those Generics syntax in Golang seems so hard to read.
    • theplumber2 hours ago
      It is verbose but inference helps a lot to keep it “tidy”. I always find myself increasing my focus a notch when I start dealing with generics. It’s one of the things I use only if I really “need”.
      • xmprtan hour ago
        One of the reasons it took so long to implement generics in Go was because there was a lot of stuff you could do that didn't need it. Now that generics are there, a lot of that stuff is still the best way to solve the problem and many of the methods that require generics are in the standard library so it's rare that you absolutely need it.
      • bessel-dysfunct2 hours ago
        Yeah, I agree with that.

        Back when Go's generics came out, I was working with about 20% Go and 80% Python. I looked at the syntax, went "not today, Satan" and never bothered to learn it. For the past half year I've been in a mode where most of my coding time is spent with Go and I've been completely indoctrinated. I unironically like thinking about how generics and interfaces interact now.

        I also need to slow down when I need to use them for non-trivial stuff. Not just relative to Go code but relative to how much I needed to think about them back when I was using OCaml. I think part of it is that I save them for hard issues and use interfaces for easy stuff.

  • lilbigdoot4 hours ago
    This level of generics actually has me interested a bit in Go now.
  • pixxxel21 minutes ago
    Let's GO
  • theplumber3 hours ago
    This is quite of a big release and I like the new methods on generics.
  • cat-whisperer20 minutes ago
    does go have enums?
  • drivebyhooting3 hours ago
    Can generics be used to improve error handling and eliminate the if err pattern?
    • jerf3 hours ago
      No.

      I kind of want to leave it there. But that will probably be looked on disfavorably.

      I've seen at least a dozen attempts. It's not like it's hard to write it out. There's maybe a couple of variants but they're all just a handful of lines. The problem is, once you have an Option in hand, you end up trading:

          val, err := whatever(...)
          if err != nil {
              // handle error
          }
          // use val
      
      for

          val := whatever(...)
          if err, isErr := val.Error(); isErr {
              // handle error
          }
          realVal := val.Value()
          // use realVal
      
      What you win in nominal safety, you're definitely losing in convenience.

      There's also no win in trying to offer a monadic interface like

          finalVal := whatever(...).OnVal(func (val Value) opt.Option[Result] {
              // use val
          })
      
      because that's the minimal specification of an anonymous function in Go, so it's very inconvenient. Even if that was trimmed down, nested functions are still problematic in other ways. And you still have to unpack finalVal anyhow.

      Really the solution is, install golangci-lint, turn on errcheck [1], use a pre-commit hook to make it a commit failure if golangci-lint fires, and that pretty much covers the problem in practice.

      One of the problems with Option/Result/etc. advocacy... not the pattern itself, the advocacy... is that it is generally are presented, implicitly or explicitly, as if the alternative is C, with its errno and the need to not just check an error value, but remember to go actively seeking out errors constantly, making it easy to forget. But by modern standards, that's completely pathological.

      If we rate error handling techniques on a scale from 1 to 10 (best), C here is a 1, and standard Option is maybe an 8 or a 9. The way Go does it is maybe a 6; it is completely true that you can neglect to handle an error (see errcheck comment in previous paragraph), but it is in your face that an error is possible, and that's really most of the problem. Putting Option/Result/etc. is not always a "go from 1 to 9" result. "Go from 6 to 8" is a much less impressive proposition, and the other inconveniences that come with it in Go tend to overwhelm the gain. I use errcheck all the time, and even in the Before Times when I was writing it all by hand it really didn't fire all that often. Especially if I exclude test code. In an AI era this hardly rates at all. AI never neglects the error.

      Whether it does the right thing with it, now... that's another story entirely.

      Read those error handling clauses if you're writing Go with AI. I really don't like what I've seen AIs do with them by default. What I've seen out of AI has been very thoughtless. Nominally correct in some weak sense, but thoughtless.

      [1]: https://golangci-lint.run/docs/linters/configuration/#errche...

      • nitrix4 minutes ago
        Error handling is as important as the happy path of an application. It’s not something you sweep under the rug.

        The err != nil quickly turns into metrics, logs, fallback strategies, retry mechanisms, flight recording, rate limiting, updating caches, so on.

        Anyone who’s trying to shorten this hasn’t maintained any actual real software.

      • drivebyhooting2 hours ago
        I think my opinion will be even more maligned: I like Java-style checked exceptions. It forces awareness of the error and a clean way to propagate it.
        • Nursie2 hours ago
          The thing that most annoys me in Java in that area is when a dependency throws an unchecked error that wasn’t even documented.

          Thanks so much for that! Now I have no choice but to be reactive when something fails…

  • kansm2 hours ago
    Tried running a couple of examples in the tour, but ran into a few errors.
    • wredcoll2 hours ago
      Tried reading your comment but ran into a lack of usable information.
    • 2 hours ago
      undefined
  • stingraycharles4 hours ago
    Am I the only one who’s absolutely shocked that Go finally is embracing generics?

    Does anyone have a bit of an inside view into what changed in the perspectives of the language maintainers?

    I’m not buying the “it took us 20 years to understand how to do it correctly” argument, as this is something you explicitly take into consideration when designing the language or not. And it was specifically not a part of language design, and is much harder to retrofit (backwards compatibility).

    So what changed?

    • bradfitz4 hours ago
      (I was on the Go team for ages)

      Seriously, that's all it was. Just Ian alone proposed and rejected a half dozen of his own different approaches to generics. Finally a language + implementation plan came together that people all liked.

      Nobody was ever opposed to generics that I saw.

    • amtamt3 hours ago
      If bug free binary search implementation can take 16 years, I am ready to buy generics implementation could take 20 years.

      > In his landmark book The Art of Computer Programming, legendary computer scientist Donald Knuth noted that although the first binary search algorithm was published by John Mauchly in 1946, the first bug-free version was not published until 1962—taking a staggering 16 years to get right.

      • ckcheng3 hours ago
        Took a few more years to get really bug free.

        > Fast forward to 2006. I was shocked to learn that the binary search program that Bentley proved correct and subsequently tested in Chapter 5 of Programming Pearls contains a bug. ... Lest you think I'm picking on Bentley, let me tell you how I discovered the bug: The version of binary search that I wrote for the JDK contained the same bug. It was reported to Sun recently when it broke someone's program, after lying in wait for nine years or so.

        https://research.google/blog/extra-extra-read-all-about-it-n...

    • fooster4 hours ago
      It’s also not true that because it wasn’t part of the initial design that it was harder to retrofit. I just don’t understand all this go bashing that happens on this site especially when so much is badly informed speculation. I guess it’s easier to tear something down.
    • throw2ih0204 hours ago
      > what changed in the perspectives of the language maintainers?

      The original maintainers moved on to other projects and the new community maintainers came to a consensus through the proposal and governance process.

      • bradfitz4 hours ago
        No, that's not accurate. The same core people were involved.
    • abtinf2 hours ago
      Unfortunately nothing changed. They wanted generics all along.

      The Go ecosystem was a delicate, special thing. It was a wholesale rejection of the malignant consultancy takeover of programming that had festered and spread for the previous 15 years. Introducing generics was a grievous error, and they just keep making it worse.

      It used to be you could look at any Go code from any author and pretty much instantly understand it completely. That’s no longer the case.

      It used to be you would work on a problem, just writing the code from top to bottom. No time wasted fiddling with abstractions you’ll never use. You’d grumble about it, but succumbing to the temptation was impossible. That’s no longer the case.

      • tacitusarc2 hours ago
        I have written Go for the past decade and completely, fundamentally disagree with this take. Go has always had a tendency towards limited exressivity, which created a strong dependence on interface{}, type assertions, and runtime bug’s that should have been compiler errors.

        When I read these grumbling takes about how Go use to be so simple etc I imagine devs who would revel in all the features they were unable to implement because it would be too difficult in the language. Or devs who love typing and re-typing the same code over and over again, littering their code with switch cases and conditional logic while passing themselves on the back for avoiding “abstraction”.

    • whateveracct3 hours ago
      and they're still worse than the 1970s state of the art lol
  • fang2hou3 hours ago
    [dead]
  • okzgn3 hours ago
    [dead]
  • nothrows2 hours ago
    generics were a slippery slope. give it a decade and Go will be indistinguishable from c++
    • EdiXan hour ago
      Generics themselves maybe not. Generic methods probably yes. What people want generic methods for is to do deeply nested call chains that were never typical of Go. And if you have deeply nested calls you'll need some way to deal with errors in deeply nested calls, and then a short function syntax to pass to behavior inside those deeply nested calls. Give it a few years and everyone will be writing the same functional slop in Go that they are writing in every other language.
    • nirui2 hours ago
      Not here against Generic methods, but I feel the Go team is in a mid-age crisis where they lack of new things to do to prove themselves. See their iterators mini-drama not long ago?

      I feel the sumtype/emum/routine demanders should yell a little harder so Go team can find their purpose again.

    • cookiengineer2 hours ago
      > generics were a slippery slope. give it a decade and Go will be indistinguishable from c++

      Lib boost will have conquered every language by then!!! :D

      Jokes aside, generics are unusable in a lot of languages due to their syntax choices. In Go we kinda have the problem that there's no real templating and no real macros, so they're even harder to use.

      But I agree somewhat, generics feels to me like an anti pattern in Go.

      Also, the way the Go core/stdlib is written, it makes generics so unnecessarily painful to debug. Why they decided to have definitions like "~C" or "~[]S" is beyond me. No human knows what the resulting compile time error means. They should have named these things "Comparable" or "Slicable" or whatever is more expressive. Just stop with this stupid single letter shit.