rswier/c4
View on GitHub ↗ ★ 10,824 C
C in four functions
31 mentions on Hacker News by 25 people: 7 stories, 24 comments · first 2014-11-04 · latest 2025-09-30
20082026
-
▲ 2
C4 – C in Four Functionsstory by welovebunnies · 2025-09-30 · 0 comments
-
…to see someone do the smallest possible C version of an ML Something like c4 - C in 4 Functions ( https://github.com/rswier/c4 ) - which actually has a type checker! (which is hard to see on first reading)
comment by chubot · 2025-06-06 · in Small Programs and Languages -
▲ 1
C4 – C in four functions (2014)story by levzettelin · 2024-10-18 · 1 comment
-
…comment mentioned and va_args. [1] https://github.com/rswier/swieros/blob/master/root/bin/c.c [2] https://github.com/rswier/c4/blob/master/c4.c [3] https://en.wikipedia.org/wiki/Recursive_descent_parser
comment by seansh · 2024-01-06 · in A tiny hand crafted CPU emulator, C compiler, and Operating System -
The C4 compiler [ https://github.com/rswier/c4 ] is a self-hosting compiler for a subset of the C programming language that produces executable x86 code. You can understand and audit this code in a couple of hours (its 528 lines). It could…
comment by dzdt · 2023-10-26 · in Running the "Reflections on Trusting Trust" Compiler -
▲ 24
C4: C in Four Functionsstory by signa11 · 2023-08-26 · 0 comments
-
c4 - C in four functions: https://github.com/rswier/c4/ c4x86 - JIT compiler for x86 in 86 lines: https://github.com/EarlGray/c4
comment by homarp · 2023-08-26 · in AoikC4x86Study: Line-by-line comments to c4.c and c4x86.c files -
…that you now know that that the first pointer will always point exactly to the next node. I've see https://github.com/rswier/c4 use that. Granted it doesn't make for the most readable code, but it's even smaller and faster.
comment by FullyFunctional · 2023-07-02 · in Flattening ASTs and other compiler data structures -
C4 comes to mind (C in 4 functions), https://github.com/rswier/c4 . have you considered adding a backend for LLVM? perhaps a bit heavyweight, but it could be a good way to get C/C++, fortran, rust, etc. if that's something you'd like!
comment by foxhill · 2022-04-07 · in Hand-optimizing the TCC code generator -
Great question. Here are some candidates: * https://github.com/rswier/c4 * https://github.com/Fedjmike/mini-c * https://github.com/rui314/8cc * https://github.com/rui314/chibicc * https://github.com/aligrudi/neatcc Some of them are…
comment by certik · 2021-03-09 · in What is the simplest self-compiling subset of C? -
…because you make them hard". That said, I think C4 makes a better example of how simple it can be: https://github.com/rswier/c4/blob/master/c4.c (Previously on HN at https://news.ycombinator.com/item?id=8558822 and…
comment by userbinator · 2021-01-21 · in Compilers are hard -
▲ 436
C4: C in Four Functions (2014)story by azhenley · 2020-02-18 · 131 comments
-
…compiler. As a matter of fact, a whole course could be devoted to the study of this masterpiece: https://github.com/rswier/c4
comment by userbinator · 2020-02-18 · in Thought Experiment: An Introductory Compilers Class -
I think c4 (a C compiler in four functions, hence the name) is pretty neat. https://github.com/rswier/c4/blob/master/c4.c
comment by numlock86 · 2019-10-28 · in Ask HN: What is the most beautiful piece of code you've ever read? -
…includes struct support. I should probably add it to the master branch so it gets more visibility: https://github.com/rswier/c4/blob/switch-and-structs/c4.c
comment by rswier · 2019-10-10 · in Small C Compilers -
…on Windows too, if you have gcc installed. Also, see "Adding support for 64 bit targets" commit: https://github.com/rswier/c4/commit/2feb8c0a142b2e513be69442... And yes, swieros has much more.
comment by acqq · 2019-10-10 · in Small C Compilers -
https://github.com/rswier/c4/blob/master/c4.c Holy what
comment by snagglegaggle · 2019-10-10 · in Small C Compilers -
It's a demo, like https://github.com/rswier/c4 .
comment by sanxiyn · 2018-04-09 · in Tinn: A tiny neural network library written in C99 -
By C4 you meant C in 4 functions? https://github.com/rswier/c4 here?
comment by pankajdoharey · 2018-03-17 · in TinyVM – A small and easy to understand virtual machine in C -
C in 4 functions: https://github.com/rswier/c4
comment by mpweiher · 2018-01-15 · in Gosh Darn Function Pointers -
Even more impressive (to my way of thinking) is c4: https://github.com/rswier/c4/blob/master/c4.c c4 is what you might call a microscopic C compiler; it's surprising how much it does for the code it has.
comment by tptacek · 2017-03-02 · in Selfie: tiny self-compiling C compiler, MIPS emulator and MIPS hypervisor -
…This one is fun too, since it contains both a bytecode compiler and its interpreter VM: https://github.com/rswier/c4 (Previously discussed on HN at https://news.ycombinator.com/item?id=8576068 and https://news.ycombinator.com/item?id=855882…
comment by userbinator · 2016-03-31 · in Super Tiny Compiler -
▲ 2
C4 – C in four functionsstory by rspivak · 2016-03-17 · 0 comments
-
▲ 1
C4: C compiler in 4 functionsstory by api · 2016-01-28 · 0 comments
-
Yes. Obligatory and tedious re-up for my favorite minimalistic C program of the last 5 years: https://github.com/rswier/c4 Take 2 hours to grok this and you can skip compiler books and move straight to compiler papers.
comment by tptacek · 2015-06-23 · in Implementing a Virtual Machine in C -
…much simpler. It's probably a bit far toward the side of terseness, but good to study in any case: https://github.com/rswier/c4/blob/master/c4.c For understanding precedence climbing/recursive descent, this is a good article:…
comment by userbinator · 2015-06-09 · in Show HN: Calc, a simple command-line calulator in C -
https://github.com/rswier/c4/blob/master/c4.c#L132 Ehehe.
comment by swah · 2015-06-02 · in PicoC: A very small C interpreter -
c4 remains the master class in minimal interpreted C implementations: https://github.com/rswier/c4 It's (of course) less complete than PicoC, but it might be the single most useful introduction to compiler construction I've read.
comment by tptacek · 2015-06-01 · in PicoC: A very small C interpreter -
…is more agreeable with my style (and I think the parser in it is amazingly concise and elegant): https://github.com/rswier/c4/blob/master/c4.c
comment by userbinator · 2015-03-17 · in Show HN: WIP C compiler in Go, inspired by 8cc -
…Use a standard library function it does not readily support, and you're out of luck. [1]: https://github.com/rswier/c4/blob/master/c4.c#L492-L498
comment by vesinisa · 2014-11-05 · in C4 – C in 4 functions -
▲ 517
C4 – C in 4 functionsstory by petercooper · 2014-11-04 · 138 comments