TLDR: how I modified and deployed this programme with little knowledge of Golang
1 Background and motivation
- I began picking up the standard web development tools (Javascript, HTML and CSS) around a year ago, and hand wrote some websites in plain HTML and React with minimal help from LLMs.
- Around a month ago, I was introduced to the Next eco system, and began heavily using LLMs. I have worked through the Next quick start myself, but the front end of every project has been drafted by V0. I have never hand-drafted any Next
page.tsx
in any completed project. - LLMs can clearly help a lot with when I have a basic familiarity with the landscape. Next is new to me, but I do know the Javascript and Node eco-system.
- What about a language with which I am unfamiliar and which has a totally different eco-system, e.g. Go? That is the question I wanted to answer.
2 The goal
My interest was piqued by this blogpost. I always had a soft spot for the Game of Life, and the fact that the programme was written over a week was very attractive.
I couldn’t find a deployed version on original repo, however. So my goal was to run it on my local machine, make variations, and deploy it.
3 Background study
There is a a very well-paced Tour of Go that doesn’t require any installation: I took the first 3 lessons, but lost patience when it came to pointers and structures.
I had a sneak peek at the concurrency module, not least because coming from single-threaded Javascript/Node, it baffles me how other languages can do without Promises and async/await. But too hard: another time.
4 Installation
The first step is to clone to repo and to try to run the code on my local machine.
There was an immediate problem: water went under the bridge between 2019 and 2024, the original go.mod
and go.sum
no longer worked.
Perplexity.ai is great for this: paste in the error messages and suggestions come. The installation stage is often the most frustrating, esp. since it takes quite a deep understanding of the language and the environment to understand the error messages (and the reasons why they appear). LLMs really help with that.
It was a moment’s work to update these files and run the code on my machine.
5 Scanning the code
Helpfully, everything is in one file and it is only 200 lines long.
Even though I had no true knowledge of the syntax, just scanning through the code + comments gave me a rough idea of what is supposed to do what.
I also asked Perplexity.ai to walk me through the code, which felt helpful (even though it didn’t give me any deep understanding of the Golang itself).
6 Adding features
The cells were too small to my liking, so that is the first thing I wanted to tinker with. I tried reducing the RES parameter: but then the window size shrunk as well, which is no good.
Perplexity AI almost immediately gave the correct answer. A separate parameter, CELL-SIZE, is introduced at just the right place, and the output looked a lot more like what I wanted to.
Similarly, taking things step by step, I added a feature to slow down the update speed and (on the second day) to change the behaviour to setting only 1 cell alive per click.
7 Hallucination?
For me the most/only memorable parts of this experience is when I felt the LLM was pointing me in the wrong direction.
I was wrong about this once and right about this the other time.
In the middle of the process, I had switched from Perplexity.ai to PromptBros.ai (in which I declare an interest), so that I have a better record of what I have done. While both had their glitches, I thought the PromptBros UI was slightly better.
Both the PromptBros and Perplexity had suggested that I use the following import statement:
import (
"fmt"
"image/color"
"log"
"math/rand"
"time"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
Which I thought was a mistake: the URL “https://www.github.com/hajimehoshi/ebiten/v2" returned a 404 on GET.
But it isn’t: once I modified the go.mod
and go.sum
, a new version of ebiten could be downloaded, and the code spewed out by the LLM worked.
I still don’t have a deep understanding why this is. Dependency management is too large a topic for me to dig into right now: I recently heard (in real life) about a tool called Nix which may be help me understand this more deeply.
8 Deploy
The code runs on my local machine: how to deploy it on the browser?
Here LLMs likely led me down the wrong route: it suggested I deploy the code on Render via Docker. Interesting suggestion, and right down my street as it sounded cool to use a Dockerfile on a server.
But it occurred to me that making the code work on the browser is a different task from making it work on a remote machine. Surely the plan is not to give the user access to the full machine and let them execute a go run main.go
.
So I opened a new chat and a more sensible answer emerged: web assembly.
Even here, the LLM (Perplexity.ai) still tried to lead me down the wrong path: it suggested rewriting the entirely main.go
without reference to ebiten
, i.e. by directly manipulating the canvass API. But this could not be right. Surely whoever made Ebiten would have thought about the need to deploy it online, and there must be some solution for converting it to web assembly. And so there was.
Once the direction became clear, it was straightforward to follow the instructions and to run main.go
locally from my browser. This could not be done by just opening the HTML file: CORS became an issue. Instead, following Perplexity LLM’s rather sensible advice, I used:
python3 -m http.server 8080
To host and test everything locally.
It remained to research options for deployment. Turns out the easiest answer is Github pages, even though oddly the search result that popped up first is a rather obscure Q&A.
9 Reflections
This was a very enjoyable programming experience. I started with little knowledge of Go (and no idea at all about Web Assembly) and also came away with little. But at least I have dabbled with both and have a feel for what these tools are about. Otherwise with my current skills and interests, they are likely so forbidding that I wouldn’t have got my hands dirty at all.