Show HN: I wrote a BASIC interpreter that boots on UEFI machines
Comments
scotty79
JoeAltmaier
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:
glimshe
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!
WalterGR
> How do you handle saving/loading data?
The linked page has this to say:
"Disk I/O — SAVE, LOAD, MERGE, FILES, KILL, running directly on the UEFI Simple File System."
Gorsefound
That's right. It uses UEFI's FAT32.
fuzzfactor
If you have a PC mainboard whose UEFI supports NTFS, does that filesystem work too?
skrellm
> If you have a PC mainboard whose UEFI supports NTFS, does that filesystem work too?
Yes. The UEFI Simple Filesystem Protocol is transparent to the UEFI app. The protocol gives you open/read/write/close calls, without needing to know the underlying fs.
roryirvine
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.
skrellm
I agree, it's a shame it's not FOSS.
Besides UEFI, it has a Windows GDI port, but if it were FOSS one could add SDL backend for example and then one could compile it for Linux and Webassembly as well.
dlcarrier
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.
skrellm
> it would make a great replacement for GRUB or rEFIt.
edoceo
What's wrong with those bootloaders? Maybe try syslinux?
Gorsefound
That's an interesting idea. :-)
Rygian
"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).
StilesCrisis
As a parent who had a very similar experience growing up, I've tried putting BASIC in front of my young kids. It didn't work at all; the magic just isn't there anymore. If you've got an iPad, there's unfortunately no wonder in "I can make the computer do whatever I want". Also, kids know how modern computers are supposed to look and feel, and BASIC won't get them there.
Sorry.
alnwlsn
That's a shame, I'm quite a bit younger than both of you and this is exactly how I learned to program. When I was a kid, computers were icons and a mouse, with no indication of how they worked or how you would go about making them do whatever you want. But I found a bunch of old BASIC books in my school library; the kind of computer in there had no icons, but very much encouraged you to program it. It took me a while to find one of those computers (but not as hard as it is now, they were literal trash back then), but I was hooked once I did.
Modern tech has a huge barrier to entry if you know nothing about it. I didn't even know what "install a program" was at the time, before soon learning it means "get in trouble" for messing up the (one) family computer.
raverbashing
That sounds more like an opportunity to rethink how a new beginner language for modern computers should look like
(Maybe something more like Hypercard I guess - or something that renders to HTML)
unrented7977
That's why they made Scratch, which seems to have been fairly successful
skrellm
Visual programming is not for everyone. I have two kids, one loves Scratch, the other despises it.
Fun fact, Scratch wasn't the first iteration of visual programming, and one could argue that Lego NXT was even more successful. https://www.nxtprograms.com/help/learn.html
polaris64
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
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.
sras-me
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.
ale42
Great, nice project! In the time of Electron bloat, it's really refreshing to see bare-metal UEFI stuff.
fuzzfactor
Looking at the download sizes:
UEFI "native" 114kb
Windows version 1.4mb
VHD version 12.6mb
None of them are huge but it does emphasize how much difference in resource savings is available if your program can run directly on "bare metal" without even an OS at all.
convolvatron
UEFI supports device discovery, TCP/HTTP, transfers to raw disks, filesystems, memory management and a bunch of other facilities. while it lacks a general process model and multitasking, I'm not sure its really correct to call UEFI programs bare metal.
skrellm
> I'm not sure its really correct to call UEFI programs bare metal.
I think you can. UEFI is a firmware which comes with the hardware, stored on the motherboard. It's there and automatically runs when you turn on your machine.
It's okay to consider the firmware part of the "bare metal", IMHO.
ale42
Not sure why the Windows version would be much bigger than the bare metal one. If you use native code, the code size overhead from using native GDI calls to draw the window is almost zero. Didn't check if the Windows version uses some GUI toolkit that inflates the size.
skrellm
> Not sure why the Windows version would be much bigger than the bare metal one.
That's probably because there's a bug in the linker, which puts uninitialized variables in the data segment instead of bss. This means unlike the bare metal variant, the Windows executable is full of zeros.
This is a well known bug (see https://github.com/msys2/MINGW-packages/issues/18612 for example) which also affects my projects: https://gitlab.com/bztsrc/skandi The Linux CLI version is 216K, the Windows CLI version is 5.4M and the only difference is the lack of bss.
saidnooneever
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
jonjacky
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.
Gorsefound
It's C code compiled with MSVS. Not sure about a FOSS release yet. I'm still in the early stages of experimenting.
shakna
Not the author.
But binding micropython and posix-uefi is a weekend project. [0]
NegativeLatency
Maybe the embedded python flavors would be a good fit?
dragonfax
I know at least old Apple systems had a full Forth interpreter in their bootloader.
Someone
OpenFirmware, developed by Sun, used by Sun, Apple, IBM and ARM, according to Wikipedia (https://en.wikipedia.org/wiki/Open_Firmware)
You should put it on bootable USB stick.