Show HN: I wrote a BASIC interpreter that boots on UEFI machines

tarjan.itch.io

154 points by Gorsefound 4 days ago


I started writing Thoreau BASIC because I wanted a small, old-fashioned BASIC interpreter: line numbers, immediate mode, simple graphics, strings, arrays, the sort of environment where the computer starts with a "Ready" prompt and you can immediately make it do something.

Then I wondered: why should it need an operating system?

So I made it boot directly on x64 machines using UEFI.

The UEFI version uses the Graphics Output Protocol for its framebuffer and gets its keyboard input directly from the firmware. There is no Windows or Linux underneath it. The machine boots into BASIC.

It supports the usual BASIC machinery plus graphics primitives, 32-bit colour, floating point, file operations and other features I've been adding as I encounter programs that need them. There is now also a Windows version, which makes it considerably easier to try.

One of my goals is compatibility with the style and behaviour of old Microsoft BASICs rather than creating a modern language that merely happens to use BASIC syntax.

I'm currently porting my text adventure Pixel Prose to Thoreau BASIC. That's becoming a much better test suite than artificial tests because every missing feature or subtly wrong behaviour eventually gets exposed by an actual program.

The project is deliberately small. The UEFI version greets you with:

"I make myself rich by making my wants few." — Henry David Thoreau

followed, somewhat ironically on a modern PC, by something like:

27,340,685,312 bytes free

I'd be interested in hearing from people who wrote BASIC in the 80s/90s, interpreter/compiler people, and anyone sufficiently strange to still find a Ready prompt inviting.

glimshe - 3 days ago

This is a great project. How do you handle saving/loading data? You mentioned file operations but you need some sort of file system - perhaps FAT32 - to support that. I'd need that to consider using it on UEFI.

One thing you could use for more test cases is the book 101 BASIC Computers Games by David Ahl. Games always encouraged people to use computers and that's as classic as it gets!

JoeAltmaier - 4 days ago

Very cool! The raw-metal boot part is impressive.

BASIC requires more support than you'd expect. Here's an interpreter, with a similarly long list of features it has to support:

https://www.moondew.com/basic/index.htm

roryirvine - 2 days ago

Not FOSS? That's a real pity.

I learned to program on 8 bit micros, and created a rough boot-to-BASIC experiment ~15 years ago following the JeOS pattern. So this project sounds really exciting, but I'd be more interested if I weren't restricted to being a passive end user.

jonjacky - 15 hours ago

What hardware have you run the UEFI version on?

Can you assume that pretty much any computer these days provides UEFI firmware that supports ThoreauBASIC, or might some computers provide only a cut-down UEFI that doesn't provide all the functions you need?

Is there some way to investigate the UEFI implementation on any computer? Can you get to the UEFI shell on any computer somehow or is the UEFI shell a separate application you have to download from somewhere and install?

I realize these questions are getting far afield from what you wanted to tell us about, but UEFI is still kind of a mystery despite being installed almost everywhere -- it's hard to find explanations about it.

dlcarrier - 4 days ago

I learned to program on the Commodore 64 and in QBASIC in th 90's. I'll give it a try.

Considering how much it supports, if it could chainload a full operating system, it would make a great replacement for GRUB or rEFIt.

Rygian - 2 days ago

"The machine boots into BASIC" :-)

I was 8 or 9 years old when the ZX Spectrum +2 arrived home.

I'm seriously considering installing this on an old laptop and giving it to my son when he's 8 years old, together with a hard-copy of a BASIC reference and a few simple programs and games to type in.

Getting a FAT32 filesystem on day 1 is already a huge jump from my childhood experience (loading from tape).

polaris64 - 2 days ago

I really like this! I started a personal project a long time ago to boot a Raspberry PI into an environment like this, the idea being to bring back the good old days of the ZX Spectrum, Amstrad CPC, Commodore 64, etc. I had to abandon the project but seeing this makes me want to resurrect it.

trashb - 2 days ago

This is great! Allowing anyone to program like it is the 1980s and bring them back to their hardware somewhat. I think it will also find it's way to the permacomputing crowd since UEFI is so ubiquitous these days it may be a good platform for that can offer modern features with a understandable interface.

ale42 - 2 days ago

Great, nice project! In the time of Electron bloat, it's really refreshing to see bare-metal UEFI stuff.

sras-me - 2 days ago

I am on a similar quest with https://hackage.haskell.org/package/spade

But it is not bare metal yet and it is not BASIC.

jonjacky - 3 days ago

Very nice! I am curious how you built your BASIC as an EFI application. I didn't find any source code or build instructions in the downloads.

I am investigating whether it would be feasible to do something similar for Python.

saidnooneever - 2 days ago

this is actually a really cool project been thinking of something like this ever since i saw a dudes Pascal (amd64) uefi loader and OS project

looks like a lot of fun to explore and learn from thank you

dragonfax - 2 days ago

I know at least old Apple systems had a full Forth interpreter in their bootloader.

scotty79 - 2 days ago

You should put it on bootable USB stick.

- 4 days ago
[deleted]
vancekai - 15 hours ago

[dead]

andrewww95 - a day ago

[flagged]

- 2 days ago
[deleted]
wahid_seddiqi - 2 days ago

[flagged]

timonoko - a day ago

Off-topic, but some average AI would have made all this in 7 seconds.