Moving the kernel to modern C
Moving the kernel to modern C
Posted Feb 26, 2022 21:56 UTC (Sat) by marcH (subscriber, #57642)In reply to: Moving the kernel to modern C by camhusmj38
Parent article: Moving the kernel to modern C
You have a very good point but you also have the exact reason why this keeps happening:
> No one is saying you have to use RTTI or exceptions ...
The problem is: how do you tell developers _not_ to use RTTI, exceptions or any other of the gazillion features from the C++ kitchen sink that you don't want them to use? Most people don't read coding standards until they're told to (too late) and maintainers don't scale.
The _only_ way to enforce something efficiently and consistently is to have a fully automated tool (compiler, linter, static analyzer,...) that catches it. Anyone who has ever used CI knows that.
C++ fans who keep telling everyone "modern C++ can do that too" keep missing the point. The question is absolutely not about what C++ can do; we all know the answer is "everything" - which is exactly the problem. The C++ question is "What are the compiler/linter checks to STOP people from doing X, Y and Z?" Cause most projects can't afford the maintainer bandwidth to enforce coding standards manually and even maintainers make mistakes, especially when overwhelmed.
This is the difference between theoretical computer science and real world engineering with severe labor shortages, project management, deadlines etc. Maybe even some QA sometimes.
These C++ checks will unfortunately never be good enough because:
- Everyone has a slightly different definition of what is modern and/or safe C++ or about what they want to forbid.
- C++ fans are fans of C++ because it lets you do whatever you want
- The language wasn't designed for most of these checks in the first place, so they can be at best heuristics with many false positives. Just look at existing static analyzers.
So the only such check is to forbid C++ entirely and to wait for C to keep stealing very specific stuff from C++.
Or Rust.
PS: I had given up any hope of inexperienced people producing anything decent in shell scripting and then someone mentioned shellcheck in some obscure comment on LWN. Thank you!
