Ask HN: How do I learn C properly?
432 pointsI have 15+ years of experience in many languages: javascript, python, go, etc.
I can write C, but I'm not confident I'm doing it the right way. There are now decades of forums and blogs I can search through, but I'd love to have a single, clean, clear source of truth for recommendations on how to write C code.
I've started reading "Modern C" by Jens Gustedt. I'm not sure if this is the closest to a modern source of truth.
Note, I'd like my C code to work on Windows, which possibly restricts the "right way" to features provided by C89. But again, I'm not sure, the internet is super clear on this.
Thanks for the tips!
Comments (199) 63 threads
Earlier commentsRead "Who Says C is simple?": http://cil-project.github.io/cil/doc/html/cil/
Take up a different language :-)
I think the primary topic to master in C is pointers. This is where most falter. It takes a few years to "master" (if we ever do). Here I would recommend "Understanding and Using C Pointers", Richard Reese. [2]
If you are interested in networking, any of the classic "TCP/IP Illustrated Vols I/II/III", W. Richard Stevens, [3] contain a ton of C code to implement components of TCP/IP.
If you are interested in Graphics, then "Graphics Gems", Andrew Glassner [4] is a good source.
"An Introduction to GCC", Brian Gough, [5] to understand the tooling and its various bells and whistles.
My learning swimming by jumping into the deep end of the pool experience was realized by learning Windows Programming using the Charles Petzold book and navigating through Microsoft Foundation Classes in the late 80s/early 90s. The state of the art in tooling wasn't that great in those days and I spent months with the book to get things going. This was done after I had built a foundation with K&R and a decent amount of Unix network programming.
I see a lot of the other posts recommend more modern books. But you still need to build your foundation on C and Pointers in particular.
Good luck on your journey.
[1] https://www.amazon.com/Programming-Language-2nd-Brian-Kernig...
[2] https://www.amazon.com/Understanding-Using-Pointers-Techniqu...
[3] https://www.amazon.com/TCP-Illustrated-Protocols-Addison-Wes...
[4] https://www.amazon.com/Graphics-Gems-Andrew-S-Glassner/dp/01...
[5] https://www.amazon.com/Introduction-GCC-GNU-Compilers/dp/095...
All comments shown.
Couldn't load more comments. Check your connection and try again.