‹ 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. fooblaster · · focus · HN ↗
      How? you can write exactly the same low level code today.
      1. AlotOfReading · · focus · HN ↗
        Shot in the dark, but maybe the OP is referring to the fact that these code conventions are explicitly discouraged by the C++ core guidelines. The SoA example falls afoul of the rule requiring T* to be used only for singular object pointers, for example.
        1. cjbgkagh · · focus · HN ↗
          Not a regular C++ programmer but wouldn’t you use std::span here instead? Sure it’ll carry a few redundant lengths but it makes using functions that take spans easier. When I do write C++ it’s usually for speed so I’m often working at the intrinsics level, though AI has gotten good enough at it that I now generally delegate this work to an agent.
          1. jandrewrogers · · focus · HN ↗
            Depending on the specific code, the compiler may even eliminate the redundant lengths.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.