News for hackers. Stuff that matters.
Re:Why databases use ordered indexes but programming uses ha... by crazygringo on Monday December 09, 2019 @10:31PM (#21749348)
I've always thought b-trees should be the starting "default" for everything, because their speed is far more consistent, you get extra features, and you don't have to make decisions in advance about allocating extra memory or worry whether the keys aren't well-distributed enough that you'll get horrible collisions. And how often do the extra few lookups for a tree materially affect the speed of your software?

Hash tables to me aren't a go-to -- they're an optimization I reach for only when I have a real performance reason where I have to use them, and my data is highly predictable so I have confidence how to set them up. But honestly, that just doesn't happen that often. I swear, I think I've used Bloom filters more often than hash tables in my life.

Re:Why databases use ordered indexes but programming uses ha... by garmaine on Tuesday December 10, 2019 @12:27AM (#21749841)
I suspect the author of this language and/or his audience has done most of their work in dynamic languages where "associative lookup data structure" means a hash table.
Re:Why databases use ordered indexes but programming uses ha... by dajohnson89 on Monday December 09, 2019 @11:23PM (#21749565)
of the data structures you mentioned, which are easier to work with? to implement? I code in Java and I usually use hashmaps as a go to. they're simple and fast ways to store relationships between data.
Re:Why databases use ordered indexes but programming uses ha... by garmaine on Tuesday December 10, 2019 @12:28AM (#21749845)
std::map in C++ is way easier to work with than std::unordered_map (which didn't even exist until C++11).
Re:Why databases use ordered indexes but programming uses ha... by yuushi on Tuesday December 10, 2019 @01:31AM (#21750202)
Define "way easier". The interface, at least for day to day operations, is basically identical.
Re:Why databases use ordered indexes but programming uses ha... by garmaine on Tuesday December 10, 2019 @05:19AM (#21751237)
Supports more features like ordered traversal, generally faster in most cases (yup!), consistent api cost, doesn’t invalidate iterators on certain operations like moving between maps. That’s just off the top of my head.