Hacker News new | past | comments | ask | show | jobs | submit login

Did anyone ever enjoy writing C, especially data structures?

Here is what I remember from college:


Segmentation fault.

I actually had the option of using a few languages for my Data Structures/Algorithms class, and chose C. Granted, execution time was a competition and I'm a relatively competitive person by nature, so that influenced, but it really wasn't all that painful, and in fact direct control of pointers made some of the data structures easier to manage, in my opinion. Plus being on top of the rankings for efficiency is always nice :)

I found most of my segfault bugs by a simple "gdb program". It's scary at first, but it's usually not that hard.

GDB is great, but valgrind is even quicker at diagnosing segfaults.

GDB. God's gift to programmers

the Old Testament God, to be exact.

I had fun dealing with input management using the standard library only. Without any directions on how it worked or what to use.

This is something I've forgot in the years I've spent working since University. There is a certain joy in hacking on data structures / input management and finding the exact patterns that will handle all of the error cases you've thought of.

Anyone have any suggestions for priming myself to work on a problem without directions and finding a solution as you go along (exploratory programming)? The closest I've come lately is exploring the node.js API and working out a basic web server with auth, cookies, and some MVC structure.

I took a (mandatory) class on C as part of my degree ten years ago. Your description matches what I saw around the lab. They dropped C the following year.

I think the reason for this is that coding in C involves knowing a lot about the insides of a computer (eg. what memory even means, how it is addressed, why allocating a string isn't trivial at the machine level and thus requiring pointers in C, indirection, etc). In other words, there are many prerequisites coming from various other classes.

Another example of the sort of thing I mean, although it doesn't directly apply to C: it's hard to understand space and time complexity (ie. big O) without understanding the complexity of basic steps that requires knowledge of the types of things a CPU can do (eg. that memory is effectively a vector, changing a location in memory is O(1) but inserting data into a vector is far more expensive).

IMHO, there simply isn't time for classes to cover all these prerequisites thoroughly (ie. to a level needed for practical coding in C) before a C class can commence. With something like Java or Python you can ignore the complexities until you have had time to learn them. With C you can't.

Thus, it isn't sensible to teach C in college. At least not as a mandatory thing for a CS graduate. And the moment it isn't mandatory the hard classes will get dropped (I took harder classes because I found them interesting, but that lowered my average compared to what I might have achieved otherwise).

C is one of the few languages in which data structures are really fun and challenging. Even C++ has STL where everything is ready for you...

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact