Hacker News new | ask | show | jobs
by tammerk 1908 days ago
There are no hidden calls, mostly there is one way to do something. No exceptions, so you can see entrance and exit points of a function. There is no "abstraction" feature, so you tend to keep your code away from unnecessary abstractions.

You can find counter-examples ofcourse, bad programmers can create a mess from anything and everything.

My question is, as an example, how come Linux kernel's code ,nginx's code or memcached's code 100 times more readable than any other project in another "better" language.

This is why people say C is simple. You have limited options and you tend to end up with a "simple, readable" solution.

No one says "C is perfect, you should use it for anything and everything, it handles all the issues of computers, no gotchas, no surprises, 3 year old kids should start with C programming."

2 comments

Unless you're working with strings, which are a hell of a nightmare to use safely. It's become a lot better in terms of the stdlib, but even stuff like the supposedly safe vsnprintf may quickly ruin your day and open potential overflow exploits if you forget to accout for the space of a null terminator or accidentally write the return value to a size_t instead of an int.

Error handling isn't obvious either. The linux kernel does it the right way with error code returns and results in pointers, but that's not the obvious way at all.

Until you try to do something like zero a buffer to clear sensitive data just before it goes out of scope, and find that there's no way to do so that compilers actually have to obey.