> But most people aren’t coding language features
It's definitely a tough lever, but supporting generics for the people who are means that the people who aren't can write cleaner code. I think go got it right, eventually.
Disallowing someone from using easy statically typed tree maps is not accomplishing any of the simplicity virtues people trumpet Go for having. While the much-warned-of castles of inappropriately applied generics have yet to be found in any codebase I've worked with in any language, including Rust.
Go is optimized for use, not computer science edge cases. And as a result it is widely used, and some of the most complicated and widely-used open-source projects out there are built in it, even before it had generics. For example, Kubernetes.
This is because of Go's simplicity, not in spite of it.
Whose usage are you trying to optimize the language for? Golang is not a good academic language. But it is extremely good for actually solving problems with code.
More compelling ones are sets, ordered maps, a generic sync.Map, optionals (nulls suck!), abstractions over channels - badly needed!
I wouldn't consider any of those to be academic.
> rg BTreeMap monorepo/ --type rust --no-filename | awk NF | wc -l
1656
You may not have ever encountered a use case for a tree map, but there is quite a wide gray area between 'computer science edge cases' and cookie-cutter CRUD apps. For example, deterministic map ordering, or sets for map keys, or fast map equality.Funny that you mention Kubernetes. This is the tree map implementation Kubernetes depends on https://github.com/google/btree
But in the hands of people who love to go bananas, generics can result in hellish code.
My favorite example of a problem where generics is not useful is the OpenSAML implementation (Java). For all I know it may have been sanitized since I tried to make use of it about a decade ago, but that thing was, for lack of a better word, a pointless exercise in type system wankery. It was so bad it took us less time to implement what we needed from scratch than to figure out how to use the library correctly. (The code I wrote a decade ago has been in production, for a decade on a system that is used by ~150-200M users. Not just because it works, but because it can be maintained by people who aren't really that interested in spending weeks understanding it)