Coding a new BASIC interpreter in 2025 to replace a slow one

nanochess.org

81 points by nanochess 3 days ago


____tom____ - a day ago

For those interested in BASIC, here's "A curated list of awesome BASIC dialects, IDEs, and tutorials":

https://github.com/JohnBlood/awesome-basic?tab=readme-ov-fil...

It's not as popular as Python, obviously, but that lists over fifty implementations of BASIC.

codazoda - a day ago

I applied for a job about 12 years ago where the company was still using BASIC for some of their software. If I remember correctly it was numbered BASIC, not the more modern stuff. I think the software was doing some type of accounting—stuff that worked and they didn't want to change.

3036e4 - 16 hours ago

There is a chapter in the Blue Book about how the GW-BASIC byte code is structured, and from what I understand it used pointers to lines, not just offsets? But I did not look too carefully (guess the answer is in the source code: https://gitlab.com/tkchia/GW-BASIC).

That book is full of interesting facts and fun low-level tricks for (GW-)BASIC programming. Available for download here: https://github.com/robhagemans/hoard-of-gwbasic

Before reading that I never considered how primitive early BASICs were. There is a lot of linear-searching for things (variables, line-numbers) that has to be considered when optimizing.

wkjagt - 11 hours ago

Oscar Toledo (nanochess) is one of my personal heros. And one of his books, Boot Sector Games, is one of my favorite books. Seeing him post something like he just did gives me a kind of joy that is becoming pretty rare on the internet these days, for me at least.

Joker_vD - a day ago

> I discovered the pointer to the next line wasn't a good idea, because it needed to move every pointer after a line insertion.

Huh? Don't you need to only change the "next-line-pointer" for the line that's right before the inserted line?

> but the NEXT changed the line, but on the next statement it would lost track and get back to the line following the NEXT. The loops also require their own stack, but including the counter variable address, a pointer to the TO expression, and a pointer to the STEP expression (5 words in total).

Mmm. IIRC, usually the compiled NEXT statement would store the pointer to the corresponding FOR statement, so you don't need an additional stack for loop depth during the execution. But you still need it (or some other sort of chaining) during the program input so whatever.

> Typing the program was difficult, as the keyboard bounced a lot. This happens when you read too fast the keyboard, so fast you can see that effectively the key contact isn't perfect.

Yeah... I've read that keyboard microcontrollers has to deal with contact bounce even today.

analog8374 - a day ago

I love basic

Can you OOPize it?

bluedino - a day ago

I always wondered if any engineers suggested changes to make some BASICs faster and the companies didn't want it competing with "real" software