Live data from Hacker News

Write a hash table in C

github.com

21–30 of 58 posts

Re: Write a hash table in C

#21
post #16

Earlier 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…

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

#22
Don't allocate these items individually; don't store pointers to such items. They're tiny, and the pointer chasing + allocator bookkeeping overhead + potential randomisation make it inefficient for no gain. Just allocate an array of items. This way you'll also deal with fewer potential errors. Speaking of errors, please handle them and fix the API so that the caller can know if there's a problem.

Re: Write a hash table in C

#23

Earlier 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

[deleted]

Re: Write a hash table in C

#24

"The language doesn't come with [a hash table implementation] included" The standard library does come with a half-baked hash table implementation[1] (hcreate/hdestroy/hsearch) that only allows creation of _one_ global hash table. GNU libc[2] adds hcreate_r/hdestroy_r/hsearch_r that allows multiple tables to be created. The APIs are strange and antiquated. On the other hand, the hash table implementation described in…

The hcreate nonsense is POSIX, not C99, so a conforming C implementation might not include it.

Re: Write a hash table in C

#25

Earlier 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

Huh? I'm not butthurt. Seems like you are though.

I'm sorry having standards and expectations is something that offends so many people.

C isn't a "difficult" language. It's something any CS major should have an understanding of.

I can't believe on hackernews, I'd get attacked for saying people should learn C.

Nevermind that most OSes and most languages themselves are written in C. Even python interpreters are written in C.

Since when is saying people should learn C for a CS degree considered being "butthurt"? What's next? Saying people should learn latin/ancient greek for a liberal arts degree is considered being butthurt?

Re: Write a hash table in C

#26

If you just want to see hash tables work as a data structure, here's a talk-as-blog-post I made on the subject. http://nathanmlong.com/2015/10/reimplementing-rubys-hash/

Nathan, that was absolutely fan-fuckin-tastic. Pardon me for the potty mouthed tmesis but that was a highly highly amusing run through. How did you do the graphs? (I'm always wondering how people do graphs.) And is that really you on the sofa waking up from the dream?

Re: Write a hash table in C

#27
post #5

While 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.…

See elsewhere here https://news.ycombinator.com/item?id=15082885 for an neat-o Ruby implementation.

Re: Write a hash table in C

#28
In the intro section, on extending to unicode being non-trivial...is the argument that if your input has some non-ascii data you probably have all non-ascii data and the above 127 bucket will be too full? Honest question.

Re: Write a hash table in C

#29
post #8

Earlier quoted context omitted.

Because not everyone who reads HN went through a CS program, and may have not seen implementations of common data structures like this before. Its a well-written tutorial that conveys the topic well.

My advice would be to take this to another website, one specifically for introductory CS topics. I expect a higher level of discussion on HN.

[deleted]

Re: Write a hash table in C

#30

Earlier quoted context omitted.

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

Huh? I'm not butthurt. Seems like you are though. I'm sorry having standards and expectations is something that offends so many people. C isn't a "difficult" language. It's something any CS major should have an understanding of. I can't believe on hackernews, I'd get attacked for saying people should learn C. Nevermind that most OSes and most languages themselves are written in C. Even python interpreters are written…

You're being attacked because of your condescending tone implying that music and english majors aren't smart enough to pass the CS curriculum
Post reply on HN