Skip to content(if available)orjump to list(if available)

Writing a C compiler in 500 lines of Python (2023)

tomhow

Previously:

Writing a C compiler in 500 lines of Python - https://news.ycombinator.com/item?id=37383913 - Sept 2023 (165 comments)

Liftyee

This article breaks it down well enough to make me feel like I could write my own C compiler targeting AVR. (I probably could... but it would not be easy.)

Never actually looked into how compilers work before, it's surprisingly similar/related to linguistics.

weregiraffe

Now write a Python compiler in 500 lines of C.

tvickery

I wrote one in 2 lines:

import sys, subprocess

subprocess.run(["gcc", sys.argv[1], "-o", "a.out"])

null

[deleted]