I used to write code like const int * const * const ptrPtr; for about a year, having seen the “modern C” etc tutorials saying literally everything but be const. In that year, I had one bug that would have been caught by consting absolutely everything, but wasn’t because I forgot to write const enough times on a pointer, and with that I stopped doing it.
const int * const * const ptrPtr;
Writing const on everything is not worth the readability hit. It’s not worth the time it takes to type it in. Const in C is simply not powerful enough to catch real bugs, nor guide you towards better designs.
I would use and appreciate a -fconst-by-default, but that’s never going to happen.
i wonder how hard it would be to transition to a saner declaration syntax for C. it would introduce no actual language changes, so you could do it entirely as a preprocessing step, run after the C preprocessor expansion is complete and before you hand off to the compiler. per-file would be the simplest way to do it - all you need is a directive at the start of the file to run the extra preprocessor, and everything else would work unchanged. the readability payoff would be considerable.
Just use Rust already.
“Have you considered rewriting it in Rust?”
Maybe they could use Go’s declaration syntax? It’s clean and well thought out and fits pretty well into the C-derived language syntax.
yeah, go was what I had in mind when I was writing that; it’s designed by people with deep c experience who learnt from the mistakes of the past