Hacker News new | ask | show | jobs
by mmanulis 1939 days ago
First, what are you looking to gain from knowing C? IMHO C is great for embedded programming, that's it. C isn't a great language for "web programming". It's terrible at string manipulation. It's mostly used for embedded and systems programming. Yes, there are plenty of exceptions, but we're dealing with generalities here.

If you're just looking to better understand memory or pointers or something similar, K&R + What Every Programmer Should Know About Memory are all you really need. Throw in a book on linkers and loaders, even an old one, and you'll have more than enough info to understand what most programs are doing under the hood.

I learned the language in school and at the first few jobs I had, all embedded or systems work. If I had to learn it today, I would do the following:

1. Read K&R book on C - https://en.wikipedia.org/wiki/The_C_Programming_Language - your goal here is to just learn the syntax. Build some simple programs with what you learned, like replicate echo or cat commands.

2. I like Learn The Hardway series of books for the tools he teaches. It's really hard to be effective with C without knowing how to use a debugger or some static code analyses tools. https://learncodethehardway.org/c/ You can learn make, GDB, valgrind, etc. on your own too - plenty of O'Reilly books on the topics. I do recommend learning at least make, GDB and valgrind - they will help you build your code and figure out where you screwed up with your pointer arithmetic - which you will do.

3. Decide on what kind of projects you want to work with C. I learned by rebuilding some of the standard Unix utilities (e.g. curl or wget) as well as some systems programs, like a network scanner.

4. Build something a lot more complex, like a bootloader for an Arduino board. As in, get a cheap Arduino nano and write your own little bootloader that will load a simple program that blinks an LED. Plenty of other alternatives, e.g. build a basic git implementation. Try your hand at building a JSON parser - you'll hate strings by the end though.

5a. Get a book on Linux device drivers and go through it; build a few of the drivers - it's really not that hard. The Linux kernel is just another framework. You can also just look at https://kernelnewbies.org/ to see what else you can do and find other resources.

5b. Alternatively, build your own database. Can be a clone of Dynamo or Redis or some kind of RDBMS. You can even build your own pub/sub system if you want. Whatever you're curious about.

6. If you really like working with C, go through a Data Structures course and implement all of that stuff in C. You'll hate yourself but you'll learn a lot about the language. By now, you'll have picked up a bunch of that stuff anyways, but don't let not knowing quicksort algo stop you from building something. All the sorting/searching algos are better learned once you're comfortable debugging your code and looking for pointer issues.

Personally, I love working with C. It can be incredibly frustrating, but it's the first language I learned, so it's my home. In the last 10 years, I only worked with it when doing embedded work. I'll reach for Go as a system's programming language first (haven't learned Rust yet). For web development, there are too many modern frameworks and languages that are much much better than C.

1 comments

C has other use cases. Reverse engineering and Exploit Development, for example.

K&R is great if you're coming to C from a different language. I was recommended that book as a beginner and many of the exercises were way too difficult if the only exposure a person has is reading the chapter that leads up to them.