An excuse to learn some Spinel

· Mauri's Devlog


This year Matz showed spinel, an ahead-of-time compiler for Ruby. It turns Ruby into C, compiles C with the system compiler, and produces a standalone binary. The limitations is that it only allows a subset of the language. There’s no metaprogramming available. You can’t even eval an expression.

I wanted to see what it feels like to write a real program inside those limits, and a static site generator looked like the right size for it. Given some markdown, write out some html.

That’s how I persuaded Claude to start working on Pulpmesh. A tiny blog generator inspired by the work of prose.sh and the rest of the smol web: You provide a folder of .md files, a _pulpmesh.md with general configuration for your blog, and invoking pulpmesh build gives you plain html, an rss feed and stylesheets.

Writing Ruby for Spinel is mostly just writing Ruby. Until type inference loses track of something and the C compiler starts complaining about sp_RbVal and const char *, and you have to dig what is it talking about.

About Claude sending fixes to Spinel

Spinel is young, and Pulpmesh kept running into its rough edges. At first I worked around them in my own code. Matz had built a good part of Spinel with Claude Code, so I figured it’s sensible to let same tool chase the bugs and fix them. Claude addressed several bugs around String management and they ended in several PRs.

Matz merged all four. Well, most likely Claude merged them. The lack of friction made this a very encouraging process. Yes, I know Spinel is just a hobby project, but still, I never had a better experience dealing with OSS.

I still have a PR open on Rhino from 2013. Four PRs merged in a week is a different experience.

Then it needed somewhere to live

Once the generator worked I figured why not also allow to publish the site. What I always liked about prose.sh is that publishing is just scp, so I wrote pubmesh, the daemon behind pulpme.sh. An SSH server where the username is the name of your blog. The first time an ssh key that logs in with a name gets to keep it, and whatever you copy replaces your blog’s source and triggers a pulpmesh build.

scp -r myblog/* myawesomeblog@pulpme.sh:/

A few seconds later your site is live at https://pulpme.sh/~myawesomeblog.

Now, Pubmesh is shamely written in Go, on top of wish. It only accepts markdown and one stylesheet, builds into a staging directory and swaps it in at the end. The generator itself is the Spinel binary, pubmesh just runs it.

Spinel all the way down

The plan now is to rewrite pubmesh in Ruby and compile it with Spinel too, so the whole thing, from the SSH server that receives your files to the generator that renders them, is Ruby compiled to a native binary.

That’s not possible yet. An SSH server needs crypto, and needs to handle several connections at once, and a lot of other things. So a lot of that will have to go into Spinel first, probably as Claude opens more pull requests like the ones above.

Let’s see if I get to the SSH handshake before my Rhino PR gets merged. In the mantime enjoy pulpme.sh!

last updated: