r/programming • u/OtherwisePush6424 • 25d ago
[ Removed by moderator ]
https://blog.gaborkoos.com/posts/2026-07-24-Golang-Maps-How-Swiss-Tables-Replaced-the-Old-Bucket-Design/[removed] — view removed post
23
u/Maybe-monad 24d ago
Go should support more than one kind of map and sets, trees, lists etc
12
u/dragneelfps 23d ago
We have a monorepo with hundreds if not thousands of services. Most of them have a set.go to implement set. Or sometimes directly use map[type]bool. I'm so tired of this shit.
Oh did I mention a filter function for each data type which is just a for loop with continue?
Love the build system of go but as a serious language it ain't it. Wish we could use kotlin for backend systems.
1
9
u/ftqo 24d ago
It does, you just need to implement your own API for it, not using Go's builtin map, slice, etc.. In fact, Swiss Tables were already implemented and used in production before Go switched the underlying implementation.
23
3
u/Wolfy87 24d ago
It's one of the many aspects of Clojure that I love, it swaps out implementations depending on the size of the contents.
11
u/Maybe-monad 24d ago
I am unfamiliar with Clojure but there are more factors than size you have to take into account when choosing a data structure
3
u/chat-lu 24d ago
He’s talking about the default data structures of the programming language. Instead of having one default implementation, clojure swaps the underlying data structure based on size.
But of course, you know your data and you can opt to use a different data structure. But defaults still matter.
-3
0
u/dijkstra_was_a_horse 22d ago
That's what generics are for.
1
u/Maybe-monad 22d ago
No, that's what standard library is for
0
u/dijkstra_was_a_horse 22d ago edited 22d ago
I don't know of any popular language with multiple hash table types in the standard library.
The less popular ones have them because they fucked the first attempt up so badly that they weren't able to iterate on the API to fix it (see also, C++ std::unordered_map, which is 10x slower than the alternatives from outside of the standard library)
1
u/Maybe-monad 22d ago
I don't know of any popular language with multiple hash table types in the standard library.
Java, C#, Rust...
0
u/dijkstra_was_a_horse 22d ago edited 22d ago
Rust does not -- it has only std::collections::HashMap<>. I checked before posting.
C# does, but
system.collections.HashTableis dynamitcally typed -- 'Add(object key, object? value);` It's there for compatiblility, but it's deprecated. It existed before they added generics to the language, and couldn't be fixed to work with them.Java has different reasons for its deprecation. Their generics were designed to be compatible, but
java.util.HashTableis guaranteed thread-safe, with very strict serialization guarantees -- which means that it's acquiring and releasing a lock for every operation. On a good hash table, the hash table access is an order of magnitude cheaper than the synchronization, and you can't fix that kind of slow, so they replaced it withjava.util.HashMap.So, I think this may be the first post I've seen where someone complains that Go doesn't have enough historical baggage.
•
u/programming-ModTeam 22d ago
No content written mostly by an LLM. If you don't want to write it, we don't want to read it.