Learning C in 2023
I’ve got a need and interest in learning C for an upcoming project. I’m quite familiar with C# and JavaScript/Typescript, but have never dove into C. I know there’s a lot of resources out there but given that C has been around for so long it’s hard to tell discern what’s relevant what’s not.
I’d like to start with fundamentals and work my way into being able to navigate and contribute to an existing C codebase. I learn great with books and by creating little projects, but am open to any resources available.
14 comments
[ 2.5 ms ] story [ 107 ms ] threadThe C syntax is quite simple. Complexities come when dealing with the OS through system calls. Threads, sockets, memory, etc.
Most other languages are about learning the language features. The languages you have mentioned and C++ are like this. People tend to get bogged down in trying to get the language feature to work for their problem. I have avoided this as much as possible since I find going down that path forces me to restate my problem in a more contained environment.
I work on Linux with C. The two most important books I've used are 1. The C Programming Language by Brian Kernighan and Dennis Ritchie 2. the Linux programming interface by michael kerrisk
Also understanding your compiler and debugger is very useful. There are a lot of options in these tools to improve your program and workflow.
Try to reduce your cycle time. Code, compile and test. Don't try to write a tone of code and they get it to work properly all at once
If I just want to write a C program I don’t understand how this is true, can you elaborate?
I will say that a huge subset of C programs involve low level interactions. I know some talented developers that feel disagree, but I wouldn't use C otherwise (though there are probably other use cases). ie. basically never
In which case you are somewhat of a hardware / kernal / OS programmer. The lower layers will matter. In the PC world this might be abstracted away. I haven't heard of many developers diving into eg. a modern Intel x86, at a hardware level (but perhaps write some ASM).
C also works well for embedded systems. In which case you likely have a compiler and have to interact with low level hardware and peripherals.
So I will say in the long run you will need to learn these things. My education in C involved writing code for linux system; that's how it's taught to CS/SWE people.
On the computer / electric front, you would work with an embedded platform. In either case you'll learn useful things and will be able to jump back and forth... but there will be some substantial differences in your specialized knowledge.
2nd vote for ... kernighan, ritchie "the c programming language"
and after you master the basics maybe robert sedgewick "algorithms in c"
and: pointers ... especially if you are coming from scripting-languages or c#/java you probably only have a weak concept of reference vs value for variables and pointers for other fundamental building-blocks (c function pointers anyone ... ;)
so after the introduction look especially at pointers, because its a "new concept" and its very essential in c ;)
a more extensive list is for there: * https://stackoverflow.com/questions/562303/the-definitive-c-...
just my 0.02€
Good luck!
For the standard library (POSIX), I don't have a good catch all source but you'll want one here.
For networking (which tells more than just networking), "Beej's Guide to Networking". That's a fantastic book (online free from the author). Hilarious and informative.
I liked writing existing unix utilities myself and I found that a helpful set of projects.
My 8yo did managed to learn programming on his own with it, as he doesn't read English fluently enough yet. He now uses the French k&r as reference. But learning from it, he was struggling.
So not for you, but leaving here as a reference.