15 ms·
The "Core Guidelines" site hidden in the references is a gem. https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuid
by kensai 4y ago
The "Core Guidelines" site hidden in the references is a gem.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
- eklitzke 4y agoPro tip: clang-tidy understands pretty much all of the cpp core guidelines, and if you're using clangd it can emit clang-tidy warnings for violations (and in some cases even provide fixits). Not to mention a bunch of other really useful style rules. You should definitely be using it if you're not already.
- ephimetheus 4y agoRunning this on header-heavy or header-only code is still an unsolved problem however.
- account42 4y agoCan't you just pass your headers as "source files" to clang-tidy? Or create dummy source files that include them if your build system can't do that?
- ephimetheus 4y agoKind of, if you happen to have the right include paths and compiler flags, which even a compile command database from e.g. CMake doesn't give you (by default)
- boundchecked 4y ago>// Hard-to-read CaMeLcAsEvArIaBlE Absolutely.
- ChrisMarshallNY 4y agoCan't get better authors.
- noobermin 4y agoI fear even reading this. Back in 2010, I read the c++faq religiously, tried to warp my projects to it in college, and in the end produced nothing because i was too busy trying to be a big boy. Now, the c++faq is obsolete. I'm generally tired of opinionated lists of "best practices," code that actually works is 10x better than what some guy (always a guy) somewhere thinks I should do whereas in fact what I should do is actually build things that I can use. Caveat (big one) okay, it's not "some guy", the authors are literally Bjarne Stroustrup & Herb Sutter. I still feel anxiety though.
- jcelerier 4y ago> I fear even reading this. you don't necessarily have to read it. Many of the guidelines are implemented as checks in clang, for me the ones I find relevant and enabled show up inline when I write code in my IDE.
- simplotek 4y ago> Back in 2010, I read the c++faq religiously, tried to warp my projects to it in college, and in the end produced nothing because i was too busy trying to be a big boy. You're just admitting to having created your own problem, and suffering consequences for it. Nothing in your comment pertains any issue with reading coding guidelines in general or specifically the C++ ones, let alone any comment in particular. > Now, the c++faq is obsolete. That's your personal assertion, and one that does not sound informed at all. I keep track of the C++ coding guidelines. In general they are nice rules of thumb. No one wants to build a religion around them.
- noobermin 4y ago>No one wants to build a religion around them. The phenomenon literally has a wikipedia page describing it[0]. That's a lot of people to describe as "no one." [0] https://en.wikipedia.org/wiki/Cargo_cult_programming https://en.wikipedia.org/wiki/Cargo_cult_programming
- simplotek 4y ago
- TremendousJudge 4y agoI love this document, because I think that it's a perfect microcosm representing all the problems with the CPP style of doing things are. The guidelines document is: - Self admittedly incomplete - Self admittedly outdated - Extremely long - Not targeted at developers first, but at analysis tool writers [1] - Raises the question (to me, at least): Why doesn't this document exist since the nineties? What was going on there? What took so long? And you can use this set of bullet points to basically describe everything that CPP does and all its complexity. Compare it to Python's pep8 and it's shameful, even. They tried to write some guidelines and the language was so big and bloated that they couldn't complete the work, plus the result is so inaccessible that most developers will simply ignore it completely. I work professionally with CPP right now and all these issues are constant sources of pain to me. I want to like the language, but everything is always like this. [1] "We do not expect you to memorize all the rules before trying to write code. One way of thinking about these guidelines is as a specification for tools that happens to be readable by humans."
- sqeaky 4y agoDo guidelines that claim to be complete and perfect actually reach that level? They preface this to cut off arguments were someone tries to slavishly follow rules even when inappropriate, something that is all too common in our industry. It is long because they work on adding examples to each one and specify precisely what they mean. Striving to reach the level of precision a pedantic C++ developer might demand when ambiguity arises. This document didn't exist in the 90s because the way we shared information was fundamentally different back then, the web sucked. Also, many of these relate to more recently learned lessons or specific things about C++11 and it would be odd to mandate time travel for one document.
- TremendousJudge 4y agoOf course, I didn't mean this specific document, just a guidelines document similar to this, but for older versions of the language. I'm sorry for comparing to Python again, but it's a much younger language and it has had an official document equivalent to this one since 2001. Remember, the Core Guidelines project was announced in 2015, after C++14 was already in production systems all over the world. C++11 has existed for more than a decade, it has already been superseded by 3 newer versions of the language that add a lot of new features (some of them incompatible with each other), yet for most of its existence there was no official guideline from the creators that explains how it should (and shouldn't) be used. And as far as I know, nothing like it existed for C++98. It's too little, too late. They clearly have some priorities regarding documentation that, as a user, I strongly disagree with. Big organizations (EA, Unreal, Google, etc) can live with this -- they can afford to have their own, very restrictive standards on how to use the language. Most small organizations (in my experience) don't, either through lack of expertise, money, time, or will (or a combination of all), and their code is usually ugly, hacky, unstable, and hard to work on. This document only solves this problem insofar it exists as a very strong recommendation to buy ReSharper and just do whatever it says.