Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    F

    foonathan

    foonathan.net · Personal blog · on HN since 2016

    Jonathan Müller writes about C++ design and language features, including constexpr, move semantics, allocation APIs, and library techniques.

    Visit blogRSSHN submissions
    Languages & CompilersProgramming
    What HN says

    HN commenters cite it in C++ and Rust threads on move semantics and allocation, and one says it changed their view of C's malloc API.

    Stats for nerds
    35HN people shared it
    50linked in comments
    861story points
    Nov 2025last shared
    2018people per year2025

    Top posts on HN

    1. 1
      Carbon’s most exciting feature is its calling convention
      1 person · 243 points · first shared 2022 · 217 comments on HN
    2. 2
      Is the C++ preprocessor still needed?
      1 person · 106 points · first shared 2017 · 152 comments on HN
    3. 3
      New integer types I’d like to see
      2 people · 104 points · first shared 2022 · 126 comments on HN
    4. 4
      Constexpr is a Platform (2020)
      2 people · 102 points · first shared 2020 · 53 comments on HN
    5. 5
      Malloc() and free() are a bad API (2022)
      5 people · 89 points · first shared 2022 · 27 comments on HN
    6. 6
      What is the unit of a text column number?
      2 people · 60 points · first shared 2021 · 43 comments on HN
    7. 7
      Is the preprocessor still needed in C++? (2017)
      1 person · 43 points · first shared 2020 · 59 comments on HN
    8. 8
      Nifty Fold Expression Tricks
      2 people · 33 points · first shared 2020 · 15 comments on HN
    9. 9
      Technique: Recursive Variants and Boxes
      2 people · 19 points · first shared 2022 · 5 comments on HN
    10. 10
      I accidentally wrote a Turing-complete parsing library
      2 people · 5 points · first shared 2021 · Discussion on HN

    What HN people wrote when they linked it

    • nyanpasu64Sep 2022

      I'm reminded of https://www.foonathan.net/2022/08/malloc-interface/#problem-4-realloc. While initially I was skeptical of the author's criticism of C's allocation APIs, this bug seems to be one that could've been avoided by using the proposed try_expand() instead of realloc().

      Of course ideally we'd move away from provenance-based UB and Rust's third-class aliased mutability, to simpler conservative aliasing semantics by default, and allow programmers to opt into non-general optimizations by manually saving unchanging values like vector::size() into locals, or have the optimizer and programmer interactively explore code invariants and optimizations, making the optimizer a performance-focused pair programmer rather than a black box.

    • CalavarJul 2025

      > isn't even legit in modern C++. That's just move semantics. When you move it, it's gone at the old name.

      Exactly the opposite actually.

      Rust has destructive move while modern C++ has nondestructive move.

      So in Rust, an object is dead after you move out of it, and any further attempts to use it are a compiler diagnosed error. In contrast, a C++ object is remains alive after the move, and further use of it isn't forbidden by the language, although some or all uses might be forbidden by the specific user provided move function - you'll have to reference the documentation for that move function to find out.

      This article explains the difference well: https://www.foonathan.net/2017/09/destructive-move/

    • gpderettaNov 2022

      That's what everybody originally believes (me included)!

      constexpr is_right_answer(int x)
      {
      if (x==42) return true;
      else
      {
      std::cout <<"try again \n";
      return false;
      }

      A function can be constexpr as long as at least one possible invocation can be compile time evaluated. In fact compilers can't generally prove that a function can't be constexpr.

      I believe constinit has the semantics you want but I've yet to study it in details.

      For more details see: https://www.foonathan.net/2020/10/constexpr-platform/ .

    • aw1621107Mar 2020

      I believe programmers are still free to define specific operators in lieu of the compiler-derived ones for such cases.

      I found a blog post which raised similar concerns [0], and P1185 [1] proposes some solutions. I don't know whether they made it into the standard, though.

      [0]: https://foonathan.net/2018/10/spaceship-proposals/

      [1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r1.html

    • einpoklumNov 2025

      Sorry to be the nitpicker here, but - the best incremental improvement would probably have seen move-destruction instead of just moves, which keep the source object alive and force the allowance for a valid 'empty' or 'dummy' state.

      See also:

      * https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm#Alternative move designs

      * https://www.foonathan.net/2017/09/destructive-move/

    • cmaDec 2020

      I thought he was saying the `end` in range begin/end was now allowed to be some empty signifier to tell things to look for the null pointer (null is a sentinel, but `end` itself is now empty). That may not be right, I don't know enough about the new concepts stuff and range seems to be part of that.

      edit: looking at this it maybe covers it:

      https://foonathan.net/2020/03/iterator-sentinel/

    Related

    Marcel Weiherblog.metaobject.com47 people

    Meltdown patch reduces mkfile(8) throughput to less than 1/3 on OS X

    Marcel Weiher
    Personal · last shared 2026
    The Old New Thingdevblogs.microsoft.com/oldnewthing788 people

    Be careful with that thing, it's a confidential coffee maker

    The Old New Thing
    Company · last shared 2026
    cor3ntincor3ntin.github.io32 people

    The Problem with C (2020)

    cor3ntin
    Personal · last shared 2026
    Bartek's Coding Blogbfilipek.com49 people

    Coding without Google

    Bartek's Coding Blog
    Personal · last shared 2021
    John Regehrblog.regehr.org401 people

    Teaching C

    John Regehr
    Personal · last shared 2026
    Brown PLT Blogblog.brownplt.org33 people

    Teaching the Essentials of Garbage Collection

    Brown PLT Blog
    Company · last shared 2026
    Niko Matsakissmallcultfollowing.com221 people

    Towards a Rust Foundation

    Niko Matsakis
    Personal · last shared 2026
    Andrew Gallantblog.burntsushi.net141 people

    My FOSS Story

    Andrew Gallant
    Personal · last shared 2026