After too much time spent doomscrolling the polycrisis, I wrote some words: Some Other Friday. I wish I had something better to offer.
CPU Journey
The 6502 was the first CPU that I programmed1 in machine code — on my Vic-202 and on BBC Micros3 at school, back in the 80s. I wrote a few simple games for the Vic-20, mostly because its limited 3.5Kb memory made it hard to do anything in BASIC. On the BBC Micro I got a bit more ambitious and wrote something that I imagined was like a simple round-robin, cooperative multitasking scheduler. The cassette tapes containing that code will all be somewhere in a landfill site near Hull, whiling-away the time until entropy reduces the bits to noise.
Later I wrote some code for the Motorola 6809. And later still I used 68000 dev boards as an undergraduate. We had to upload assembly language to an honest-to-god minicomputer to be assembled to machine code before we could find out if the seven-segment LED display would do the right thing, or whatever it was.
(During an intern year at IBM I remember talking to an employee who was writing System/36 microcode to interface a transputer development board to a 3090 mainframe. Godlike stuff, and way beyond me.)
It’s been a while now, but I remember feeling that the 68000 was clearly powerful and elegant and a “proper CPU”, but also that I had little hope of understanding all the details of its operation. The 6502 was my first, and with hindsight was far less elegant with plenty of warts, but I felt at the time that I understood it pretty well. The 6809 was somewhere in-between, I guess, and a very nice CPU to work with.
As a professional developer I haven’t had to write a single line of machine code or assembly language these thirty-odd years. Maybe I should be glad. Even now, though, I try to think of computers as physical machines with physical characteristics and limits — even if the tools and developer experience try to convince me otherwise.
I’ve never thought about it before today, but I suppose I benefited from that early progression from 6502 to 6809 to 680004. Whether or not it makes sense as a journey nowadays, I couldn’t say.
- It occurs to me that we seldom talk about programming computers any more. We write code or apps, separated from the hardware. ↩︎
- Yes, machine code. The Vic-20 didn’t have a built-in assembler and, while I think I was aware that such as thing could theoretically be obtained somehow, I had no idea how to go about doing that. All I had was a monthly subscription to Commodore User magazine and my falling-apart copy of the Vic 20 Programmers Reference Guide. So I wrote-out the assembly language on paper and hand-converted it to machine code. Debugging was even more fun. ↩︎
- BBC Basic had a good, built-in, two-stage assembler. ↩︎
- I never got on with the Z80: that brash upstart /s ↩︎
Photos news
Herewith a housekeeping announcement about changes to the photo galleries on this site.
Prior to some time in November the photos at andyjohnson.uk/photos were served by an old installation of Lychee. Nice as Lychee is, I’d grown a little frustrated by the difficulties of uploading photos from my phone. I’d also, frankly, forgotten how to build Lychee on Windows — a problem, as I was intermittently aware that the installation was out of date.
So I retired Lychee and, for a while, brought the photos into WordPress and served them using a plug-in called Modula. This worked fairly well, and Modula is slick and pretty, but in the end I concluded that it wasn’t the best solution for a couple of reasons:
- Modula requires that all photos are stored in the WordPress media library, which lacks a way to group related images into albums. There are various plug-ins that provide a folder-like overlay on-top of the media library, but they don’t change the underlying organisation of the library. Without using some sort of naming file convention, it looked like it would be difficult to keep things organised.
- Modula is primarily designed for ecommerce sites that use images for product information. Its not a good fit for a personal photo gallery.
So I looked around at self-hostable photo gallery software that could run on the VPS that hosts this blog: basically a standard Linux/Apache/PHP virtual machine with only control panel and ftp access. And after a bit of research I decided to try Piwigo.
I’d looked at Piwigo several years ago but found it to be clunky and distinctly web 1.0-ish. In the years since it seems to have been successfully dragged into the JavaScript era, and now seemed quite snappy and pretty. It also has an updated Android uploader app. I decided to give it a go using Bootstrap Darkroom, which looked to be the most up-to-date of the various themes that Piwigo supports. I fairly quickly found that it did 90% of what I wanted, but the theme lacked some polish. Piwigo has a nice event-driven extensibility mechanism that allowed me to push this to 95% using just config tweaks, but the theme still lacked one thing I wanted: the ability to show the EXIF description or IPTC description metadata next to the image.
At this point I thought “hey, I’m a software developer – how hard can it be…” so I forked the repo. What I should have thought is “hey, I’m not a web developer – this will be hard…“. But I persevered and got properly familiar with npm and yarn and sass and PHP and VS Code, and dug into how to build the five year-old theme code with all its legacy dependencies… and it wasn’t easy. But I’m back now, battle-hardened and glad to be alive, and now I give you my Dark Aperture theme for Piwigo:

It’s based on the Bootstrap Darkroom codebase, with a bunch of enhancements and fixes that are specific to my needs. I make no claims that it is useful to anyone else. My thanks to Thomas Kuther, who wrote the code that I merely adapted and tweaked
The theme’s name comes from Wide Aperture, which is the least-worst name I could come up with for the new Piwigo site running my new theme. I think it looks pretty good.
For the time-being the site has a few albums that are a subset of the photos that were on the old Lychee site. After I’ve recovered from all this webdev I’ll upload a better, wider selection.
A Christmas Memory
Someone on HN asked: What are some of your favorite memories from Christmas? Many comments were about video games or consoles or first PCs. Here’s what I wrote, lightly expanded and edited.
—
I was born in the late 60s, so none of my earlier childhood Christmas memories involve digital technology. But one that stands out was the year that I got a telescope for Christmas.
I was maybe about ten. It was fairly average, cheap refractor on a wooden tripod. But growing up in an environment where things like that weren’t the norm, I didn’t understand that at the time. This was the era of Viking and Voyager and the Grand Tour, so I was very pleased.
On Christmas day my family, my aunts and uncles and cousins, would all cram themselves into my grandparent’s small council house for Christmas dinner. Then the kids would play with their toys and try not to get stood on by the slighly tipsy adults. There were too many people in too small a space, I realise now, but I have happy memories of those days.
When it got dark, that year, I took my new scope out into my grandparent’s small front garden to look at the moon and to try (unsuccessfully because, as I later realised, it lacked the resolving power) to locate a planet or two. The moon looked coldly beautiful, and I remember seeing craters and features in much more detail than I ever had before. I was hooked.
It was very cold that day, in a way that it doesn’t ever seem to be at Christmas anymore. People wandering past, walking dogs or maybe going to visit friends or to the pub, kept asking me what I was doing. I could hear everyone indoors, talking and laughing. Eventually it started to snow very lightly, so I packed up my gear and stood watching the thin snowfall for a while – drifting over the unlit space above the land drain that their house faced onto – and then went back indoors.
That was more than forty years ago. My grandparents are long dead and their house no longer exists. Many of the other adults who were there then have also died. But I still remember how my universe suddenly got vastly bigger that Christmas day. And I remember the snowflakes drifting down in the dark.
A few years ago I passed that telescope on to a five year old friend. I don’t know what, if anything, she makes of it though. We live in a different age of wonders, with images from the Hubble and James Webb available on any screen. Different times, as it should be.
Merry Christmas everyone.
BF
When you know deep-down that a Brainfuck interpreter should only ever be written in C, but you’re not quite ready to leave the comfort of C#. So in a spirit of minimalism you find yourself writing C# in a C style just for the hell of it.
public static void Execute(string program, Stream? input, Stream? output)
{
int ip = 0;
int dp = 0;
var data = new byte[30000];
while(true)
{
if (ip >= program.Length)
break;
switch(program[ip])
{
case '>':
dp++;
break;
case '<':
dp--;
break;
case '+':
data[dp]++;
break;
case '-':
data[dp]--;
break;
case '.':
output?.Write(data, dp, 1);
break;
case ',':
input?.Read(data, dp, 1);
break;
case '[':
if (data[dp] == 0)
ip = JumpTo(']', +1, program, ip);
break;
case ']':
if (data[dp] != 0)
ip = JumpTo('[', -1, program, ip);
break;
}
ip++;
}
}
private static int JumpTo(char match, int incr, string program, int ip)
{
while (true)
{
ip += incr;
if ( (match == ']' && program[ip] == '[') ||
(match == '[' && program[ip] == ']') )
ip = JumpTo(match, incr, ip, program);
else if (program[ip] == match)
return ip;
}
}
This made me wonder if the style of a language affects the style of its implementation. Not sure.
(For any impressionable children reading this: don’t do it this way. Use descriptive variable names and comments and put braces around your if/else clauses.)
(And for any hiring managers reading this: its deliberate, I promise.)
The Strongman Fantasy
Timothy Snyder on The Strongman Fantasy — life in the near-future Trump-style authoritarian dictatorship. The way that it starts:
We dream that a strongman will let us focus on America. But dictatorship opens our country to the worst the world has to offer. An American strongman will measure himself by the wealth and power of other dictators. He will befriend them and compete with them. From them he will learn new ways to oppress and to exploit his own people.
And the way that it ends:
Once this process begins, it is hard to stop. At the present stage of the strongman fantasy, people imagine an exciting experiment. If they don’t like strongman rule, they think, they can just elect someone else the next time. This misses the point. If you help a strongman come to power, you are eliminating democracy. You burn that bridge behind you. The strongman fantasy dissolves, and real dictatorship remains.
Most likely you won’t be killed or be required to kill. But amid the dreariness of life under dictatorship is dark responsibility for others’ death. By the time the killing starts, you will know that it is not about unity, or the nation, or getting things done. The best Americans, betrayed by you when you cast your vote, will be murdered at the whim and for the wealth of a dictator. Your tragedy will be living long enough to understand this.
SLotD: Cheap Thrills
My new hobby is reading the C# using statements that Visual Studio inserts as it tries to figure-out the dependencies for my fumbling typing.
using System.Security.Cryptography.X509Certificates;
using static Android.Media.Midi.MidiDeviceInfo;
using Android.Media;
using Kotlin.Jdk7;
using Android.Drm;
using System.Security.Cryptography;
using Android.AdServices.CustomAudiences
public class MyClass
{
It passes the time…
TakeoutExtractor v1.1
At the start of the year, as part of my general effort to minimise my exposure to Google, I ordered-up a Google Takeout and cleared-out and archived my photos and videos from Google Photos.
To this end, I’ve just released version 1.1 of Takeout Extractor over on github. This releases adds fixes for a few issues discovered during the year, including some kindly reported by other github users. It now correctly handles photos edited using the Google One add-on photo features, to which I subscribed some time back in the last year. I also updated the projects to .net 7 and did some general freshening up. As noted in the readme, this is a source-only release because publishing maui apps currently seems to be broken in Visual Studio 2022. I’ll see if this is resolved by future VS updates. For Windows and MacOS apps (sadly sans the latest fixes) see the v1.0 release
See here for some background on the project. I hope it is useful to someone.
Small Progress
& I am tired
From It’s 6 am & the Sun Is Out by KB Brookins
of making peace with small
progress being a precursor
for my death
Link, via Erin Watson
Year End
“This is what you shall do: Love the earth and sun and the animals, despise riches, give alms to every one that asks, stand up for the stupid and crazy, devote your income and labor to others, hate tyrants, argue not concerning God, have patience and indulgence toward the people, take off your hat to nothing known or unknown or to any man or number of men, go freely with powerful uneducated persons and with the young and with the mothers of families, read these leaves in the open air every season of every year of your life, re-examine all you have been told at school or church or in any book, dismiss whatever insults your own soul, and your very flesh shall be a great poem and have the richest fluency not only in its words but in the silent lines of its lips and face and between the lashes of your eyes and in every motion and joint of your body.”
Walt Whitman, preface to Leaves of Grass, via Maria Popova
Happy new year. Maybe, just maybe, although I can’t see how, 2024 might just be better less bad than the one ending. We’re all going to have to try pretty hard though.
Time to burn the dying year down and start again.