4 ms·
Yes in Go I think I’m mostly tempted to reinvent the wheel every few lines of code, for the sheer lack of stdlib abstractions I’ve grown used to.
by jmaker 3y ago
Yes in Go I think I’m mostly tempted to reinvent the wheel every few lines of code, for the sheer lack of stdlib abstractions I’ve grown used to.
- IggleSniggle 3y agoThis is funny to me, because Go is often touted as a language that has "everything you need" in the stdlib. Of course, I'm coming from the nodejs world, where before you can start working you first need to evaluate and choose: typescript or not typescript and if yes what build tool chain, which test runner, which assertion lib, which mocking lib, etc etc. Not really that long ago when you had to choose which async lib (now you just need to choose which async color). Thankfully a lot of that stuff is in nodejs now, and there's a commitment to maintain parity with Web APIs which also helps, but there's still a lot of half-done work and path-dependencies on outside libs.
- vitus 3y ago> This is funny to me, because Go is often touted as a language that has "everything you need" in the stdlib. My usual example of something missing from the standard library is func max(a, b int) int { if a > b { return a } else { return b } } math.Max only operates on two float64s (due to the absence of function overloads; many standard library functions such as this predated generics), so if you want to avoid casting (and/or potential loss of precision if you're working with int64), you need to reinvent the wheel.
- pyth0 3y agoGo has had generic forms of the `min` and `max` functions as builtins since 1.21. https://pkg.go.dev/builtin#max https://pkg.go.dev/builtin#max
- j1elo 3y agoGo 1.21 is the version from which it is noticeable that they are pushing towards (re)implementing things that were lacking before due to missing support for generics. Like the new slices package, meant to do common operations on slices, that is brand new on 1.21. I wouldn't be surprised to see more and more new additions leveraging generics in next releases.
- vitus 3y agoGood to know! I admittedly haven't written much Go in the past year, and while min / max were some of the most egregious examples, I'm sure there are plenty more that still exist.
- prosqlinjector 3y agoYou actually don't need any of that stuff, you can just write .js files and run them in node. The node.js standard library is quite extensive.
- IggleSniggle 3y agoIt's much much better now, especially if you are willing to adopt the experimental modules.