C++ Resource: CppCoreGuidelines #381
Replies: 5 comments
-
+1 Clang-Tidy implements a lot of the checks in the C++ Core Guidelines. I think Visual Studio also has some of these. Would it make sense to enable some of the checks and slowly turn up the knob as warnings are fixed? |
Beta Was this translation helpful? Give feedback.
-
Chris, thank you so much for bringing this topic! Yes, we (RN Core at Facebook) value C++ Core Guidelines and doing our best to follow it in all suitable aspects. If you see any problems in the codebase which can be improved with following the guidelines, feel free to open a PR. That's being said, the Guidelines is a huge document, so we probably cannot follow it religiously in every single aspect, esp. if some recommendation conflicts with internal Facebook-ie guidelines/code-styles or best-practices (but those are very rear exceptions). |
Beta Was this translation helpful? Give feedback.
-
Oh sweet, looks like
With an existing codebase that slow crank is about the best you can do. Otherwise it's full on firehose. That said, automated analysis is only part of the solution. Some of these rules are able to be detected by software, which is great. Many are not. One thing I like about the doc is they try to cover this in an "Enforcement" section for the rule. For example look at something less crisp like A function should perform a single logical operation. That's a fuzzy rule, but they still have suggested indicators. For those that are hard to pick up with tools we can give our human brains some patterns to look for. |
Beta Was this translation helpful? Give feedback.
-
Another incredible source of insides is Google's "C++ Tips of the Week" |
Beta Was this translation helpful? Give feedback.
-
Since this is not so much of a discussion and more work that needs to be done, I've opened this issue #28394 to capture next steps. |
Beta Was this translation helpful? Give feedback.
-
Introduction
As an engineer at Microsoft who's worked with C++ for two decades, I've really learned to appreciate the value of having written down (and linkable) guidelines around code patterns. I also appreciate that different C++ communities have different tribal agreements about style and patterns, and in no way am I interested in squawking in and telling people how to live their best C++ life. However at the request of others I'm here to share resources on C++ patterns and pitfalls that I've found to be valuable.
CppCoreGuidelines
Across the many codebases I've worked in there's one resource that has been broadly agreed upon:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
An individual team might add more rules on top of that (Windows has a huge doc of additional rules that are particular to their codebase, for example), but they are expressed assuming CppCoreGuidelines as a baseline.
Why do I like it?
It's a huge document. It's not intended to be read beginning to end, although it is interesting throughout if you're into that sort of thing. Mostly I discover more content by being linked some specific issue and then wandering around. Every time I take a stroll through I learn something new.
So, next time you're reviewing someone's PR and make a comment on some C++ fundamentals, see if I you can find justification in this document. Link it. See if that branches out and people start picking up what you're putting down.
Discussion points
Was that helpful? Anyone else have some C++ resources they have found valuable? Or similar guides around other languages relevant to React Native? Please share!
Beta Was this translation helpful? Give feedback.
All reactions