4 ms·
I wish there was some way that you could configure a C++ compiler to just disable certain features of the language, or enforce good practices. But that's alrea
by jokoon 2y ago
I wish there was some way that you could configure a C++ compiler to just disable certain features of the language, or enforce good practices.
But that's already what linters/static analyzers are doing? But then, why not integrate those tools directly in a C++ compiler instead?
With cpp2/cppfront, Herb Sutter is already building some sort of a "sane" subset of the C++ language, maybe because you cannot achieve good practices without having a new syntax.
C++ seems to have the same problem of javascript: it has annoying "don't-do-that" use cases, although it seems insanely more complicated to teach good C++ practices.
- fweimer 2y agoYou can write a compiler plugin that rejects constructs you don't like. Even GCC doesn't immediately lower the more complex (more controversial) C++ constructs. There's an existing system headers mechanism, so it's probably not that hard to skip this kind of feature restrictions for the standard library headers (where the banned constructs might be used to implement something that looks completely different at the surface).
- ThatGeoGuy 2y agoThis is more or less what Sean Baxter was trying to do with https://www.circle-lang.org/ https://www.circle-lang.org/. Of course, this requires buying into a set of tooling and learning a lot of specific idioms. I can't say I've used it, but from reading the docs it seems sound enough.
- pjmlp 2y agoThat is what static analysers are for. The issue is developers that think they are useless tools.
- mst 2y agoUsefully albeit depressingly, these days you can often get significantly easier buy-in if you call it a linter instead.
- sixfiveotwo 2y ago[dead]
- humanrebar 2y agoOr taken to an extreme, it's not hard to compose clang-queries that find for any arbitrary syntax. You could ban 'int' and pointers in your project if you wanted!
- pjmlp 2y agoOr the way I like it, configure Sonar to break pull requests when devs ignore the rules that are supposed to be followed.