I Wrote a Compiler
16 comments
·June 15, 2025npalli
>The original authors of yacc were Mike Lesk and Eric Schmidt - yes that Eric Schmidt.
Incorrect, they were authors of lex. yacc was authored by Stephen Johnson.
Surprising to me is all the authors are still around, even though the tools are over 50 years old!. Shows how young computer science field is.
azhenley
TinyBASIC is fun and beautifully simple. I wrote a 3-part tutorial for making a TinyBASIC-to-C compiler using Python a few years ago.
Let’s make a Teeny Tiny compiler https://austinhenley.com/blog/teenytinycompiler1.html
tuveson
I know BASIC is kind of a “bad” language, but there’s something so delightful about it. If we’re plugging TinyBASIC projects that others might find interesting, I made an MMO TinyBASIC REPL the other day: http://10klob.com/
bastawhiz
>The original authors of yacc were Mike Lesk and Eric Schmidt - yes that Eric Schmidt.
I don't know if it's worth mentioning, but the author of the post is David Singleton, the former CTO of Stripe. I almost hadn't noticed until I saw the domain.
refulgentis
I worked ~4 layers underneath him when he led Android Wear at Google, and every year or two that happens to me, and it puts a smile on my face. Gotta have love of the game to do this at that level.
IIRC, and man, maybe I'm making it up, but, lore was he always made time on a regular schedule to hack.
Usually 1 layer from the bottom isn't coding so much anymore.
(oddly, I didn't realize he was *CTO* of Stripe until a few months back, when his new thing with Hugo Barra was announced)
matthewmueller
Love reading these. Keep these blog posts coming!
TMWNN
I thought a compiler, with no adjective or caveat, should turn a HLL into machine language. Isn't what this describes—turning BASIC into Go—more accurately described as a "pseudocompiler" or "Go compiler" or somesuch? I know Emacs is always said to have a "bytecode compiler" that processes Elisp code, not a "compiler" per se. Am I mistaken?
tuveson
This kind of question winds up being the CS equivalent of “is a hotdog a sandwich”. I agree that transpiler is a more accurate term for it and that a hotdog is not a sandwich. But there are lots of languages that start life as compile-to-C things. Many compiled languages today output LLVM IR which is not machine language. Similarly people would probably call javac a compiler, even though it outputs bytecode.
fao_
Strictly speaking it's a transpiler, but honestly the delta between the target language (Go) and the source language (BASIC) is very fluffy and wooly, from what I remember from my PL theory days the distinction was always fuzzy enough that people used whatever term felt right to them.
An example off the top of my head — Chicken Scheme (call-cc.org) calls itself a compiler but it's target language is C
pxc
The standard term for this kind of compiler is "transpiler", afaik.
Here's the Wikipedia page for such things, which also taught me several other names for them:
kragen
The standard term for "transpiler" is "compiler", though.
meisel
What would you call TypeScript’s tsc, which translates TS to JS? Microsoft would say it’s a compiler: https://code.visualstudio.com/docs/typescript/typescript-com...
ratmice
So, if he had invoked go for you would it be a compiler? Another definition is that it translates a source language into a target language.
icemanind
[dead]
DustinEgg
[dead]
This is very similar to the project I have in Chapter 2 of my new book Computer Science from Scratch [0]. It's also Tiny BASIC without INPUT. I called it NanoBASIC. But it's an interpreter not a compiler. This tutorial is a nice starting point. The chapter is much more comprehensive, so if you want to get into the weeds, I can recommend my own chapter (of course). But it's in Python, not Go. The code is on GitHub[1]. But this tutorial is great too.
0: https://nostarch.com/computer-science-from-scratch
1: https://github.com/davecom/ComputerScienceFromScratch