hn.today

Writing Efficient C++ Code

asawicki.info112 points48 comments
Screenshot of Writing Efficient C++ Code

Commenters argued about the usefulness and scope of the article on writing efficient C++ code. hn_submit said C++ is usually fast enough without manual optimization, while 112233 lamented that modern C++ has trended in ways that make simple low-level optimizations harder. MaxBarraclough criticized the article for omitting important topics like branch prediction, context switching and synchronization and for being too brief for newcomers. gbin pointed out that performance needs are domain specific - robotics, embedded, HFT and telco demand careful resource tradeoffs - and criticized wasteful GUI app behavior.

Several commenters advanced concrete technical positions. glouwbug promoted data-oriented design, claiming switching from polymorphic pointers to std::variant and adopting structure-of-arrays yields large TLB/cache gains and faster SIMD-friendly code, and offered practical SIMD and FP tips. cjbgkagh and others said intrinsics can deliver order-of-magnitude speedups. jandrewrogers and jll29 argued that recent C++ features (constexpr, new move semantics in C++23, compile-time execution) make writing clear and efficient code easier, a view beached_whale echoed. creata warned against -ffast-math for most apps and questioned the C++23 move-semantics claim. cjbgkagh suggested std::span for safer APIs and jandrewrogers countered that compilers sometimes eliminate redundant length information.

Read on asawicki.info48 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.