CLanguage

ThoughtStorms Wiki

Context : ProgrammingLanguages

I like C.

Not much of a fan of CPlusPlus

Cosmopolitan lets you make C binaries that can run on any major operating system : https://github.com/jart/cosmopolitan

Quora Answer : What existing programming language do you believe could and should improve, and how?

Dec 18

I'm really surprised people haven't added new compile-time constraints to ordinary C compilers.

For example, why not have flags in the compiler - or perhaps "pragma" instructions to the compiler - to declare things like "This module is immutable" (ie. contains no assignments to variables except at their declaration). Or "Null free" (ie. no variable is created without a value assigned). Maybe even some approximation to borrow checking and other move semantics could be handled with just extra compile-time checks.

Perl has a version of this with "strict" for example.

AFAICT, it ought to be possible to add this kind of thing to C compilers without changing anything about the language itself. The code would still be good old-fashioned C that we all know and love. It's just that it's C that we know follows those extra constraints (because the compiler has ensured it)

And this shouldn't be some obscure "advanced" option or in high end tools. It should be in the C standard, explained on the first page of the "how to compile" chapter, and really easy to understand and add to existing C code.

It seems to me that this would be a cheap way to help us make a huge improvement in many, many existing and large code-bases that provide much of our computing infrastructure, as these constraints would operate on a file-by-file basis, allowing developers to incrementally add this discipline and safety to their existing code-base as and when possible.

We could also allow these constraints to be recursive. Eg. I should be able to declare that a module is immutable AND that it doesn't #include anything other than other immutable modules.