3 ms·
Sometimes I wonder why these nifty data structures that someone already implemented in c++ don't immediately (or even 5+ years later) have ports to other langua
by mkoubaa 4y ago
Sometimes I wonder why these nifty data structures that someone already implemented in c++ don't immediately (or even 5+ years later) have ports to other languages. Especially languages that are closer to the metal than average (e.g. Rust, Go, ...)
- deleted 4y ago[deleted]
- tialaramex 4y agoWhat sort of languages are you thinking of which are "closer to the metal" than C++ but support the features you'd want for these structures ? The closest I can think of is Rust, but it does have ports of such things. Rust's HashMap is a Swiss Table - Abseil's flash_hash_map but ported to Rust (via HashBrown), Haphazard is a Rust port of the Folly library's hazard pointers (which might some day be C++ 26 or C++ 29 Hazard Pointers)
- sgerenser 4y agoperhaps mkoubba meant “closer to the metal” than the average programming language, like, say Swift or even C#, not “closer to the metal” than C++. Otherwise it the comment makes little sense, as I would not even consider Rust “closer to the metal” than C++. Maybe C or x86 Assembly?
- mkoubaa 4y agoYes precisely. Closer than the average
- uluyol 4y agoThere are different semantics for these data structures in different languages. These tend to exist for corner cases, but those corner cases constrain your design. So you might not be able to replace the default Java hashmap with absl::flat_hash_map, but you can steal ideas and maybe do better in other ways where the C++ map would be constrained. However, doing that is work that someone has to pick up. And releasing a (e.g.) Go library that breaks from the built in map semantics might not see much adoption in that community. C++ actually seems a bit unique in terms of how many widely used implementations there are of key data structures (e.g. strings, maps, trees, inline vectors). Not criticizing just making an observation.
- mkoubaa 4y agoThis is a really good point. C++ developers seem to be more opinionated than other communities about data structure semantics in my experience. Possibly because the language chose the wrong semantics for the original standard library, whereas other languages made more sensible choices
- aaronbee 4y agoThere are some folks working on porting SwissTable to Go: https://github.com/golang/go/issues/54766 https://github.com/golang/go/issues/54766 What’s holding it back currently is coming up with a way to do incremental rehash, which Go’s current map provides.
- rurban 4y agoSince the swisstable is available in C++ and C, everybody can trivially use it. I'm more concerned about missing security policies. Like collision counting.