by glmdev · 4y ago · 0 comments
It's all well and good to generalize basic containers and functions (good, in fact), but I wish the language was better at inferring types.
I'm sure this is something that will improve with time, but a bit after generics were released, I tried to build a type-safe language evaluator in Go using generics and found them lacking the kind of type-narrowing necessary for fully-generic architecture.
Short write-up of my conundrum on SO, if anyone is interested: https://stackoverflow.com/questions/71955121/how-to-type-swi...
TypeScript has me spoiled. :)
https://planetscale.com/blog/generics-can-make-your-go-code-...
If you want a sophisticated type system with a language they complied to native code then use Swift or Rust.
I personally think it is good to have some choice in complexity level and that at least one language, Go, tries to carve out a niche in simplicity.
I am only barely convinced that generics was the right choice for Go.