‹ BackHN Continuity

Thread

Writing Efficient C++ Code (2013)

176 points · 161 comments · ibobev

  1. 112233 · · focus · HN ↗
    "This article was originally published in Polish in issue 4/2013" — a lot of excellent advice. Sad to see C++ have moved in last decade in a direction that makes writing efficient, simple low level code harder and harder :(
    1. jll29 · · focus · HN ↗
      I think it has become EASIER: for instance, since C++23 Rust-like move semantics can be used, which provides the compiler with extra information that can be leveraged for the generation of better code.

      Or take constexpr - it permits to move computations to compile time that are complex and in older versions either had to be done at runtime, or an ugly workaround had to be used (e.g. assigning a mysterious literal pre-computed in another run or by hand).

      1. creata · · focus · HN ↗
        > C++23 Rust-like move semantics can be used

        What C++23 feature allows that?

        1. aw1621107 · · focus · HN ↗
          The closest thing I can think of is trivial relocation [0] which matches the bitwise copy + no destructor on moved-from bits of Rust's moves, but that was only added to the draft for C++26 and was removed late in the process anyways [1].

          [0]: <a href="https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg21&#x2F;docs&#x2F;papers&#x2F;2025&#x2F;p2786r13.html" rel="nofollow">https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg21&#x2F;docs&#x2F;papers&#x2F;2025&#x2F;p27...

          [1]: <a href="https:&#x2F;&#x2F;herbsutter.com&#x2F;2025&#x2F;11&#x2F;10&#x2F;trip-report-november-2025-iso-c-standards-meeting-kona-usa&#x2F;" rel="nofollow">https:&#x2F;&#x2F;herbsutter.com&#x2F;2025&#x2F;11&#x2F;10&#x2F;trip-report-november-2025-...

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.