Hacker News new | ask | show | jobs
by cperciva 3424 days ago
If you're going to try to learn C by looking at any of my code, I highly recommend that you pick spiped for that purpose. Tarsnap is built around libarchive, which is good code but much bigger and less coherently organized; scrypt and kivaloo sacrifice clarity for performance in many places.

But spiped is just 6500 lines of code, of which 4300 is segregated library code; a novice C programmer should be able to start by treating those as black boxes and read through the rest of the code to get a clear sense of how the entire program works -- something which is almost impossible for a program as large as even OpenBSD's minimalist httpd.

And reading spiped will expose you to a lot of the concepts which experienced C developers take for granted -- non-blocking network I/O and callbacks, threads, "extending" the language by creating more sophisticated data structures, workarounds for non-POSIX platforms, etc.