xigoi

C Language Criticism

I know that C was designed a long time ago when there wasn't much knowledge about language design. I'm not trying to berate its original creators, I just think it's time to move on to more modern systems programming languages like Nim, Rust or Zig. That's why this criticism is from a modern perspective.

I found this article which explains many things much better than I, so please check it out. My article contains a few duplicates and some additional points.

Preprocessor

What's a better way of doing imports and macros than embedding another language with completely different syntax, which does naive text substitution, into your language? In order to avoid dangers which are not present in any sane import/macro systems, you have to do ugly hacks such as:

Braces & Semicolons

See Braces & Semicolons

Syntax inconsistencies & warts

Since many other languages (Java, C#, JavaScript, ...) have mindlessly copied most syntax from C, these mistakes have a profound effect on a whole family of languages.

Undefined behavior

When you write something stupid such as n++ * ++n, the compiler doesn't stop you or even warn you. Instead, it's allowed to do whatever it wants — and in practice, it will probably just interpret the code in an arbitrary way and silently move on. And what's worse, even some things that aren't stupid fall under the category of undefined behavior — such as creating a function whose name starts with to! That is, if you write a function top_results(), the compiled program can format your hard drive.

Tooling