News for hackers. Stuff that matters.
Re:The Janet Language by injidup on Saturday February 18, 2023 @07:57AM (#34846563)
Sets and maps do not required hashing. Specifically std::map and std::set in the C++ standard library are based on ordered trees.
Re:The Janet Language by jb1991 on Saturday February 18, 2023 @08:23AM (#34846755)
They’re often called “hash sets” or “hash maps” in other languages - they are called this for a reason, and certainly not because they could be implemented as a list.

std::map is not a good example anyway, you want to consider std::unordered_map for a more appropriate comparison. C++ is weird that way. (What C++ calls a map is not what most languages call a map. std::map doesn’t even satisfy O(1). You’d be surprised how many working C++ developers don’t even realize the unnecessary performance cost they take when they decide to use std::map, because it’s not a proper hash map. )

But this thread is not about the finer differences in implementation of maps but rather whether or not they are basically just lists. They are not.

Re:The Janet Language by glasshug on Saturday February 18, 2023 @10:55AM (#34847802)
Agree broadly that this thread has gotten too long off what was basically a joke, but!

Please measure before you make changes to your maps for perf reasons. Yeah this forum all knows their big-O, but B-tree maps like std::map often perform better than hash maps on real-world architectures.

Re:The Janet Language by injidup on Saturday February 18, 2023 @01:02PM (#34849226)
You said "requires" hashing. Sets and Maps do not require hashing. Through it is correct to observe the unfortunate naming convention in the c++ std lib.

std::set and std::map should be std::ordered_set and std::ordered_map sts::unordered_set and std::unordered_map should be std::hash_set and std::hash_map

If this were so then it might make the incorrect usage of these two options less prevalent. But they are both map and set structures just each version has other guarantees that in some scenarios may be more or less useful.

Re:The Janet Language by xigoi on Saturday February 18, 2023 @03:09PM (#34850549)
> But they are both map and set structures just each version has other guarantees that in some scenarios may be more or less useful.

And similarly, linked lists and arrays are just different "versions” of the same data structure: a list.

Re:The Janet Language by mirekrusin on Saturday February 18, 2023 @04:24PM (#34851250)
Let's simplify it even more - everything is just ones and zeroes.
Re:The Janet Language by jb1991 on Sunday February 19, 2023 @02:35AM (#34855372)
You interpreted my reply as “all sets and maps require hashing“ instead of “sets and maps are examples of data structures that can require hashing”… which they are.

Imagine someone says, every fruit in the world is sour, and someone answers, no there are plenty of fruits that are sweet, such as apples, and then an entire thread gets launched in an irrelevant direction pointing out that actually some apples are sour. That’s effectively what’s been done here, and it’s a waste of everyone’s time.