Live data from Hacker News

Go 1.21 Release Candidate

go.dev

31–40 of 236 posts

Re: Go 1.21 Release Candidate

#31

Nice, my push for actually using the sha256 instructions on amd64 finally got released. 3x-4x increase in hash speed on most x86 which is really nice for content addressable storage use cases like handling container images.

Huh, that is interesting how they do that. They are enabling SHA instruction support based on CPUID and without respect to the value of GOAMD64. I did not realize Go was doing that.

Re: Go 1.21 Release Candidate

#32
post #12

I enjoy Go so much. It is almost perfect language for getting things done, but I still can't understand some design choices. Does someone knows why Go uses env variables (like GOOS and GOARCH) instead command line arguments?

I guess so you can configure them on e.g. a build server instead of tweak your build command, but then, neither is particularly portable.

Re: Go 1.21 Release Candidate

#33
Wait is this now heap allocating a value in every iteration of every loop? I hope that allocation is optimized out in every case where there isn't a closure over the loop variable?

Re: Go 1.21 Release Candidate

#34

Nice, my push for actually using the sha256 instructions on amd64 finally got released. 3x-4x increase in hash speed on most x86 which is really nice for content addressable storage use cases like handling container images.

Got a link to the PR? Curious to see how this is implemented.

It looks like https://go-review.googlesource.com/c/go/+/408795

Re: Go 1.21 Release Candidate

#35

[flagged]

What big thing are you expecting? Go is more of a stable language, a reliable and boring language for building software now that in ten years you can still maintain. Go isn't peaking, Go isn't an exciting or cool or hype language, it's just... there. And that's just fine.

Too many languages just started borrowing features from others, saying "yes" to every suggestion, until they got out of control and all over the place. Go says "no" more often than not. Which isn't always a good thing, mind; generics took a long time because they wanted to understand the problem and not add more like what happened to Java. The builtin min/max features up until this release only supported float64. Lots of small annoyances like that.

Re: Go 1.21 Release Candidate

#36
post #12

I enjoy Go so much. It is almost perfect language for getting things done, but I still can't understand some design choices. Does someone knows why Go uses env variables (like GOOS and GOARCH) instead command line arguments?

It could make it easier for build systems to be multi platform. You don’t have to keep track of custom args and add them to every call, you can just set the environment once.

Re: Go 1.21 Release Candidate

#38
post #18

It is interesting to see them add things like the "clear" function for maps and slices after suggesting to simply loop and delete each key one at a time for so long. Is this a result of the generics work that makes implementation easier vs. the extra work of making a new "magic" function (like "make", etc.)?

That `clear` on a slice sets all values to their type's zero value is going to be extremely confusing especially coming from other languages (Rust, C#, C++, Java, ...) where the same-named function is used on list-ish types to set their length to zero. Doubly-so when `clear` on a map actually seems to follow the convention of removing all contained elements.

Sure, although as a Go user, the behavior described is exactly what I’d expect. These new functions are no different from functions that you could write yourself.

Re: Go 1.21 Release Candidate

#39
post #21

Seems like a really substantial release to me. The new built in functions min, max, and clear are a bit surprising, even having followed the discussions around them. The perf improvements seem pretty great, I’m sure those will get much love here. Personally, I’m most excited about log/slog and the experimental fix to loop variable shadowing. I’ve never worked in a language with a sane logging ecosystem, so I think sl…

Am I reading it correctly that `clear` does different things for maps and slices? Why doesn't it remove all the items from the slice like it does with the map, or set the values in the map to the zero value like it does for slices? That seems like an easy thing to get tripped up on

You can't "remove all items from the slice"; you can only change the length to 0: "slice[:0]".

Re: Go 1.21 Release Candidate

#40
I'm a bit surprised that the slog package was added to the stdlib, but it does seem to use the API that I think is the most ergonomic across libraries I saw in Go (specifically, varargs for key values, and the ability to create subloggers using .With), so I guess it's nice most of the community will standardize around it.

If all goes well, you won't have different libraries using different loggers anymore, in some not too distant future, which should improve easy composability.

Post reply on HN