For all its warts, the C language is a marvelous thing. It is remarkably simple, yet somehow expressive enough to allow entire operating systems to be

Weekend projects: getting silly with C - lcamtuf’s thing

submited by
Style Pass
2024-06-30 05:30:03

For all its warts, the C language is a marvelous thing. It is remarkably simple, yet somehow expressive enough to allow entire operating systems to be written with ease. Just as curiously, its terse, minimalistic syntax became the way to structure code — copied by nearly all of its mainstream successors, from Java to Go.

Among geeks, the syntax can also be credited for the emergence of code obfuscation as an art form. The IOCCC contest is perhaps the best-known outlet for this craft; a typical IOCCC submission looks like this:

There’s plenty to admire about the winning IOCCC entries, but they’re usually not fun to study: they tend to rely on confusing preprocessor macros, nonsensical formatting, unhelpful variable names, and simple logic encoded in obtuse arithmetic expressions that need to be reverse-engineered back into normal code.

This is unfortunate; the C language can easily confound seasoned developers without being hard to read. To illustrate, consider the humble switch (…) statement:

Leave a Comment