C++ Stories

cppstories.com · Personal blog · on HN since 2020

Bartłomiej Filipek writes about modern C++, covering language features, concurrency tools, initialization, and practical coding advice.

What HN saysHN commenters cite it for concurrency tools in C++17 and later and for a pimpl idiom discussion, amid debates about C++ complexity.
35HN people shared it
11linked it in comments
129stories submitted
959story points
3 months agolast shared
2020people per year2026

Most-shared posts

  1. 1
    A New Book: Data Member Initialization in Modern C++
    4 people · 2 points · first shared 2022 · 1 comments on HN
  2. 2
    How to Stay Sane with Modern C++
    3 people · 4 points · first shared 2021 · discussion on HN
  3. 3
    How to Init a String, Looking for Sanity
    3 people · 4 points · first shared 2022 · discussion on HN
  4. 4
  5. 5
    Understanding Std:Shared_mutex from C++17
    3 people · 3 points · first shared 2026 · discussion on HN
  6. 6
    Embracing Modern C++ Safely, Book Review
    2 people · 135 points · first shared 2022 · 212 comments on HN
  7. 7
  8. 8
    Integer Conversions and Safe Comparisons in C++20
    2 people · 47 points · first shared 2022 · 28 comments on HN
  9. 9
    Adjacency Matrix and std:mdspan, C++23
    2 people · 37 points · first shared 2025 · 21 comments on HN
  10. 10
    C++20 Concepts – A Quick Introduction
    2 people · 8 points · first shared 2021 · discussion on HN
  11. 11
  12. 12
  13. 13
    Using Std:Expected from C++23
    2 people · 4 points · first shared 2024 · discussion on HN
  14. 14
    Top-7 Performance Traps for Every Developer
    2 people · 3 points · first shared 2021 · discussion on HN
  15. 15

What HN people wrote when they linked it

janice1999 · 2024-01-21
Some of C++ features are great, as recently discussed on the Linux kernel mailing list. However for many of Cs usecases, they are not appropriate, like exceptions and RAII in embedded. Once you start disabling major features those 'power tools' become far less attractive. Also, to extend the metaphor, hand tools are usually obvious and easy to use while power tools can have very long manuals. See for example the 275 page book on just Initilisation in C++ [0]. [0] https://www.cppstories.com/2022/cpp-init-book/
loeg · 2026-02-21
https://www.cppstories.com/2026/shared_mutex/#newer-concurrency-tools-… > Since C++17, the concurrency library has expanded significantly. We now have: > ... > safe memory reclamation mechanisms (RCU, hazard pointers in C++26) > These tools focus mostly on thread lifetime, coordination, cancellation or lock-free programming. > std::shared_mutex fills a different role. > It is still a mutual-exclusion primitive, explicitly designed to protect a shared state with many readers and few writers. It does not compete with atomics, condition variables, or RCU. What does it mean to say shared_mutex does not "compete" with atomics/CVs/RCU? There are many situations where RCU or other safe reclamation mechanism is a good replacement for state + shared_mutex. (And some situations where atomics are a decent replacement.)
LorenDB · 2024-02-20
Read through https://www.learncpp.com. You'll get a complete refresher on the language, but it will be using modern C++ stuff (modern in this case means C++17). For C++20 and newer, honestly, the only big feature that I ever use is concepts, although I do also use the new struct initialization syntax[0]. [0]: https://www.cppstories.com/2021/designated-init-cpp20/
jb1991 · 2023-08-05
There are discussions in many places about this, including right here on HN. I encourage you to Google it. Here are some examples: https://news.ycombinator.com/item?id=24537267 https://www.cppstories.com/2018/01/pimpl/#pros-and-cons It used to be a widely advertised technique maybe a decade ago, but it has long gone out of style.
thesuperbigfrog · 2023-05-05
It depends on what problem you are trying to solve, your programming style, and the size of your team. I personally will avoid C++ if possible because it has too much complexity, too many "gotchas", and there are better choices available (Rust, Go, Ada, C, etc.). Some people like C++ and that is fine. They can use it. I will use something else if at all possible. https://en.wikipedia.org/wiki/Criticism_of_C%2B%2B https://250bpm.com/blog:4/ A 275-page book about how initialization works in C++: https://www.cppstories.com/2022/cpp-init-book/
joebaf · 2023-03-28
Here's the direct link to the blog post on the book: https://www.cppstories.com/2023/init-story-print/ And the book at Leanpub: https://leanpub.com/cppinitbook
323 · 2022-11-28
Less known fact is that it's called C++23 because there are 23 ways to initialize a variable. Of course, it's a joke. In reality C++23 has only 20 ways to initialize a variable: https://www.cppstories.com/2022/init-string-options/ https://blog.tartanllama.xyz/initialization-is-bonkers/
elcapitan · 2022-08-14
Isn't that what the linked website is for? https://www.cppstories.com/p/start-here/
oumua_don17 · 2022-08-05
This book `Embracing Modern C++ safely` just showed up in my book feed, you may find it useful. [1] is a review of the book. [1] https://www.cppstories.com/2022/embracing-modern-cpp-book/
tialaramex · 2025-09-17
So, what programmers wanted (yes, already before C++ got this) was what are called "destructive move semantics". These assignment semantics work how real life works. If I give you this Rubik's Cube now you have the Rubik's Cube and I do not have it any more. This unlocks important optimisations for non-trivial objects which have associated resources, if I can give you a Rubik's Cube then we don't need to clone mine, give you the clone and then destroy my original which is potentially much more work. C++ 98 didn't have such semantics, and it had this property called RAII which means when a local variable leaves scope we destroy any values in that variable. So if I have a block of code which makes a local Rubik's Cube and then the block ends the Rubik's Cube is destroyed, I wrote no code to do that it just happens. Thus for compatibility, C++ got this terrible "C++ move" where when I give you a Rubik's Cube, I also make a new hollow Rubik's Cube which exists just to say "I'm not really a Rubik's Cube, sorry, that's gone" and this way, when the local variable goes out of scope the destruction code says "Oh, it's not really a Rubik's Cube, no need to do more work". Yes, there is a whole book about initialization in C++: https://www.cppstories.com/2023/init-story-print/ For trivial objects, moving is not an improvement, the CPU can do less work if we just copy the object, and it may be easier to write code which doesn't act as though they were moved when in fact they were…
ghostwriter · 2023-02-15
Sorry, I still don't get how it's different from C++, and my point wasn't about `auto` but rather about `std::vector v2`: std::vector v2 (v1.begin() + 1, v1.begin() + 2); > However, in the provided example, the Rust type checker can use the provided clue to narrow this down to an exact type The Rust example is incomplete and its RHS by the time it gets to `.collect()` within the context of `iterator` has to be bound to a particular type of the context via `impl Iterator for <MyContext>`. This is pretty much the same thing as template argument deduction for class templates in C++17 [1][2], and in C++20 it got extended to generic concepts and constraints [3]: #include <numeric> #include <vector> #include <iostream> #include <concepts> template <typename T> requires std::integral<T> || std::floating_point<T> constexpr auto avg(std::vector<T> const &v) { auto sum = std::accumulate(v.begin(), v.end(), 0.0); return sum / v.size(); } int main() { std::vector v { 1, 2, 3 }; std::cout << avg(v) << std::endl; } Note that nowhere in the snippet do I specify the type explicitly except for the container of type vector. [1] https://en.cppreference.com/w/cpp/language/template_argument_deduction [2] https://devblogs.microsoft.com/cppblog/how-to-use-class-template-argum… [3] https://www.cppstories.com/2021/concepts-intro/

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close