C
is a system programming language which is old but with “bad” fame: undefined behavior, notorious memory related bugs, etc. Especially with Go
and Rust
having gone viral right now, C
seems already forgotten by people. Nevertheless, IMHO, C
is still a thing which is worth for you spending some time on it.
Whether you are are a C
novice or a C
veteran,I highly recommend you read Modern C if you haven’t read it before. Then you will find C
also evolves stealthily and is not as primitive as you think. E.g., C11
has defined standard thread APIs like C++
has done, which makes C
more like a “modern” language, not an outdated thing. You may get a new perspective of C
from this book.
Regardless if you are a systems language programmer, DevOps, performance engineer or wear other hats, the more you know about the Operating System, the more you can do your job better. Take all prevailing Unix-like
Operating Systems as an example, from kernel to command line tools, they are almost implemented in C
. To study related source code can make you delve into Operating System internal deeper. E.g., I knew there is a taskset
command which can bind specified process of a dedicated CPU
, but I wanted to know the magic behind it, so I went through its code. Then I learned 2
things:
a) There is a “/proc/%pid/task
” folder which records thread information of process;
b) taskset
actually calls sched_setaffinity and sched_getaffinity APIs to attain its goal.
Last but not least, because C
is so “low-level”, you can leverage it to write highly performant code to squeeze out CPU
when performance is critical in some scenarios.
Although I have listed many reasons which I think you should learn C
, you may have sufficient excuses to refuse to dabble into C
too. It doesn’t matter. But if you want to give C
a shot, firstly you should not be scared of it. There are many ways of writing wrong C
code, but you only need to make sure what you write is correct and in defined behavior, that’s all about C
programming.