I've heard of two possibilities (as a recommendation) for using data structures in C without having to develop them: - BSD queue.h offers linked lists, queues, etc [1]. - UT-hash offers hash tables [2]. I've also read some people being frustrated with them, probably due to the quirky syntax/API. On the plus side (BSD at least) it's just a header file that you can download, include and start using. [1] http://bxr.su/O…
Write a hash table in C
51–58 of 58 posts
Re: Write a hash table in C
#52Earlier quoted context omitted.
A standards process is frequently about documenting what already exists in common implementations so that there is a specification for future implementations. POSIX was very much one of these processes.
OK... so how did junk like this ever get into enough implementations that people were forced to include it in the standard? ;)
Why not have these anyway? Otherwise people will make their own (probably buggy) equivalents.
I'm actually surprised that people aren't aware of them.
Re: Write a hash table in C
#53While the reasons for this that the author gave are valid, I think it would also be valuable to do this in a high level language. I'm sure lot of people who can read C code went through a CS program, and hopefully learned how hash tables work then. People without CS degrees and who mostly write JS/Ruby/Python/etc. and use hash tables on almost every line of code they write are much less likely to know how they work.…
Re: Write a hash table in C
#54I've heard of two possibilities (as a recommendation) for using data structures in C without having to develop them: - BSD queue.h offers linked lists, queues, etc [1]. - UT-hash offers hash tables [2]. I've also read some people being frustrated with them, probably due to the quirky syntax/API. On the plus side (BSD at least) it's just a header file that you can download, include and start using. [1] http://bxr.su/O…
Re: Write a hash table in C
#55Earlier quoted context omitted.
> There's room for both. Sure. I'm all for learning ML, Scheme, C/C++, Python, Ruby, Java/C#, etc. > There's a reason why a lot of CS programs have shuffled from primarily C to Python (some had Java in between). The reason is called dumbing down the curriculum. My fall freshman year, my college tried to switch from C to Java in order to make it easier for the general population to get into CS and there was a major pu…
The dumbing down of the curriculum so that music/english majors can pass CS classes doesn't do anyone any favors. You sound butt-hurt
Re: Write a hash table in C
#56Earlier quoted context omitted.
There's room for both. There's a reason why a lot of CS programs have shuffled from primarily C to Python (some had Java in between). Not having to deal with boilerplate and housekeeping lets you focus on learning the topic at hand. Especially in a classroom setting where you're probably focusing on the specific subject instead of real-world dirtiness. But after learning the basic concept, you do need an actual imple…
> There's room for both. Sure. I'm all for learning ML, Scheme, C/C++, Python, Ruby, Java/C#, etc. > There's a reason why a lot of CS programs have shuffled from primarily C to Python (some had Java in between). The reason is called dumbing down the curriculum. My fall freshman year, my college tried to switch from C to Java in order to make it easier for the general population to get into CS and there was a major pu…
This breaks the HN guideline against flamebait. Please don't post like this here.
Re: Write a hash table in C
#57Earlier quoted context omitted.
OK... so how did junk like this ever get into enough implementations that people were forced to include it in the standard? ;)
tsearch/hsearch/lsearch have been around for at least 30 years. My guess is that they've been around for a lot longer. Why not have these anyway? Otherwise people will make their own (probably buggy) equivalents. I'm actually surprised that people aren't aware of them.
The _r versions look perfectly sensible.
Re: Write a hash table in C
#58Earlier quoted context omitted.
> There's room for both. Sure. I'm all for learning ML, Scheme, C/C++, Python, Ruby, Java/C#, etc. > There's a reason why a lot of CS programs have shuffled from primarily C to Python (some had Java in between). The reason is called dumbing down the curriculum. My fall freshman year, my college tried to switch from C to Java in order to make it easier for the general population to get into CS and there was a major pu…
> so that music/english majors can pass CS classes This breaks the HN guideline against flamebait. Please don't post like this here. https://news.ycombinator.com/newsguidelines.html
Introduction to Programming became a requirement and the drop-out/failure rate for non-CS major students was excessively high so the Dean thought teaching the classes in java rather than c would help out those who were new to programming and help them pass these "newly required" classes.