37 ms·
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 cr
by CraigJPerry 4y ago
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.
- mopierotti 4y agoI'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).
- CraigJPerry 4y agoWe’re replying to an article where the author also claimed that but then encountered a bug only in their generic version.
- dolmen 4y agoAbout "Why is this so much slower?" this article is a must-read: https://planetscale.com/blog/generics-can-make-your-go-code-slower https://planetscale.com/blog/generics-can-make-your-go-code-...