This is cool. Granted, the language presented here is absolutely horrid, but at the same time so much better than what was available at the time. The ZX Spectrum was a quirky ball of low-cost hacks (the Ferranti ULA that implemented most hardware stuff was driven beyond its intended use hard, with brilliant-yet-horrible features such as using the same pin for audio input and output...). Its BASIC lacked most features that are taken for granted these days, like control blocks: GOTO-another-line-number was the only way back in the days, and the resulting spaghetti code was... rough.
Inline assembly, which also hadn't been invented yet other than by embedding raw opcodes in DATA statements, is absolutely required to get the performance required for gaming: I still cherish my HiSoft Devpac tape (officially purchased and shipped from the UK at great expense and requiring extensive negotiations with the local customs people, for whom this entire 'software' thing was a bit new...) and Z80 assembly reference (pirated from a library with the school photocopier). So, in one sense, the limited BASIC was a blessing: it required you to really get to know your machine, which is probably the first and last time in my life that happened: I've not considered the timing implications of the CRT and optimized my code around that for a long time.
Nice to see people are still enjoying a 44-year-old platform!
I’m the author of the compiler. I started it 18yrs ago, well before AI, mainly as a PoC.
But people started to ask for more and more features …
The compiler tries hard to mimic the original Sinclair BASIC but also allows a more modern syntax similar to QBasic / FreeBASIC.
Even 40+ years later, it remains one of my favourite ever BASIC dialects. I did badly miss integer variables, but it was IMHO the most thoughtful and considered extension of Sinclair BASIC ever made.
I am a little sad that the SAM Coupé's BASIC, which Wright also wrote, has never had a FOSS clone.
Ah, the SAM Coupé, it was such a bad luck coming at the end of 8 bit home computers.
I used to do window shopping at computer store that had them in display, but they weren't worth the investment, most of my friends were slowly moving into the Amiga already, and I eventually got a PC.
I would say a bit of its ideas lives on Spectrum Next.
> I wrote most of the Wikipedia article about BetaBASIC
If you still want to work on it, add sample code. I think that’s a must for a programming language page.
I see https://en.wikipedia.org/wiki/Sinclair_BASIC doesn’t, either but at least it has a list of commands. I still prefer sample code, though. It is the better way to present things, even though it will give an incomplete overview of capabilities.
So, yeah, apparently my comment comes off a bit more negative than intended, but: absolutely great work, and the improvements make this an actually-very-usable solution for the platform.
No offense taken.
I plan to improve the compiler and add other target machines (currently it generates Z80 asm files already).
But I refuse to use AI in this side project :( Just to enjoy it for the sake of coding (you know), so some
inrovements will take some time…
Minor nitpick: inline assembly had been invented already. Indeed it had been implemented and shipped for the Acorn Atom in 1980. The Atom packed a quirky but effective BASIC with an inline 6502 assembler into its 8Kb ROM. And a BASIC with rather more features, and an inline assembler, was shipped with the BBC Micro, slightly ahead of the ZX Spectrum launch. Folks on the Cambridge scene had the chops to do better versions of BASIC, they just didn't make it into any Sinclair products until the QL. (And, a later Sinclair product, the Z88, of course, shipped with the Z80 version of BBC Basic a few years later, this time with an inline Z80 assembler.)
Even though the language is 'horrid' I have a weird attraction to it. I have been programming in various BASIC languages for more than 20 years. The last years I maintained a self developed application for my Mom in Visual Basic. Somehow I got things done in that language.
That was the same thing that any 8 bit BASIC of the era.
I have yet my books of learning BASIC (for kids), and there for ZX Spectrum, Commodore, Apple 2, etc... And only had that. The only thing that I remeber lacking compared againts other BASICs, was the ON GOTO, ON GOSUB and ELSE . On the control of flow in BASIC... That is all.
I will not see something more advanced (and without numbering the lines), like while and do loops, or select case, proper subrutines and functions, until I touch Turbo BASIC (and QBASIC)
There was a wild range in capabilities in the various BASIC implementations of that time. I grew up with an Amstrad CPC6128, it came with Locomotive BASIC (https://en.wikipedia.org/wiki/Locomotive_BASIC), which was very capable: at one point I had written a multiplayer game with background music in it, without needing a single PEEK, POKE or CALL. The few times I saw Commodore BASIC programs it was littered with those three.
IIRC the older Microsoft Basic for CP/M was significantly more powerful than ZX Basic.
This is not surprising because the Microsoft Basic was intended for computers with 8 inch floppy disks (the much larger predecessors of the 5 1/4 inch floppy disks familiar to IBM PC users), while ZX Basic had to run from a ROM with only cassette storage. Thus the former was expected to be used for bigger programs that could also process much more data.
The Microsoft Basic for CP/M was very similar to the later GW-BASIC for MS-DOS.
The advantages of Microsoft Basic that mattered for me at that time were less about any improved program control structures, but about more powerful data types, for instance double-precision 64-bit floating-point numbers.
It was, never used it, but it already suffices that it supported structured BASIC and a proper compiler.
Also to note, the original Darthmond BASIC was much more powerful than the ones on 8 bit micros due to hardware restrictions, exception to those that were good enough to run CP/M.
Similar progression path for me, with GW-BASIC in the middle.
However, I got a structured BASIC for the Speccy in a MicroHobby or Micromania magazine (cannot remember exactly), with screen editor, but naturally had the problem it would make the 48 KB memory size even smaller.
It would work better on the 128 KB models, but those lucky ones to own a 128 +3A could get hold of CP/M, with support for Mallard BASIC, CBASIC and BASCOM.
Distinction between compiled vs. interactive is important. But it becomes less relevant the shorter compile/edit/debug cycles are. The "instant feedback" aspect is what matters.
For a # of years I used a setup with all my favourite tools running from a RAMdisk. That's on MSX2/2+. Edit/assemble/debug cycles in <1 minute if so desired. There was also KUN BASIC on that platform: a JIT compiler for (a subset of) MSX-BASIC. Speedups of ~10..20x or more for many programs or -sections with near-zero effort.
And of course, all this could be freely mixed. Short snippets of machine code for speed/'heavy lifting', BASIC to glue everything together & make quick edits.
Sadly this seems to be lost on modern platforms. Despite >10,000 faster cpu's, ungodly amounts of RAM, storage etc.
That was the whole point of when Dartmouth BASIC was created.
Also one feature that 8 bit BASIC lost in the process due to their hardware limitations, was that originally Dartmouth BASIC wasn't interpreted, rather compiled into machine code before execution, a kind of primitive JIT.
Only 8 bit computers able to run CP/M got similar kinds of BASIC experience, like the original one.
I loved Sinclair Basic back in the day despite its limitations - it was my gateway drug into software and systems. When I discovered Boriel Basic a few weeks ago it allowed me relive my childhood, and finally finish making a game for the ZX Spectrum (albeit a remake):
Inline assembly, which also hadn't been invented yet other than by embedding raw opcodes in DATA statements, is absolutely required to get the performance required for gaming: I still cherish my HiSoft Devpac tape (officially purchased and shipped from the UK at great expense and requiring extensive negotiations with the local customs people, for whom this entire 'software' thing was a bit new...) and Z80 assembly reference (pirated from a library with the school photocopier). So, in one sense, the limited BASIC was a blessing: it required you to really get to know your machine, which is probably the first and last time in my life that happened: I've not considered the timing implications of the CRT and optimized my code around that for a long time.
Nice to see people are still enjoying a 44-year-old platform!
This is probably a too-wild idea, but what I personally would love to see would be to adopt the extensions of Dr Andy White's BetaBASIC.
I wrote most of the Wikipedia article about BetaBASIC:
https://en.wikipedia.org/wiki/Beta_BASIC
Even 40+ years later, it remains one of my favourite ever BASIC dialects. I did badly miss integer variables, but it was IMHO the most thoughtful and considered extension of Sinclair BASIC ever made.
I am a little sad that the SAM Coupé's BASIC, which Wright also wrote, has never had a FOSS clone.
I used to do window shopping at computer store that had them in display, but they weren't worth the investment, most of my friends were slowly moving into the Amiga already, and I eventually got a PC.
I would say a bit of its ideas lives on Spectrum Next.
If you still want to work on it, add sample code. I think that’s a must for a programming language page.
I see https://en.wikipedia.org/wiki/Sinclair_BASIC doesn’t, either but at least it has a list of commands. I still prefer sample code, though. It is the better way to present things, even though it will give an incomplete overview of capabilities.
- IF THEN
- FOR
- GOSUB / RETURN
- DEFN
- GOTO
- READ / DATA
That was the same thing that any 8 bit BASIC of the era.
I have yet my books of learning BASIC (for kids), and there for ZX Spectrum, Commodore, Apple 2, etc... And only had that. The only thing that I remeber lacking compared againts other BASICs, was the ON GOTO, ON GOSUB and ELSE . On the control of flow in BASIC... That is all.
I will not see something more advanced (and without numbering the lines), like while and do loops, or select case, proper subrutines and functions, until I touch Turbo BASIC (and QBASIC)
This is not surprising because the Microsoft Basic was intended for computers with 8 inch floppy disks (the much larger predecessors of the 5 1/4 inch floppy disks familiar to IBM PC users), while ZX Basic had to run from a ROM with only cassette storage. Thus the former was expected to be used for bigger programs that could also process much more data.
The Microsoft Basic for CP/M was very similar to the later GW-BASIC for MS-DOS.
The advantages of Microsoft Basic that mattered for me at that time were less about any improved program control structures, but about more powerful data types, for instance double-precision 64-bit floating-point numbers.
Also to note, the original Darthmond BASIC was much more powerful than the ones on 8 bit micros due to hardware restrictions, exception to those that were good enough to run CP/M.
However, I got a structured BASIC for the Speccy in a MicroHobby or Micromania magazine (cannot remember exactly), with screen editor, but naturally had the problem it would make the 48 KB memory size even smaller.
It would work better on the 128 KB models, but those lucky ones to own a 128 +3A could get hold of CP/M, with support for Mallard BASIC, CBASIC and BASCOM.
It's that you could LIST. Then move cursor up and edit and press enter. (Not found in ZX, but still ok).
Next, you could list, and draw CIRCLE over the program listing. It was live, like smalltalk, but simpler.
Reproducing language variants without immersion described above is not full story.
For a # of years I used a setup with all my favourite tools running from a RAMdisk. That's on MSX2/2+. Edit/assemble/debug cycles in <1 minute if so desired. There was also KUN BASIC on that platform: a JIT compiler for (a subset of) MSX-BASIC. Speedups of ~10..20x or more for many programs or -sections with near-zero effort.
And of course, all this could be freely mixed. Short snippets of machine code for speed/'heavy lifting', BASIC to glue everything together & make quick edits.
Sadly this seems to be lost on modern platforms. Despite >10,000 faster cpu's, ungodly amounts of RAM, storage etc.
Also one feature that 8 bit BASIC lost in the process due to their hardware limitations, was that originally Dartmouth BASIC wasn't interpreted, rather compiled into machine code before execution, a kind of primitive JIT.
Only 8 bit computers able to run CP/M got similar kinds of BASIC experience, like the original one.
https://github.com/nateProjects/adarkroom-zx
https://github.com/skx/gobasic
And later still I wrote an adventure game in Z80:
https://github.com/skx/lighthouse-of-doom
The Spectrum was how I got into programming, and despite the limitations I have fond memories.