Conquer the Complexity of Modern C++
"Beautiful C++ presents the C++ Core Guidelines from a developer's point of view with an emphasis on what benefits can be obtained from following the rules and what nightmares can result from ignoring them. For true geeks, it is an easy and entertaining read. For most software developers, it offers something new and useful."
--Bjarne Stroustrup, inventor of C++ and co-editor of the C++ Core Guidelines
Writing great C++ code needn't be difficult. The C++ Core Guidelines can help every C++ developer design and write C++ programs that are exceptionally reliable, efficient, and well-performing. But the Guidelines are so jam-packed with excellent advice that it's hard to know where to start. Start here, with Beautiful C++.
Expert C++ programmers Guy Davidson and Kate Gregory identify 30 Core Guidelines you'll find especially valuable, and offer detailed practical knowledge for improving your C++ style. For easy reference, this book is structured to align closely with the official C++ Core Guidelines website.
Throughout, Davidson and Gregory offer useful conceptual insights and expert sample code, illuminate proven ways to use both new and longstanding language features more successfully, and show how to write programs that are more robust and performant by default.
Avoid "bikeshedding": stop wasting valuable time on trivia
Don't hurt yourself by writing code that will cause problems later
Know which legacy features to avoid and the modern features to use instead
Use newer features properly, to get their benefits without creating new problems
Default to higher-quality code that's statically type-safe, leak resistant, and easier to evolve
Use the Core Guidelines with any modern version of C++: C++20, C++17, C++14 or C++11
Whether you've worked with C++ for decades or you've only recently focused on it, there's something here to improve virtually every program you write, design, or maintain.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code
## 【One-Line Pitch】
A practical, developer-focused tour of the C++ Core Guidelines, distilling 30 high-impact rules into actionable advice for writing cleaner, safer, and faster C++ code. Ideal for working C++ programmers—from veterans to recent converts—who want to modernize their style without drowning in the full Guidelines document.
## 【Book Arc】
- **Opening (~0%–15%)**: Introduces the Core Guidelines project and the book's philosophy—avoiding "bikeshedding" (wasting time on trivia) and focusing on rules that deliver real benefits. Sets up the book's structure, which mirrors the official Guidelines website for easy cross-referencing.
- **Early (~15%–35%)**: Covers foundational style rules: writing ISO Standard C++, preferring default arguments over overloading, using in-class member initializers, avoiding trivial getters/setters, declaring one name per declaration, and not insisting on single return statements. These are quick wins for code clarity.
- **Middle (~35%–65%)**: Addresses "don't hurt yourself" rules—encapsulating messy constructs, keeping function arguments low, using C-style subsets for cross-compiler ABIs, initializing members in declaration order, minimizing shared writable data, and using template metaprogramming sparingly. Also begins the "stop using that" section on legacy pitfalls.
- **Late (~65%–90%)**: Continues with rules to abandon: raw pointer ownership transfer, singletons, memset/memcpy for object initialization, casting away const, error handling via global state (errno), and `using namespace` at global scope in headers. Then shifts to "use this new thing properly"—returning structs/tuples for multiple outputs, class enums, small scopes, constexpr, templates for abstraction, and concepts.
- **Ending (~90%–100%)**: Concludes with "write code well by default"—statically type-safe programs, immutable data, encapsulating rule violations, declaring variables only when you have values, designing for optimization, and using RAII to prevent leaks. Ends with an envoi and afterword.
## 【Key Takeaways】
- **Bikeshedding is a real productivity killer** (Early): The book's core premise is that many C++ debates (naming, formatting) waste time; the Guidelines help you focus on rules that materially improve code quality and maintainability.
- **Prefer modern initialization over constructors that only set members** (Early): In-class member initializers are simpler, less error-prone, and avoid duplication—a small change with outsized clarity benefits.
- **Encapsulate messiness rather than spreading it** (Middle): When you must do something ugly (platform-specific code, tricky logic), isolate it in one place so the rest of your codebase stays clean and reviewable.
- **Raw pointers should never transfer ownership** (Late): This is a foundational safety rule—use smart pointers or containers instead, and you eliminate a whole class of leaks and dangling-pointer bugs.
- **Avoid singletons and global state for errors** (Late): Both create hidden dependencies and make testing/evolution harder; prefer explicit dependency injection and exception-based or return-value error handling.
- **Use new features deliberately, not just because they're new** (Late): Class enums, constexpr, templates, and concepts are powerful—but the book emphasizes using them *properly* to get benefits without introducing new problems.
- **Design for static type safety and immutability by default** (Ending): Preferring immutable data and type-safe interfaces makes code easier to reason about, optimize, and evolve—quality becomes the default, not an afterthought.
- **RAII is your best friend for resource management** (Ending): The book reinforces that RAII (Resource Acquisition Is Initialization) prevents leaks by tying resource lifetime to object scope—a timeless C++ principle.
## 【Reading Tips】
- **Skim the Opening and Early sections** if you're already experienced with modern C++—the style rules (default arguments, member initializers, single declarations) are quick wins but may feel basic.
- **Deep-read the Middle and Late sections** ("Don't hurt yourself" and "Stop using that")—these contain the most actionable, high-impact advice for cleaning up legacy code and avoiding common pitfalls.
- **Pay special attention to the "Use this new thing properly" section** (Late): This is where the book shines, showing how to adopt C++11/14/17/20 features correctly rather than superficially.
- **Use the book as a companion to the official Guidelines website**: The structure aligns with the online document, so you can cross-reference for deeper dives or related rules.
- **Focus on the "why" behind each rule**: The authors emphasize benefits and nightmares (what happens if you ignore the rule), which makes the advice stick better than rote memorization.
## 【Coverage Limits】
The excerpts primarily cover the table of contents and introductory material; detailed code examples and in-depth explanations for each guideline are not fully visible in the source material. This guide synthesizes the book's structure and apparent themes based on the available content.
##
Excerpt 1
书名: Beautiful C++ 30 Core Guidelines for Writing Clean, Safe, and Fast Code (Kate Gregory J. Guy Davidson) (Z-Library) 作者: Kate Gregory & J. Guy Davidson Co...
th any modern version of C++: C++20, C++17, C++14 or C++11 Whether you've worked with C++ for decades or you've only recently focused on it, there's somethi...
r file Section 4 Use this new thing properly Chapter 4.1. F.21: To return multiple “out” values, prefer returning a struct or tuple Chapter 4.2. Enum.3: Pref...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Beautiful C++ 30 Core Guidelines for Writing Clean, Safe, and Fast Code (Kate Gregory J. Guy Davidson)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Beautiful C++ 30 Core Guidelines for Writing Clean, Safe, and Fast Code (Kate Gregory J. Guy Davidson)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment