Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Android 17 is the first since 3.x to add new APIs without releasing to the AOSP(grapheneos.social ↗)
    109comments
  2. Cloudflare Quick Tunnels(cloudflare.com ↗)
    197comments
  3. Saving another 100TB of RAM(cloudflare.com ↗)
    15comments
  4. Xcode 27.1 Beta Release Notes(developer.apple.com ↗)
    41comments
  5. Cache-to-Cache: Direct Semantic Communication Between LLMs (2025)(arxiv.org ↗)
    8comments
  6. Photon-Emission-Guided Laser Fault Injection Enables RP2350 Secure Debug(ledger.com ↗)
    36comments
  7. Show HN: Cactus Needle 3: 8-29MB automation models can match DeepSeek V4 Flash(cactuscompute.com ↗)
    63comments
  8. How to Write with an LLM(sockpuppet.org ↗)
    217comments
  9. The Implications of Linguistic Illegibility for LLM Security(arxiv.org ↗)
    12comments
  10. OpenJev(openjev.com ↗)
    234comments
  11. Claude Code now reads AGENTS.md if there is no Claude.md(claude.com ↗)
    2comments
  12. C++26: Trivial infinite loops are no longer undefined behaviour(sandordargo.com ↗)
    143comments
  13. Korea raises data breach fines to 10% of revenue(koreajoongangdaily.com ↗)
    40comments
  14. The first new cat species discovered in 100 years(nationalgeographic.com ↗)
    20comments
  15. Border agents can search cellphones without a warrant or reasonable suspicion(lawandcrime.com ↗)
    82comments
  16. Our brain evolved from two primitive nervous systems that merged: Study(newscientist.com ↗)
    41comments
  17. I vibed a proof of Conway's conjecture(overreacted.io ↗)
    167comments
  18. How SpaceX streamlined the Raptor engine(construction-physics.com ↗)
    14comments
  19. From Geometry to Algebra and Back Again: 4000 Years of Papers (2023) [video](youtube.com ↗)
    discuss
  20. A search-and-inference database from scratch in pure Zig(antfly.io ↗)
    10comments
  21. Minimal Phone 2(minimalcompany.com ↗)
    115comments
  22. Inside ZCode: Silently uploading your Git history to the cloud(ferstar.org ↗)
    85comments
  23. North Korean nuclear test sets off years of earthquakes(science.org ↗)
    138comments
  24. Cekura (YC F24) Is Hiring(ycombinator.com ↗)
    discuss
  25. Warez: The Infrastructure and Aesthetics of Piracy (2021)(archive.org ↗)
    8comments
  26. Show HN: Ax-check.com – Can agents use your product?(ax-check.com ↗)
    23comments
  27. US Military had close call after using AI for hallucinated intelligence report(cnn.com ↗)
    235comments
  28. Mathematicians Build Long-Awaited Graph Sandwich(quantamagazine.org ↗)
    15comments
  29. Show HN: Scry, programmable internet search w/ congestion pricing(scry.io ↗)
    16comments
  30. The scourge of x86 emulation(fex-emu.com ↗)
    74comments

Chibicc: A Small C Compiler

278 pointsby 6y agogithub.com
44 comments
6y agoHN ↗

Looking forward to the release, and will definitely get a copy!

6y agoHN ↗

Outstanding. A professional C compiler with a hackable codebase that emits x86_64 code. I'm noticing it assumes glibc-based linux. What if I modified it to emit Actually Portable Executables without needing ld/as?

6y agoHN ↗

I quite like the learn-by-commit style. Look at a diff and see what changes it took to add a feature. Very good way of showing things in a format everyone is already familiar with.

6y agoHN ↗

It would be helpful if the title was edited to feature the compiler's name: chibicc. It would make it easier to search and SEO-wise it would be helpful to disseminate the project.

6y agoHN ↗

Send an email to the mods hn@ycombinator.com They sometimes makes these changes.

6y agoHN ↗

Where will we be able to buy a copy? Is there a mailing list? I will certainly forget about this book in n months time.

6y agoHN ↗

Author here. No publishing date has been set yet. At least a half-written Japanese version of the book is available online for free (https://www.sigbus.info/compilerbook), and I'll probably translate this to English and share at least a few chapters for free. But nothing is set in stone yet. There's no mailing list for notifications yet.

6y agoHN ↗

Each commit of this project corresponds to a section of the book. For this purpose, not only the final state of the project but each commit was carefully written with readability in mind. Readers should be able to learn how a C language feature can be implemented just by reading one or a few commits of this project. For example, this is how while, [], ?:, and thread-local variable are implemented. If you have plenty of spare time, it might be fun to read it from the first commit.

nice

6y agoHN ↗

What a great resource. I will certainly pick up the book when it’s out.

6y agoHN ↗

When I find a bug in this compiler, I go back to the original commit that introduced the bug and rewrite the commit history as if there were no such bug from the beginning. This is an unusual way of fixing bugs, but as a a part of a book, it is important to keep every commit bug-free.

Somehow I can't imagine Brian Kernighan or Dennis Ritchie making those sorts of commits.

6y agoHN ↗

I would imagine it is done to avoid having a chapter at the end showing all the patches and why they were needed. A compiler course shouldn't have a bunch of errors if they can be avoided.

I doubt Brian Kernighan or Dennis Ritchie put all the errata at the end of their books on subsequent printings. They fixed the main text.

6y agoHN ↗

maybe the author can verify, from what I could see it generates assembler files that one should save to a .S file and then can be run with gcc's `cc -o executable file.S`.

6y agoHN ↗

It produces a .S file if `-S` flag was given. By default, it produces a .S file in a temporary and assemble it with `as` and write its output object file (an .o) file is produced as an output from the compiler.

6y agoHN ↗

Me as well, that was my introduction to C, before I eventually had access to Turbo C 2.0 for MS-DOS.

6y agoHN ↗

Looks like it's a Japanese podcast? Or is there an English version?

6y agoHN ↗

Oh, yes the podcast is only in Japanese.

6y agoHN ↗

Hard to tell. Maybe some die hard fan could shed some light

6y agoHN ↗

I follow him on Twitter and I haven't seen any 'official' info reading the podcast. But Mr.Rui did confirm in this thread that he would be continuing the podcast so seems like it will continue :)

6y agoHN ↗

Nothing in particular has happened to me, but producing a high quality podcast episodes takes time, and I didn't have enough time for doing that.

6y agoHN ↗

Oh I see, thank you for your response. I'm glad that you intend to continue the podcast, can't wait for the next episode :)

6y agoHN ↗

Thant's great! Missing parts are assembler and linker, which of course are out of the scope of a C compiler per se, though make complete toolchain. I'm interested in this stuff because I'm toying with my own simple machine coined for tiny FPGAs and I concidered writing my own C compiler, but I need an assembler first.

6y agoHN ↗

This looks great, I’ll definitely use it.

Is there any similar project like this where LLVM IR is used? I’ll start building a language just for fun during weekends and I plan to use LLVM but it is rather hard to understand clang on limited time, so a smaller scale project would be awesome.

6y agoHN ↗

I would look at the LLVM tutorials, and maybe the insides of your favourite languages compiler (other than clang)

When it comes to both parsing and emitting IR, keep it simple (stupid!) - the difficult bit (on a day to day basis) with the compiler is almost always the language semantics, the backend is more theory-dense but to just implement a language you can use LLVM as a black-box.

If you minimise mutable state and utilise lowering (you can implement foreach by lowering the AST to a for loop, for example) your compiler will be much easier to debug.

6y agoHN ↗

Awesome project!

When I find a bug in this compiler, I go back to the original commit that introduced the bug and rewrite the commit history as if there were no such bug from the beginning. This is an unusual way of fixing bugs, but as a a part of a book, it is important to keep every commit bug-free.

Ooo la la! "Chibicc Vol. II, The Bugs" !?

In all seriousness, a book about the bugs would be (IMO) even more fun to read than the compiler book.