RF: References
Many coding standards, rules, and guidelines have been written for C++, and especially for specialized uses of C++. Many
- focus on lower-level issues, such as the spelling of identifiers
- are written by C++ novices
- see "stopping programmers from doing unusual things" as their primary aim
- aim at portability across many compilers (some 10 years old)
- are written to preserve decades old code bases
- aim at a single application domain
- are downright counterproductive
- are ignored (must be ignored by programmers to get their work done well)
A bad coding standard is worse than no coding standard. However an appropriate set of guidelines are much better than no standards: "Form is liberating."
Why can't we just have a language that allows all we want and disallows all we don't want ("a perfect language")? Fundamentally, because affordable languages (and their tool chains) also serve people with needs that differ from yours and serve more needs than you have today. Also, your needs change over time and a general-purpose language is needed to allow you to adapt. A language that is ideal for today would be overly restrictive tomorrow.
Coding guidelines adapt the use of a language to specific needs. Thus, there cannot be a single coding style for everybody. We expect different organizations to provide additions, typically with more restrictions and firmer style rules.
Reference sections:
- (RF.rules: Coding rules)
- (RF.books: Books with coding guidelines)
- (RF.C++: C++ Programming (C++11/C++14/C++17))
- (RF.web: Websites)
- (RS.video: Videos about "modern C++")
- (RF.man: Manuals)
- (RF.core: Core Guidelines materials)
RF.rules: Coding rules
- AUTOSAR Guidelines for the use of the C++14 language in critical and safety-related systems v17.10
- Boost Library Requirements and Guidelines. ???.
- Bloomberg: BDE C++ Coding. Has a strong emphasis on code organization and layout.
- Facebook: ???
- GCC Coding Conventions. C++03 and (reasonably) a bit backwards looking.
- Google C++ Style Guide. Geared toward C++17 and (also) older code bases. Google experts are now actively collaborating here on helping to improve these Guidelines, and hopefully to merge efforts so these can be a modern common set they could also recommend.
- JSF++: JOINT STRIKE FIGHTER AIR VEHICLE C++ CODING STANDARDS. Document Number 2RDU00001 Rev C. December 2005. For flight control software. For hard-real-time. This means that it is necessarily very restrictive ("if the program fails somebody dies"). For example, no free store allocation or deallocation is allowed to occur after the plane takes off (no memory overflow and no fragmentation allowed). No exception is allowed to be used (because there was no available tool for guaranteeing that an exception would be handled within a fixed short time). Libraries used have to have been approved for mission critical applications. Any similarities to this set of guidelines are unsurprising because Bjarne Stroustrup was an author of JSF++. Recommended, but note its very specific focus.
- MISRA C++ 2008: Guidelines for the use of the C++ language in critical systems.
- Using C++ in Mozilla Code. As the name indicates, this aims for portability across many (old) compilers. As such, it is restrictive.
- Geosoft.no: C++ Programming Style Guidelines. ???.
- Possibility.com: C++ Coding Standard. ???.
- SEI CERT: Secure C++ Coding Standard. A very nicely done set of rules (with examples and rationales) done for security-sensitive code. Many of their rules apply generally.
- High Integrity C++ Coding Standard.
- llvm. Somewhat brief, based on C++14, and (not unreasonably) adjusted to its domain.
- ???
RF.books: Books with coding guidelines
- (Meyers96) Scott Meyers: More Effective C++. Addison-Wesley 1996.
- (Meyers97) Scott Meyers: Effective C++, Second Edition. Addison-Wesley 1997.
- (Meyers01) Scott Meyers: Effective STL. Addison-Wesley 2001.
- (Meyers05) Scott Meyers: Effective C++, Third Edition. Addison-Wesley 2005.
- (Meyers15) Scott Meyers: Effective Modern C++. O'Reilly 2015.
- (SuttAlex05) Sutter and Alexandrescu: C++ Coding Standards. Addison-Wesley 2005. More a set of meta-rules than a set of rules. Pre-C++11.
- (Stroustrup05) Bjarne Stroustrup: A rationale for semantically enhanced library languages. LCSD05. October 2005.
- (Stroustrup14) Stroustrup: A Tour of C++. Addison Wesley 2014. Each chapter ends with an advice section consisting of a set of recommendations.
- (Stroustrup13) Stroustrup: The C++ Programming Language (4th Edition). Addison Wesley 2013. Each chapter ends with an advice section consisting of a set of recommendations.
- Stroustrup: Style Guide for Programming: Principles and Practice using C++. Mostly low-level naming and layout rules. Primarily a teaching tool.
RF.C++: C++ Programming (C++11/C++14)
- TC++PL4: A thorough description of the C++ language and standard libraries for experienced programmers.
- Tour++: An overview of the C++ language and standard libraries for experienced programmers.
- Programming: Principles and Practice using C++: A textbook for beginners and relative novices.
RF.web: Websites
RS.video: Videos about "modern C++"
- Bjarne Stroustrup: C++11 Style. 2012.
- Bjarne Stroustrup: The Essence of C++: With Examples in C++84, C++98, C++11, and C++14. 2013
- All the talks from CppCon '14
- Bjarne Stroustrup: The essence of C++ at the University of Edinburgh. 2014.
- Bjarne Stroustrup: The Evolution of C++ Past, Present and Future. CppCon 2016 keynote.
- Bjarne Stroustrup: Make Simple Tasks Simple!. CppCon 2014 keynote.
- Bjarne Stroustrup: Writing Good C++14. CppCon 2015 keynote about the Core Guidelines.
- Herb Sutter: Writing Good C++14... By Default. CppCon 2015 keynote about the Core Guidelines.
- CppCon 15
- ??? C++ Next
- ??? Meting C++
- ??? more ???
RF.man: Manuals
- ISO C++ Standard C++11.
- ISO C++ Standard C++14.
- ISO C++ Standard C++17. Committee Draft.
- Palo Alto "Concepts" TR.
- ISO C++ Concepts TS.
- WG21 Ranges report. Draft.
RF.core: Core Guidelines materials
This section contains materials that has been useful for presenting the core guidelines and the ideas behind them:
- Our documents directory
- Stroustrup, Sutter, and Dos Reis: A brief introduction to C++'s model for type- and resource-safety. A paper with lots of examples.
- Sergey Zubkov: a Core Guidelines talk and here are the slides. In Russian. 2017.
- Neil MacIntosh: The Guideline Support Library: One Year Later. CppCon 2016.
- Bjarne Stroustrup: Writing Good C++14. CppCon 2015 keynote.
- Herb Sutter: Writing Good C++14... By Default. CppCon 2015 keynote.
- Peter Sommerlad: C++ Core Guidelines - Modernize your C++ Code Base. ACCU 2017.
- Bjarne Stroustrup: No Littering!. Bay Area ACCU 2016. It gives some idea of the ambition level for the Core Guidelines.
Note that slides for CppCon presentations are available (links with the posted videos).
Contributions to this list would be most welcome.
Acknowledgements
Thanks to the many people who contributed rules, suggestions, supporting information, references, etc.:
- Peter Juhl
- Neil MacIntosh
- Axel Naumann
- Andrew Pardoe
- Gabriel Dos Reis
- Zhuang, Jiangang (Jeff)
- Sergey Zubkov
and see the contributor list on the github.