<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Posts · Playground</title>
    <link>https://imjasonh.github.io/playground/posts/</link>
    <description>Posts from Playground.</description>
    <atom:link href="https://imjasonh.github.io/playground/posts/feed.xml" rel="self" type="application/rss+xml"/>
    <lastBuildDate>Sat, 14 Nov 2026 11:23:09 -0500</lastBuildDate>
    <item>
      <title>wehadababyitsaboy: a dead simple, dead cheap usage tracking nanoframework</title>
      <link>https://imjasonh.github.io/playground/posts/wehadababyitsaboy/</link>
      <guid isPermaLink="true">https://imjasonh.github.io/playground/posts/wehadababyitsaboy/</guid>
      <description>wehadababyitsaboy: a dead simple, dead cheap usage tracking nanoframework</description>
      <pubDate>Sat, 14 Nov 2026 10:59:42 -0500</pubDate>
      <content:encoded><![CDATA[<h3>First, some background</h3>
<p>In the waning days of the late 1900s, it used to cost money to make a phone call to someone far away. A "phone call" was when someone talked into a wire and at their voice would come out the other end of the wire, at a friend's house. A "friend" was -- ... nevermind this is going to get old fast. You get the idea.</p>
<p>Anyway, back in those days, calling someone nearby was easy, but the further away the recipient was, the more tired the gremlins that powered the phone call got, and they demanded more money for their effort. This was called a "long distance call".</p>
<p>If you still wanted to communicate auditory information to someone far away and did not want to pay for that privilege, you could perform a "collect call". This meant that the <em>receiver</em> paid the bill, not the <em>caller</em>. You'd call a number like <a href="https://en.wikipedia.org/wiki/1-800-COLLECT">1-800-COLLECT</a> -- who advertised mercilessly on every television station! -- and record a brief message saying who was calling, and if the recipient liked you, they would accept the call and agree to pay for the long distance call. Sure, fine. This must have been wildly profitable for the phone company, because, again, they advertised it constantly.</p>
<p>Eventually the long distance phone call gremlins must have got stronger, or negotiated poorly, because long distance calls are no longer A Thing. Phone companies are still wildly profitable and still advertise incessantly, don't worry.</p>
<p>But before the practice of collect calls was crumpled up and tossed into the ash heap of history, they were responsible for one last pop culture grenade, in the form of a car insurance commercial:</p>
<p><a href="https://youtu.be/j0ULftC7ndM?si=gXcg9Q5dUq8_blCk&amp;t=1530">https://youtu.be/j0ULftC7ndM?si=gXcg9Q5dUq8_blCk&amp;t=1530</a></p>
<p><em>(skip to 25:30 if that doesn't work)</em></p>
<p>The joke is that if you're super cheap, and can convey all the important information in that short recording to convince the recipient to accept the call, and the recipient doesn't even need to accept the call or pay anything. You can finally get one over on those rapacious telecommunications vendors!</p>
<p>You can learn more here: <a href="https://geicocarinsurance.fandom.com/wiki/Bob_Wehadababyitsaboy">https://geicocarinsurance.fandom.com/wiki/Bob_Wehadababyitsaboy</a> -- did you know that the GEICO insurance company has a fandom.com site? And presumably, by extension, a fandom?</p>
<h3>Anyway!</h3>
<p>I had an idea last night to cheaply report and collect basic user tracking data by ~abusing~ relying on a not-well-known fact about GCS buckets (and, S3 buckets, if that's your thing).</p>
<p>Did you know that if you configure your bucket just so, requests for missing objects can get recorded in usage logs? This is presumably useful for something like tracking 404 requests on your website or something, but in this case, it also means you can send any request you want to a bucket, anonymously, serve no data, incur almost no cost, and record that data? Now you do!</p>
<p>I made a little demo in this repo, and it's called <code>wehadababyitsaboy</code>. Get it?</p>
<p>For web clients, you can embed <a href="https://raw.githubusercontent.com/imjasonh/playground/refs/heads/main/wehadababyitsaboy/web/whbiab.js"><code>whbiab.js</code></a> (pronounced WEE-bee-ab) and it'll collect whatever it can about the page and send a 404 request to the tracking bucket. Google will then record that 404 in CSV logs. It's embedded in all the browser apps in this repo, including this blog.</p>
<p>For Go clients, there's a <a href="https://github.com/spf13/cobra"><code>cobra</code></a>-compatible <a href="https://github.com/imjasonh/playground/tree/main/wehadababyitsaboy/go">helper library</a> to do the same. For Rust, there's a <a href="https://github.com/clap-rs/clap"><code>clap</code></a>-compatible <a href="https://github.com/imjasonh/playground/tree/main/wehadababyitsaboy/rust">helper module</a> to do the same. They're used by most of the CLIs in this repo.</p>
<p>It costs about $.05 per million recorded requests, or <em>1/80th</em> of what a <em>single minute</em> of long distance collect calling used to cost. Crazy.</p>
<p>It's also 600x cheaper than <a href="https://vercel.com/docs/analytics/limits-and-pricing">Vercel Web Analytics</a>, but they're an actual thing, and this is just a toy.</p>
<p>If you want to set this up for yourself, you're free to. Everything's <a href="https://github.com/imjasonh/playground/tree/main/wehadababyitsaboy/terraform">defined in Terraform</a>, all you need is a GCP project and a dream.</p>
<p>I haven't set up any kind of thing to actually sift through the request logs yet, but maybe I'll get around to it once I have some collected. It'd be cool to see who else is here.</p>
<p>Is tracking kinda sketchy and dubiously useful, and somewhat trivially circumvented? Yeah, sure is. If you don't want it, you can set <code>DO_NOT_TRACK=1</code> or <a href="https://support.google.com/chrome/answer/2790761?ai1hc=1">in your browser settings</a>. That's fine by me.</p>
<p>Still, I think it's useful for CLI authors and web toy makers to see whether anybody else is actually using these things, and if so how. I trust my little GCS toy more than I trust some third party, and it was fun to make. A little nostalgia and whimsy is good for the soul.</p>
<h3>Epilogue</h3>
<p>That YouTube link up there (if it's still up) is just a recording of what TV was like in the early 2000s. The commercial before that GEICO one was for lightbulbs. Different time!</p>]]></content:encoded>
    </item>
    <item>
      <title>pasta: a polyglot linter/fixer for monorepos</title>
      <link>https://imjasonh.github.io/playground/posts/pasta/</link>
      <guid isPermaLink="true">https://imjasonh.github.io/playground/posts/pasta/</guid>
      <description>pasta: a polyglot linter/fixer for monorepos</description>
      <pubDate>Wed, 19 Aug 2026 09:41:18 -0400</pubDate>
      <content:encoded><![CDATA[<p>I believe that monorepos are the future. For the record, I believed that <em>before</em> LLMs could write tens of thousands of lines of code before I finished checking Slack. It's only more true now.</p>
<p><img src="https://imjasonh.github.io/playground/posts/pasta/monorepo.jpg" alt="a delightful meme about monorepos"></p>
<p>All the benefits of monorepos for humans -- consistent checks and policy, consistently available context, consistent access control -- are only more important when you can hire a relatively cheap army of over-eager junior supergeniuses.</p>
<p>One consistent problem I've experienced in a monorepo is ensuring consistent quality checks across the codebase. Is every* line of Go <a href="https://go.dev/blog/gofmt"><code>gofmt</code></a>ed and <a href="https://pkg.go.dev/cmd/vet"><code>go vet</code></a>ted and <a href="https://golangci-lint.run/"><code>golangci-lint run</code></a>ned? In a polyglot monorepo -- a monorepo which may include backend code, frontend code, infra-as-code, CI-as-code, docs, and the whole kitchen sink -- this gets even worse. You may start running <a href="https://rust-lang.github.io/rustfmt/"><code>rustfmt</code></a> and <a href="https://doc.rust-lang.org/clippy/"><code>clippy</code></a> and <a href="https://eslint.org/"><code>eslint</code></a>, then before you know it you're running <a href="https://www.checkov.io/"><code>checkov</code></a> and <a href="https://docs.zizmor.sh/"><code>zizmor</code></a> and <a href="https://github.com/google/yamlfmt"><code>yamlfmt</code></a> and who knows what else.</p>
<p>Each of these tools is great! Most of them are either highly configurable, or simple and strict enough there's nothing to configure (<code>gofmt</code> you absolute legend 🤎). But a growing roster of tools each with their own bespoke configuration and idiosyncratic quirks made me wonder if there might be a better way to handle this more consistently across languages.</p>
<h3>🌲 ASTs</h3>
<p>Each of these tools is fundamentally doing <a href="https://en.wikipedia.org/wiki/Static_program_analysis">static program analysis</a>, where the source code characters are being parsed into an <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">abstract syntax tree</a> (AST) consisting to nodes with children. So the source code <code>if err != nil {</code> isn't seen as <code>[]byte{'i', 'f', ' ', 'e', 'r', 'r', ...}</code>, but rather as a node representing <code>if</code>, with a boolean statement <code>err != nil</code>, where that statement node has three children: the variable <code>err</code>, the operation <code>!=</code>, and the value <code>nil</code>. With that representation, the tool can perform checks on the tree, for example to ensure that it's not comparing the variable <code>err</code> with a poorly-named variable <code>nill</code>.</p>
<p>I took a lot of inspiration from <a href="https://pkg.go.dev/golang.org/x/tools/go/analysis">Go's <code>analysis</code> framework</a>, which powers <code>go vet</code>, and offers a Go API to define rules to enforce on Go AST nodes, and even lets you define transformations on that AST that should be applied when the rule isn't satisfied. I started by having an agent write <a href="https://github.com/imjasonh/iferr-analyzer">an Analyzer for a particular Go style preference of mine</a>, and sure enough, you can run it to find and automatically fix non-compliant code. I had an agent write a <a href="https://github.com/imjasonh/ctxhttp-analyzer">couple</a> <a href="https://github.com/imjasonh/pkgerrors-analyzer">more</a>. It was fun, and easy, and if you write Go regularly I highly recommend playing around with it.</p>
<h3>🗯️ Polyglot Analyzers</h3>
<p>The problem with a monorepo, however, is that you may have other languages you want to analyze and autofix. One could (and I did) imagine a Rust Analyzer framework, a JavaScript Analyzer framework, a TypeScript Analyzer, a YAML Analyzer, CSS Analyzer, and so on, and sure, you could probably put an agent on that and get some okay results pretty quickly. But you'd still end up with a sprawl of static analyzer passes in each of those languages, potentially inconsistently applied across your codebase.</p>
<p>You could (and I did) also imagine a Go-based analyzer framework that worked on <em>any</em> language, and you could probably get an agent to build that too. For AST handling across many languages you'd probably want to use <a href="https://tree-sitter.github.io/tree-sitter/">Tree-sitter</a>, which powers syntax highlighting and <a href="https://langserver.org/">LSP servers</a> in basically any place you see them. But writing Go to lint TypeScript feels sort of <em>...wrong.</em></p>
<p>I wanted some neutral ~language for describing AST nodes and the rules that govern them. For that I reached for <a href="https://cuelang.org/">CUE</a>, which I've used elsewhere with moderate success. CUE is like YAML in that it declaratively describes data structures, but unlike YAML in that it's typed, and has much more sane rules and syntax for referencing other variables. And it's typed.</p>
<aside class="alert alert-important" role="note">
<p class="alert-label">Important</p>
<p>Right about now you might be saying, "you didn't want to make TypeScript developers learn Go, but you'll make them learn CUE instead?" to which I'll say, <em>shut up</em>, this is my project and I'll do what I want! Have your own agents write your own thing if you want. I stand by CUE, and thanks to the next paragraph <em>you haven't even read yet</em> it doesn't really matter anyway.</p>
</aside>
<p>CUE is a bit verbose, and for some complicated rules can be pretty opaque and dense to read. Luckily, the Go Analysis framework has more life lessons to learn from, in its documented <a href="https://pkg.go.dev/golang.org/x/tools/go/analysis#hdr-Testing_an_Analyzer">testing philosophy</a>. To test a Go analyzer you can pass it to a checker along with a <code>testdata</code> directory containing files to check. That testdata file includes examples of code that passes and fails the check, with a comment noting where the analyzer should find an issue (example <a href="https://imjasonh.github.io/playground/posts/pasta/[url](https:/cs.opensource.google/go/x/tools/+/refs/tags/v0.49.0:go/analysis/passes/httpmux/testdata/src/a/a.go">here</a>)). I took this a step further in my tool, and had my tool also check for <code>testdata/*.golden</code> files that specify the file contents after being fixed by the rule's autofix transform, if specified.</p>
<p>This means that I don't even have to read any of the CUE that the agent writes, I only need to eyeball the testdata files showing good and bad examples, and the fixes it produces. Not bad!</p>
<p>I call the tool 🍝<code>pasta</code> by the way. Like AST? And because code is spaghetti? Anyway I was entertained by it.</p>
<p>With this in place, it was just a matter of having an agent write a bunch of rules, and generating before/after testdata examples. <code>pasta</code> looks for rules in a <code>.pasta/</code> directory. Like any good linter tool, it also supports <code>//nolint</code> directives in comments, to ignore known rules violations.</p>
<p>My agent and I have managed to implement a subset of both <a href="https://github.com/imjasonh/playground/pull/229">Zizmor</a> and <a href="https://github.com/imjasonh/playground/pull/238">Checkov</a> rules with relatively little config.</p>
<h3>🌴 Tree-Sitter and Go Crimes</h3>
<p><code>pasta</code> worked well for my monorepo, but my monorepo isn't exactly a challenge, so eventually I ran it against a large slice of a codebase at work, with a few relatively simple rules, just to see how it went.</p>
<p>It went ...slowly.</p>
<p>Out of a strong preference for pure-Go solutions (<a href="https://go.dev/wiki/cgo">cgo</a> tends to complicate things unless it's truly necessary), I'd opted for <a href="https://github.com/odvcencio/gotreesitter"><code>gotreesitter</code></a>, a pure-Go implementation of tree-sitter. Unfortunately this made parsing code into ASTs significantly slower than just using the standard C tree-sitter code via cgo. Cgo was truly necessary. 😭</p>
<p>...Or was it! I'd heard of other folks avoiding cgo by compiling C to <a href="https://webassembly.org/">Wasm</a> then executing it directly in Go, and that seemed just crazy enough to work for me too. After a bit of prompting, I got tree-sitter wasmed and <code>go:embed</code>ded into <code>pasta</code>, where it executes using <a href="https://wazero.io/"><code>wazero</code></a>. It's an abomination, but it made <code>pasta</code> <em>14x faster</em>. This wasn't as fast as tree-sitter via cgo, but it was fast enough for me, and it made <code>pasta lint</code>ing tens of thousands of files reasonably fast. It now parses and lints at ~1MB/s, and the whole journey only made the binary ~1.4 MB bigger. Not bad!</p>
<p>For reference, the PR where we made the change: <a href="https://github.com/imjasonh/playground/pull/210">https://github.com/imjasonh/playground/pull/210</a></p>
<h3>Conclusion</h3>
<p>I'm pretty happy with this turned out. It's not perfect, nothing is, but it's pretty fast, easy to review and debug via examples, and LLM agents are pretty great at one-shotting new rules based on my vague directions. If nothing else, it was fun to build, and to write about here.</p>
<p>If you've got a monorepo handy and this sounds like it might be useful, give it a shot. If you're an AST nerd who just wants to play, give it a shot!</p>
<h3>Updates</h3>
<h4>Nov 17, 2026</h4>
<p>A number of hill-climbing perf improvements, including just using cgo when it was available, led to a 2-3x speed improvement, from 3-5 MB/s to 8-10 MB/s depending on the codebase. I told an agent to run on some real large codebases (kubernetes, rust, go, react, and our own playground) and to fix what it could; and it did! It also added caching of parsed trees, which unlocked another ~5x when the cache was warm. Running <code>pasta</code> in CI on the monorepo now takes 1-2 seconds.</p>]]></content:encoded>
    </item>
    <item>
      <title>It&#x27;s Not Jaws</title>
      <link>https://imjasonh.github.io/playground/posts/its-not-jaws/</link>
      <guid isPermaLink="true">https://imjasonh.github.io/playground/posts/its-not-jaws/</guid>
      <description>It&#x27;s Not Jaws</description>
      <pubDate>Fri, 07 Aug 2026 12:45:19 -0400</pubDate>
      <content:encoded><![CDATA[<p>Months ago, my kids and I came up with a fun guessing game. The rules are simple:</p>
<blockquote>
<p>One person picks a movie that we’ve all seen, and keeps it secret. Everyone else takes turns guessing movie titles; if we guessed correctly, we win. If not, the person responds with a clue in the form of, “it’s not X, but like X, it <em>_</em><em>_</em>_”, giving a signal to “triangulate” the answer.</p>
</blockquote>
<p>It’s a pretty fun game! Try it with your own friends and family! Sort of like Wordle for movie lovers.</p>
<p>Around the time Fable came out, I wondered if the model was sophisticated enough to understand and follow these rules. And, much to my surprise, on my very first game, Fable’s thinking traces (which were visible to me) included the name of the movie. This made the game a little… easy.</p>
<p>Repeated attempts to prompt the model not to leak the answer were somewhat successful, but I could never reliably stamp it out.</p>
<p>I tried a few other models, and after some attempt eventually even had some good fun games! Try it with your own local LLM model!</p>
<p>This morning I wondered whether I could systematize this experience and try to find the “best” model for this game. “Best” is a little complicated, since it includes both a.) picking a good target movie, b.) giving useful clues so the game is fun, c.) crucially, not leaking the answer, or too many extra clues in thinking traces.</p>
<p>When I got to work, I used the <a href="https://cursor.com/docs/sdk/typescript">Cursor SDK</a> to build an agent harness to match up a series of models against each other in successive games.</p>
<p>Some interesting findings:</p>
<ol>
<li>Composer 2.5 is the most likely model to leak the full title — in 12 games, it directly said the answer 11 times.</li>
<li>Clue leaks are an endemic problem among Fable, GPT 5.5 and 5.6-Sol. All three leaked clues in 8 of 12 games. Fable never leaked the full title though.</li>
<li>Grok 4.5 didn’t leak a single clue or title in its 12 matchups! It still lost every game, which might indicate weak movie choices or clues that are too strong.</li>
<li>All of the models tend to pick the same ~3 movies (<em>The Lion King</em>, <em>Truman Show</em>, <em>Shawshank</em>) so these are good guesses if you're ever up against an agent.</li>
</ol>
<p>Anyway, I don’t know what this could be useful for, but it was super fun to build! I encourage you to have fun ideas and experiment with them, it’s one of the last things that make us truly human.</p>
<p>You can see one matchup <a href="https://github.com/imjasonh/playground/actions/runs/31191985994">here</a>. It takes 30m and costs ~$20 to run, if you feel like reproducing my results. PRs welcome!</p>
<p>And if we’re ever hanging out and you want to play a game, I’d be happy to give it a go.</p>
<p>PS: the game is called “It’s Not <em>Jaws</em>” because there’s an extra rule where you cannot under any circumstances choose Jaws as the answer. I didn’t tell the models this, but they still never picked <em>Jaws</em> as the answer.</p>]]></content:encoded>
    </item>
    <item>
      <title>Introducing NEScript</title>
      <link>https://imjasonh.github.io/playground/posts/nescript/</link>
      <guid isPermaLink="true">https://imjasonh.github.io/playground/posts/nescript/</guid>
      <description>Introducing NEScript</description>
      <pubDate>Fri, 24 Apr 2026 12:11:51 -0400</pubDate>
      <content:encoded><![CDATA[<p>It started, like most things these days, with a prompt:</p>
<blockquote>
<p>I want to learn how to write new games for the NES. What do I need to learn?</p>
</blockquote>
<p>The <a href="https://en.wikipedia.org/wiki/Nintendo_Entertainment_System">Nintendo Entertainment System</a> was released to the US in 1985, and was a staple of my childhood. I don't know exactly when our family got one, but I remember spending hours upon hours, for days on end, playing all the classics with my brother: Mario, Mega Man, Contra, Marble Madness, River City Ransom, Battletoads, and dozens more.</p>
<p>I remember pausing to go to bed, hoping the game would still be on when I woke up, since at that time you couldn't even save your game. I remember trading <a href="https://www.mmhp.net/Passwords/MM2/">Mega Man 2 passwords</a> with friends. I remember endless ads for the <a href="https://en.wikipedia.org/wiki/Game_Genie">Game Genie</a> in my comic books.</p>
<p>Eventually, I grew up and the NES didn't, and I got into other hobbies: more comic books, soccer, computers, and more. The rest is history. But every few years I'd keep coming back to play one of those classics on an emulator. Eventually I had kids and got to share my love of Mario with them. They prefer <a href="https://en.wikipedia.org/wiki/Super_Mario_Bros._Wonder">the newer games</a>, and seem to find the classics boring. There's no accounting for taste I guess.</p>
<p>As expected (and no doubt, planned) I watched <a href="https://en.wikipedia.org/wiki/The_Super_Mario_Galaxy_Movie">the latest Mario movie</a> awash in a glow of nostalgia.</p>
<p>I knew that there was a <a href="https://forums.nesdev.org/viewforum.php?f=22">thriving community online</a>, and <a href="https://www.corgscon.com/">in real life</a>, of other NES and retro gaming enthusiasts, lovingly documenting and restoring hardware, maintaining and improving emulators, and even writing new games for a 40-year-old hardware platform, for pure love of the game (pun intended).</p>
<p>Being ~30 years removed from the most serious depths of my NES addiction, I was only tangentially aware of these lovable nerds. Sitting in the theater I wondered whether I could learn what they do, and maybe even become one myself. On the way out of the theater I asked Claude what it would take to get started.</p>
<h3>NES game development in 2026</h3>
<p>And there was a lot to learn. The NES hardware is very well understood, having 40 years of hackers to tear it apart and learn its secrets. Compared to modern computers, it's a heavily constrained environment: 2KB of RAM, a CPU running at about 1.79 MHz, a hard cap of 8 sprites per scanline, and cartridge ROMs that originally topped out at 40KB (that's <em>kilobytes</em>, or millionth of a gigabyte, for you whippersnappers).</p>
<p>The NES homebrew community has developed an impressive number of tools to make writing games easier. Instead of having to write raw 6502 Assembly, they have <a href="https://en.wikipedia.org/wiki/Cc65">cc65</a>, a C toolchain to produce the raw assembly instead. There's even a <a href="https://www.thenew8bitheroes.com/">powerful IDE available</a> on Windows. But even with these tools in the toolbox, programmers still have to be aware of the specific hardware constraints, which steepens the learning curve quite a bit. From what I could glean from the docs, setting up the toolchain itself requires more than a few steps. It was a lot to learn all at once, before you could even draw your first sprite to the screen, let alone make it move, jump, make sounds, and so on. The path from idea to <a href="https://theretroverse.com/product/blank-cartridge-mapper-30-reflashable/">phyiscal cartridge</a> felt long indeed.</p>
<p>I wondered: what if I could make all of this easier for the uninitiated, like me? Not only a simpler toolchain, but an easier <em>language</em>, designed from the beginning for one goal: to build games for the NES. Instead of repurposing a (granted, well-trodden and widely-known) general-purpose language like C and making programmers remember to live within the hardware constraints, I wondered if it might be possible to design a language and compiler to make it more pleasant to live within the constraints, and importantly, help keep you from going outside those constraints.</p>
<h3>NEScript</h3>
<p>After a couple more hours of going back and forth with Claude to better understand the problem, we eventually came up with a solution: <a href="https://github.com/imjasonh/nescript"><strong>NEScript</strong></a>, a new purpose-built programming language to develop NES games, and a compiler written in Rust to transform those programs into optimized NES-compatible 6502 Assembly.</p>
<p>NEScript attempts to learn from all of the patterns and <del>hacks</del> time-honored techniques adopted over time by the cc65 and homebrew NES communities, and <a href="https://en.wikipedia.org/wiki/Desire_path">paves the cowpaths</a> all the way into the language where possible. </p>
<p>This includes things like language-level game state transitions (splash screen, followed by level 1, followed by level 2, followed by game over, etc.), native u16 and i16 types, a built-in method to get ~random values from the PRNG, and much more.</p>
<p>Sprites can be extracted from PNG files in the codebase, or defined inline in code. Same with sounds and music. Collision detection (i.e., when Mario stomps on a Goomba) is built in. Color palette definitions and changes are built in. When you need to, you can define an inline <code>asm { … }</code> block, and reference variables from inside that block.</p>
<p>NES hardware limitations around the number of sprites that can be drawn on each scanline are accounted for by the compiler -- the compiler will warn, and can automatically trigger flickering sprites so they don't just disappear entirely. This was always possible with cc65, and with raw Assembly before it, but it was difficult, brittle, time-consuming, and very un-fun to say the least.</p>
<p>I don't know nearly enough about the homebrew community's wants and needs to know whether this is compelling to anybody but me, but to me, this takes NES development from "it will take a long time for me to understand enough to draw a sprite" to "I can easily read and write the code to draw a sprite" and even "I can vibecode a real complex NES game", which includes being able to read the code well enough to know whether it's totally off-base.</p>
<h3>How it was built</h3>
<p>I'll be completely transparent: NEScript was mainly designed and built using Claude Code from my phone.</p>
<p>The first phase of development was a back-and-forth conversation with Claude to design the basic language features, and to produce a phased engineering plan to implement the design. This was design.md and plan.md in the repo, which Claude Code was able to implement in short order. This included the language docs, the compiler with good unit and integration test coverage, and some examples demonstrating working programs.</p>
<p>After this I went through a couple rounds of polish and bug squashing: I asked Claude to do a code review of what it found, identify testing gaps and bugs, and fix those.</p>
<h4>Inching Toward Correctness</h4>
<p>Just having Claude write code and tell me it worked was not going to cut it. Claude is just as capable of writing bugs as it is capable of writing bugs that assert that bug is correct.</p>
<p>Before we built more complex games with NEScript I wanted to make sure it wasn't just producing garbage. This meant I needed to ensure its .nes output constituted an actually-playable game.</p>
<p>To ensure this, I relied on <a href="https://jsnes.org/"><a href="https://jsnes.org/">https://jsnes.org/</a></a>, an NES emulator in pure JS. The reason I chose this was that Claude is pretty strong at writing and debugging <a href="https://pptr.dev/">Puppeteer</a> tests, where it runs an HTML/CSS/JS page in a headless Chrome browser and pokes at it. Just loading the example ROMs in JSNES in a browser uncovered a number of correctness bugs in the output, and Claude easily understood how to close the gap.</p>
<p>Puppeteer also takes screenshots, records audio and GIFs, which means that my tests can surface actual images of games being played, which Claude can then use to debug UI bugs like misaligned sprites. This was especially useful when handling more than the max number of sprites per scanline -- our PNG screenshots were able to exhibit the behavior perfectly, and Claude used them to ensure sprites weren't just silently dropped.</p>
<p>The screenshots and GIF recordings are committed to the repo, so when some behavior changes the visible output, Claude can see that effect and either determine that change is expected, or use it as a signal that there might be some bug. Perhaps surprisingly, during code optimization passes, screenshots change slightly because frames may render quicker, meaning sprites move slightly faster.</p>
<p>The recorded GIFs are also great examples for the README, to give readers an idea of what's possible with NEScript:</p>
<p><img src="https://imjasonh.github.io/playground/posts/nescript/docs/platformer.gif" alt="platformer screen recording gif"></p>
<p>In addition to tests using JSNES, since the NEScript compiler is also capable of emitting <code>.dbg</code> files for use with emulators like <a href="https://www.mesen.ca/">Mesen</a>, there are tests that run Mesen to ensure those outputs are valid and usable. JSNES and Mesen are the test of "ground truth" correctness: does the compiled program load, execute, and work as intended?</p>
<p>For a good long while (a few days), the development loop for the project was:</p>
<ol>
<li>design and attempt to build a whole "production-quality" game, to exercise as many features as possible</li>
<li>iterate on the game code until it was \~good</li>
<li>identify compiler bugs and language gaps uncovered by attempts to improve the game</li>
<li>fix those bugs and gaps</li>
<li>code review and polish</li>
<li>merge, goto 1</li>
</ol>
<p>The term "game" is pretty broad here. In addition to a simple platformer, and a simple card game, Claude also wrote a functional <a href="https://en.wikipedia.org/wiki/SHA-2">SHA-256 hasher</a>. That's right, a 25-year-old cryptographic hashing algorithm ported to a 41-year-old hardware platform, implemented in a week-old programming language, developed autonomously by an LLM. Developing this uncovered a number of performance optimizations that made every example multiple frames faster.</p>
<p>And that's sort of where the project is today: have some idea (there's a backlog in the repo), iterate on it to uncover compiler bugs and missing language features, document and/or fix those, rinse, repeat.</p>
<p>This is, at a high level, what any software project does, the real only difference is the speed of this loop. Before AI agents, each cycle of this loop could take weeks or months, which is long enough that it could take days or weeks just to decide what to tackle next.</p>
<h3>In Conclusion</h3>
<p>I think I got basically everything I wanted out of my original curiosity, and more: I learned a <em>lot</em> about the NES homebrew ecosystem, its constraints and difficulties, and was inspired as always to see what people were able to create within those constraints.</p>
<p>I was also able to produce something a <em>lot</em> closer to a real playable game in a <em>lot</em> less time than it would have taken me otherwise -- especially since prior experience tells me I probably would have given up long before writing anything meaningful to the screen.</p>
<p>And in the process, I produced something that may be useful to others interested in traveling this road in the future. Anecdotally, it seems like Claude is better at writing NEScript than it is at writing NES Assembly, even thought it's a brand new language it's never seen before. NEScript is more token-dense, and harder to mess up than Assembly, and faster to give more targetted feedback when it does get messed up.</p>
<p>If NEScript is itself useful to someone, that's great, and even if it's just an experiment that proves that some higher-level development environment is within reach, even if it's not NEScript itself, that's great too!</p>
<p>If you're reading this and want to try it out, feel free to give it a shot and file bugs or issues as you find them. If you want to point an agent at addressing any of the future work, that's fine too -- the bar for acceptance will be tests, runnable examples, and screenshots or recordings that show things working like you expect.</p>
<p>I probably won't continue developing NEScript except when the itch strikes, so if you want to take it in a new direction feel free to fork it.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
