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
    J

    John Regehr

    blog.regehr.org · Personal blog · on HN since 2010

    John Regehr, a computer science professor, writes "Embedded in Academia" on compilers, undefined behavior in C and C++, and software correctness.

    Visit blogRSSHN submissions
    Languages & CompilersSystems & PerformanceProgramming
    What HN says

    Commenters recommend it as a reference for undefined behavior and compiler work, pointing to its Compilers and Software Correctness categories.

    Stats for nerds
    401HN people shared it
    448linked in comments
    12Kstory points
    Aug 2025last shared
    2014people per year2025

    Top posts on HN

    1. 1
      Teaching C
      11 people · 1K points · first shared 2016 · 211 comments on HN
    2. 2
      A Tourist’s Guide to the LLVM Source Code
      3 people · 489 points · first shared 2017 · 44 comments on HN
    3. 3
      Explaining Code Using ASCII Art
      7 people · 452 points · first shared 2019 · 80 comments on HN
    4. 4
      The Declining Value of a CS Master's Degree (2013)
      2 people · 360 points · first shared 2013 · 161 comments on HN
    5. 5
      Fun at the Unix Terminal
      2 people · 284 points · first shared 2017 · 55 comments on HN
    6. 6
      The Little C Function From Hell
      7 people · 279 points · first shared 2011 · 113 comments on HN
    7. 7
      SQLite with a Fine-Toothed Comb
      11 people · 274 points · first shared 2016 · 31 comments on HN
    8. 8
      How Clang Compiles a Function
      2 people · 274 points · first shared 2018 · 16 comments on HN
    9. 9
      How LLVM Optimizes a Function
      2 people · 270 points · first shared 2018 · 18 comments on HN
    10. 10
      A Guide to Undefined Behavior in C and C++ (2010)
      55 people · 263 points · first shared 2010 · 103 comments on HN

    What HN people wrote when they linked it

    • CyberFonicFeb 2017

      You are asking a number of inter-related questions. I will try to scatter a few pointers (pun intended) for you to follow up on.

      As far as learning the essential syntax of the C language, K&R 2ed is excellent. It was rewritten to cover the ANSI spec variations. The first edition uses the "traditional" conventions and these are generally flagged with warnings by most C compilers.

      You mention performance. That claim is a red herring. In absolute terms, C allows you to write the fastest code if you know what you are doing. But it's like saying that a Ferrari is the better car to drive to the mall because it gets you there faster - no mention of speeding tickets, purchase cost, insurance, etc. Many other languages will let you write almost as performant code which takes less time to debug and is easier to maintain.

      C is used for many different application areas, you don't mention what area you are working in. For example, C programming for Linux kernel modules is very different to writing Arduino code or networking code, etc. Each of these areas have a large body of knowledge based upon experiences, etc. I find Google / StackOverflow excellent resources.

      If you really want to learn about the quirks of C language and C compilers, then I can recommend http://blog.regehr.org.

      Finally, I recommend using gcc or clang on Linux or Mac with a vanilla text editor and command line tools. Using IDEs, including VS, introduces too much magic which can be extremely difficult…

    • wglbMay 2014

      When I was writing the code generation part of a compiler in a previous lifetime, there were a number of conversations of the following sort early on in the production life of the compiler:

      Programmer: The compiler is producing the wrong code for this case.
      Compiler team: Ok, let's look at the code and step through it.
      Programmer: So it is putting this quantity in the register pair here
      Compiler team: Right.
      Programmer: and it is taking out the high byte and putting it there
      Compiler team: Right.
      Programmer: and then it is . . . Oh. Wow, that is a weird way to do this.
      Compiler team: Right. Saves two bytes of code.

      The programming team had previously used assembler and had developed conventions of code patterns. Our boss pointed out that "A compiler should produce assembly code that an assembly programmer would be fired for writing."

      Not that we didn't have bugs, but the previous conversation was more common than the code generation bugs we had.

      And if, Team Compiler, if you think that that compiler is always right, John Regehr http://blog.regehr.org/ has some news for you.

    • platinumradJun 2018

      The standard massively conflicts with the practices used in existing C programs by existing C programmers. Yes, it's perfectly possible to write code that doesn't violate any of the (largely implicit, it's worth noting) strict-aliasing rules. But was it a good idea for the standard to allow optimizing compilers to silently break massive amounts of existing code that has worked for years? Even if that were acceptable, was it a good idea for the standard to disallow one of the more ergonomic and explicit ways (using a union) of reinterpreting an object as an object of a different type?

      Some good reads on this topic:

      https://blog.regehr.org/archives/1307

      http://www.yodaiken.com/2018/05/20/depressing-and-faintly-terrifying-days-for-the-c-standard/

      https://blog.regehr.org/archives/903 (See the end of Xavier Leroy's comment)

    • btillyDec 2020

      One of the key interest of C compared to more recent languages is that everything is explicit. With a finger you can follow the code as it runs and know exactly what is going on and when exactly.

      This has not been true in many years. C appears to be such a language, but optimizing compilers have learned how to find and optimize undefined behavior in code that most C programmers don't realize is unsafe. As a result there can be a considerable gap between the code as clearly intended, and the code that will be generated.

      See https://blog.regehr.org/archives/213 for more on this. Including real world examples of things like validation checks being elided by the compiler, leading to real-world vulnerabilities in programs which clearly have checks to avoid exactly those vulnerabilities.

    • TMWNNAug 2023

      This novel, and the prequel A Deepness in the Sky, depict a human interstellar civilization thousands of years in the future, in which superluminal travel is impossible (for the humans), so travelers use hibernation to pass the decades while their ships travel between systems. Merchants, including the ones the book portrays, often revisit systems after a century or two, so see great changes in each visit.

      <spoiler>The merchants repeatedly find that once smart dust (tiny swarms of nanomachines) are developed, governments inevitably use them for ubiquitous surveillance, which inevitably causes societal collapse.<https://blog.regehr.org/archives/255></spoiler>

      People always talk about the future Usenet and such, but this is the most important single insight of Vinge in the two books.

    • CalChrisApr 2017

      I'm less of a PARC fan and more of a Lampson fan. In fact, I'm a huge Butler Lampson fan. I've read his PARC valedictory Hints on Computer System Design many times and he's updated it recently. He went from PARC to DEC SRC (maybe 5 miles). I saw him give a talk at SRC and for about 15 minutes afterwards, I understood.

      Hints is the favorite paper of a lot of my heroes like John Regehr.

      https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/acrobat-17.pdf

      http://bwlampson.site/Slides/Hints%20and%20principles%20(HLF%202015).pdf

      http://blog.regehr.org/archives/1143

      From SRC, he went to Microsoft and he also taught at MIT.

      https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-826-principles-of-computer-systems-spring-2002/

    Related

    Adrian Sampsoncs.cornell.edu/~asampson33 people

    Statistical Mistakes and How to Avoid Them

    Adrian Sampson
    Personal · last shared 2026
    Yossi Kreininyosefk.com387 people

    Yosefk - My history with Forth & stack machines

    Yossi Kreinin
    Personal · last shared 2026
    Random ASCIIrandomascii.wordpress.com274 people

    There are only four billion floats, so test them all (2014)

    Random ASCII
    Personal · last shared 2026
    TrustInSoft Blogtrust-in-soft.com30 people

    Ways C compilers break for objects larger than PTRDIFF_MAX bytes

    TrustInSoft Blog
    Company · last shared 2025
    Ralf Jungralfj.de99 people

    There is no memory safety without thread safety

    Ralf Jung
    Personal · last shared 2026
    Herb Suttergotw.ca84 people

    Ritchie, Stroustrup, and Gosling interview

    Herb Sutter
    Personal · last shared 2026
    Coding Horrorblog.codinghorror.com2.1k people

    Farewell Stack Exchange

    Coding Horror
    Personal · last shared 2026
    Aphyraphyr.com551 people

    Hexing the technical interview (2017)

    Aphyr
    Personal · last shared 2026