home blog portfolio outsider art github

Is C simple?

By Ian Fisher, 28 October 2024 Subscribe

Linus Torvalds is quoted in a recent LWN article as saying:

C is, in the end, a very simple language.

Some of the commenters disagree:

roc: When you first write some programs which produce correct output, you think C is simple. Then you gradually learn the rules and get better at applying them, until it's not really simple at all, but you still think it's simple from your first impression. In the meantime, you have unfortunately written a lot of garbage C code.

And:

NYKevin: C is simple if you learn it wrong. For example, if you are told that pointers are integers representing the (arbitrary) memory address of a variable, then you will think that pointers are "simple." But pointers are not, on the abstract machine, integers referencing memory addresses. Rather, a pointer is an opaque handle given out by the abstract machine which may only be manipulated in very specific ways, or else it's UB.

And a similar sentiment elsewhere:

gilgoomesh: C sounds simple when you look through K&R Cā€¦ But the reality is filled with a staggering number of weird special cases that exist because memory doesn't work like a simple flat address space; or the compiler needs to optimise field layouts, loops, functions, allocations, register assignments and local variables; or your CPU doesn't use the lower 4 bits or upper 24 bits when addressing.

I think there are actually two distinct viewpoints that are expressed in these objections:

The first point is really about semantics (in the linguistic sense), and ā€“ setting aside the larger question of language design ā€“ I don't think there's much substantive disagreement on the actual facts.

The second point is covered in depth by two excellent articles:

So, is C simple? I still don't know. I'd like to hold on to my fond impression of C as a straightforward language that does not get in your way. But I have to concede that these arguments have given me pause. ∎