News for hackers. Stuff that matters.
Re:Crimes with Go Generics by CraigJPerry on Monday April 25, 2022 @04:21AM (#31151801)
Crimes with Go Generics really is the perfect title for this article.

I chuckled at the juxtaposition of the “expressivity and clarity” comment:

>> you can create composite types (types out of types). This lets you get a lot of expressivity and clarity about how you use Go

Followed by long winded code:

>> However, we can make this a lot more complicated with the power of the Thunk[T] type

And confusion:

>> Why is this so much slower?

This article touches on a lot of the frustration i see with abuse of static typing.

You’re going to write more code and take longer to write it and longer to change it (read: you’re going to cost me more money to build and maintain this code), for the unproven claim that you’ll write less bugs.

The author then goes on to write a logic bug in their memoization code.

But only after they’ve created a generic MPMC queue type by taking an already generic MPMC queue type (a go channel) then writing logic that breaks it (can’t handle an empty queue state) which they code their way out of by throwing more code i have to own.

Re:Crimes with Go Generics by mopierotti on Monday April 25, 2022 @08:56AM (#31153784)
I'm not sure if you're talking about static typing in Go specifically, but imho static typing and generics make code easier to change.

I dread refactoring code that hasn't made extensive use of types, because it makes it harder to know if you've missed anything conceptually (typing reduces the potential behaviors of a piece of code) or literally (e.g. forgot to update a class).

Re:Crimes with Go Generics by CraigJPerry on Monday April 25, 2022 @10:46AM (#31155608)
We’re replying to an article where the author also claimed that but then encountered a bug only in their generic version.
Re:Crimes with Go Generics by dolmen on Monday April 25, 2022 @09:38AM (#31154467)
About "Why is this so much slower?" this article is a must-read:

https://planetscale.com/blog/generics-can-make-your-go-code-...