Hacker News new | ask | show | jobs
by abhishekjha 1093 days ago
All you need is a mumrmur hash function to create a hash table. That is something that people should copy.
1 comments

This (a hash table) is a basic vocabulary type, and it's only barely understandable that C doesn't provide one given when it was invented. The hash table which people are likely to knock together this way in C isn't very good, which makes sense - but if the C library provided one then the effort to do it well only needs to happen once.

This isn't like say, Bloom filters where most people don't need one. It's like sort, which I notice C does provide in its standard library.

It's not technically C stdlib, but POSIX.1 is the next best thing:

https://linux.die.net/man/3/hcreate

That said, the implementation leaves a lot to be desired.

> but if the C library provided one then the effort to do it well only needs to happen once.

It would've happened only once, but in 1987, and then we would've stuck with it, because every body relies on the exact behavior.

Just look at `rand()`, it's basically unusable.

> Just look at `rand()`, it's basically unusable.

It does have some limitations you must be aware of, but "unusable"?