top | item 47208423

I Built a Scheme Compiler with AI in 4 Days

37 points| MatthewPhillips | 4 hours ago |matthewphillips.info

25 comments

order

tombert|2 hours ago

This is cool, I got Codex to vibe code a Forth compiler for the NES and it worked fine, but I have to say that it is decidedly not fun.

Instead of figuring out how to solve every bug and becoming intimately familiar with with the code, I just delegate all the work to virtual interns and I sit and wait.

I decided to write my own Forth compiler without AI assistance as a result. Side projects should be fun and for learning.

Not judging people who use these tools, I use them too, but i just have been using them less for anything I am doing for fun.

xandrius|2 hours ago

There is fun in what you use something for and doing the something.

I think there is a big divide between people who just love making different tools from scratch by hand and the rest who love being able to instantly whip up a new tool in minutes AND THEN use it to create something fun.

I literally would never ever in my existence be interested in making a compiler if I had nothing to use it for. If I ever wanted to make a cool program which uses that compiler then whether the compiler came into being thanks to a wizard, my enjoyment wouldn't change a single bit.

yoyohello13|1 hour ago

I think the difference is in why you want a forth compiler on the nes. Is it because you want to dig in and learn how a compiler on the nes would work? Or do you want a compiler so you can use it for something else you’re interested in doing? If your goal is the first one, then vibe coding is not going to be a good fit.

jnpnj|2 hours ago

We need a new pair of words to distinguish these two mindsets. Digging deep, finding abstractions, solutions that would say more with less .. is one kind of fun. Other people want to see the magic happen by doing few keystrokes it seems, they call it fun, i call it death.

networked|51 minutes ago

The column-number switch on the site is a clever idea, but I don't think it works. The columns are limited to a fixed height in rem, shorter with more columns. This forces readers to scroll down each column and then back up to continue.

I'd say the site should imitate newspapers either more or less closely. In either case, first limit column height to something like 80% of the viewport. The column-number switch can work similarly, selecting column width as a fraction of screen width.

More closely: split the document into multiple newspaper-style pages. The reader will only need to scroll vertically to advance between pages.

Less closely: use unlimited columns with horizontal scrolling. This way, the reader only needs to scroll vertically to bring the columns into view.

sicher|2 hours ago

Cool. I'm also working on a Scheme compiler for embedding. Bytecode VM as well as AOT compilation to Zig. 100% written by Claude Opus under my supervision and guidance. I've given it an extensive set of tests and benchmarks (r5rs and r7rs) which helps A LOT. I currently use it embedded in a modal prose editor, mostly running integration tests for now.

https://codeberg.org/sicher/zscheme

apgwoz|1 hour ago

> There’s probably more I built that I have already forgotten about.

This is a big gripe of mine at the moment. I rarely have any confidence that I know how the thing works, or what additional things it does / does not do but which I expect.

Recent example: all API endpoints should require a bearer token. Imagine my surprise when half of them didn’t enforce this effectively, 3 days later. A bearer token would work, but also providing no bearer token would also work. Over the course of time, tests were removed / things were modified to get to the goal and say “done, boss!”

I’ll note that for this project, “don’t look at the source code” was a requirement. Things have been corrected before release, but the amount of potential foot guns is so damn high.

igornotarobot|3 hours ago

> I run into bugs all the time so it’s probably not ready for anyone other than me to use, but I’ve managed to go pretty deep (if not wide) in just a few days of work.

Having similar experience with my experimental code generator to Rust. Every time a yet another example does not work, Claude fixes it. However, I am curious whether it would converge to a bullet-proof solution, or I have to carefully read the code and come up with proper abstractions.

nextaccountic|1 hour ago

Are you using syn to pretty print a tree, or concatenating strings?

I think it helps having an intermediate tree where every value is valid rust code (not just synctactically, but it compiles and runs fine) helps a lot. Like an IR for your transpiler

convolvatron|2 hours ago

if you're trying to write rust without thinking about the abstractions then yeah, its probably non-terminal. I would strongly suggest making the broad strokes yourself and letting it fill the details.

eatonphil|3 hours ago

What does "Write Yourself a Scheme in 48 Hours" produce? From OP I'm guessing it's something less than (73% of) R7RS.

https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_...

MatthewPhillips|3 hours ago

The reason it's only 73% is because I prioritized fun stuff like self hosting and platform binaries. I think finishing off the standards would only take a few more hours (except eval which I don't plan to do).

threethirtytwo|3 hours ago

detractors of AI claim this stuff is in its training data so it could be a copy which is valid. The crazy thing is the fact that it can definitely build something that does not exist.

convolvatron|2 hours ago

how many scheme compilers do you think have been written?