I am an SRE who does bit of a coding, but now I want to pivot towards system programming. I know I should try Rust and may be even GoLang, but I very much believe I should also know good C, and by good I mean system-programming-level C.<p>I will follow this up with learning gcc a bit, valgrind, strace and gdb.<p>Any tips, recommendations?
For the mechanics, there are a ton of good books, articles, and sites that can walk you through the syntax and I'm sure others here will have plenty of good suggestions on that.<p>While those are necessary, I'm of the opinion that you don't really learn unless you do. For systems programming, there are many good projects out there for you to poke at. I'd suggest getting a hold of the source code for Linux, FreeBSD, and OpenBSD. Learn how to build each of them, and install/run what you built to a VM. Then making a simple device driver for a serial or USB device would be a good introductory project. Even better, get an Arduino or something similar, and make/program both ends. Maybe a little button/light box that blinks if the CPU thermal throttles and can instruct the computer to launch an application when buttons are pressed for example.<p>At the end of the day, you're just going to have to find something you're interested in actually doing/finishing so you can stay motivated enough to push your self up the learning curve, just like learning anything else really. The fact that you'll be reading/writing/learning C is nearly irrelevant.
My usual recommendation is to work through K&R, which is how I learned C nearly 20 years ago as a high school senior taking an introductory C course at a community college. I still think this is a well-written book that will teach you the basics of C.<p>However, K&R was last updated when the ANSI C standard was ratified, and there has been many important changes to C since then. Moreover, there are important safety concerns that need to be taken to account with coding in C, such as opting for functions like strlcpy for copying strings instead of the classic strcpy or the better-but-still-dangerous strncpy.<p>Once you are familiar with C, I then recommend learning some Unix system calls. I highly recommend looking at the source code of Unix utilities, and I also recommend textbooks such as <i>Advanced Programming in the Unix Environment</i> to learn more about Unix system calls.<p>When I was an undergrad at Cal Poly San Luis Obispo over 15 years ago, all computer science majors were required to take an intensive course on Unix systems programming in C. We built many projects, such as HTTP servers and shells. I highly recommend building projects like these to get very proficient in C.
K&R still the best book on C. The language hasn't changed all that much over the years.<p><i>The C Programming Language (Second Edition)</i> by Kernighan & Ritchie. Available online for free:<p><a href="https://ia903407.us.archive.org/35/items/the-ansi-c-programming-language-by-brian-w.-kernighan-dennis-m.-ritchie.org/The%20ANSI%20C%20Programming%20Language%20by%20Brian%20W.%20Kernighan%2C%20Dennis%20M.%20Ritchie.pdf" rel="nofollow">https://ia903407.us.archive.org/35/items/the-ansi-c-programm...</a><p>You can find other C books and online resources to get up to speed on "modern" C features (C99), but 95% of K&R still applies.