The new C standards are worth it

The C language is one of the oldest among the popular languages in use today. C is a conservative language.

The good news is that the language is aging well and it has been rejuvenated by the latest standards. The C99 and C11 standards bring many niceties…

  • Fixed-length types such as uint32_t for unsigned 32-bit integers.
  • A Boolean type called bool.
  • Actual inline functions.
  • Support for the restrict keyword.
  • Builtin support for memory alignment (stdalign.h).
  • Full support for unicode strings.
  • Mixing variable declaration and code.
  • Designated initializers (e.g., Point p = { .x = 0, .y = 0};).
  • Compound literals (e.g., int y[] = (int []) {1, 2, 3, 4};).
  • Multi-thread support (via threads.h).

These changes make the code more portable, easier to maintain and more readable.

The new C standards are also widely supported (clang, gcc, Intel). This year, Microsoft made it possible to use the clang compiler within Visual Studio which enables compiling C11-compliant code in Visual Studio.

7 thoughts on “The new C standards are worth it”

  1. Mixing variables with code has always been a terrible idea / practice. Put them up front, together, so they can be found easily, so the compiler can allocate and release them in one stack frame, so you have an easier time seeing WTF you’re doing in terms of memory load, so your IDE can tell you, all in one place, what you need to clean up. Never declare a function’s variables away from the head of the function. You’re just making things harder on everyone, including yourself, and you might be causing lousy code generation as well. The lazy-making “benefit” of scattering variables all over a function is wholly illusory. 40 years of coding experience speaking here.

    1. so the compiler can allocate and release them in one stack frame (…) and you might be causing lousy code generation as well

      Any performance benefit you might perceive after declaring variables up front is, to use your own term, “wholly illusory”.

      We can certainly debate maintainability and readability, but not performance.

Leave a Reply

Your email address will not be published. Required fields are marked *