Writing a C compiler in 500 lines of Python (2023)
1–10 of 114 posts
Re: Writing a C compiler in 500 lines of Python (2023)
#2Now write a Python compiler in 500 lines of C.
Re: Writing a C compiler in 500 lines of Python (2023)
#3[flagged]
Re: Writing a C compiler in 500 lines of Python (2023)
#4[flagged]
[deleted]
Re: Writing a C compiler in 500 lines of Python (2023)
#5Previously:
Writing a C compiler in 500 lines of Python - https://news.ycombinator.com/item?id=37383913 - Sept 2023 (165 comments)
Re: Writing a C compiler in 500 lines of Python (2023)
#6This 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.
Re: Writing a C compiler in 500 lines of Python (2023)
#7Now write a Python compiler in 500 lines of C.
A python VM that consumes bytecode might be doable in not-ludicrous-amounts of C. Not 500 lines I suppose. But something manageable I think? Especially if you targeted the older releases.
Re: Writing a C compiler in 500 lines of Python (2023)
#8[flagged]
Now do it without imports.
Re: Writing a C compiler in 500 lines of Python (2023)
#9[flagged]
That is not a compiler. That is called a wrapper script.
But funny none the less.
Re: Writing a C compiler in 500 lines of Python (2023)
#10This 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.
It's b/c when Chomsky invented the theory of formal grammars he was studying natural languages & the universality of abstract grammar¹. Computer scientists realized later that they could use the same theory as a foundation for formalizing the grammatical structures of programming languages.