Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're interested in BASIC, there's an open source BBC Basic V interpreter:

https://sourceforge.net/projects/brandy/

(Also in Debian.)

BBC Basic is one of the best BASICs ever, featuring things like named procedures with local variables, structured programming, etc. Basic V, which Brandy simulates, is effectively Comal.

But you don't have to use any of that stuff if you don't want to, and all the old favourites like GOTO, GOSUB, ON GOSUB etc still exist. (Along with a handy RENUMBER command for when you run out of space between lines 140 and 150.)

I recently found an ancient program I wrote as a teenager in BBC Basic II --- I'd submitted it to a computer magazine to be printed in an issue (and then they rejected it). If you want to know what BBC Basic II looks like, here's an example.

http://cowlark.com/2015-02-03-bbc-micro

Edit: cut-n-paste tyop.



Wikipedia mentions that "One of the unique features of BBC BASIC was the presence of an inline assembler"; how does Brandy deal with that? Does it offer inline x86 asm, or does it emulate classic 6502?


Good question --- I just looked it up. Alas, no, it's not implemented at all. It doesn't even support CALL (but it does support BBC Basic's equivalent of PEEK and POKE).


"I agree BBC BASIC is excellent, particularly in having structured programming support."

Found this in the article comments. What happened to the BBC BASIC language? Is it still available, in source?


Well... the original BBC Basic was originally hand-written in 6502 assembly for the BBC Micro; it's a 16kB application ROM. Later versions were rewritten for the 65C102. The extra opcodes available freed up some space and they added a few more features, and made it even faster (and BBC Basic was already one of the fastest 8-bit Basics around). I don't believe that any of the 6502-era Acorn sources were ever released, which is a shame, as Acorn's MOS was one of the best 8-bit operating systems around.

Basic V was a complete rewrite for the ARM. In hand-tooled ARM machine code, also by Sophie Wilson. The source for this is available from the CVS archive here: https://www.riscosopen.org/content/downloads/cvs-access But trust me, it won't help. I've debugged my way through it. It's very... hand written.

Oh, yes: there are also ports of BBC Basic IVish to the 8086 and the Z80 by R.T. Russell: http://www.bbcbasic.co.uk/bbcbasic/bbcbasic.html He wasn't associated with Acorn, as far as I know. The 8086 version (for Windows and DOS) is commercial, but the Z80 version (for a variety of CP/M machines) is a free download. Not open source, unfortunately. His version even includes 80186 or Z80 inline assemblers, depending on the version. His Z80 port was licensed for a variety of machines --- Amstrad made a range of Z80 notebooks with his Basic in ROM. I've used all his versions, and they're superb.


Locomotive BASIC - which was shipped on the Amstrad CPC range of micro computers - was heavily influenced by BBC BASIC. It made switching between the CPC 464 and BBC Micro really easy.

The other variation of BASIC I used a lot in the 80s was Microsoft BASIC on the Commodore 64.

dim personalopinion$ = "Frankly I think the C64 was over hyped. Sure it had the popular MOS 6510 rather than the Z80 as used by the BBC Micro and Amstrad CPC range, but the Amstrad CPC had a more vibrant display, built in cassette player and, most importantly to me as a programming kid in the 80s, a far superior port of BASIC than Microsoft BASIC was."


"The source for this is available from the CVS archive here: ... But trust me, it won't help. I've debugged my way through it. It's very... hand written."

First computer ZX80, so I missed the BBCM.

Thx @David, the reason I asked was I was interested to see ^how^ it was written, but probably more to the point, what made it good? Sounds like speed was a loved feature. Was there ever a API or documentation made public?

Reason: want to hack a language together a BASIC-like language (are of use) for graphics.


Well, there's an annotated disassembly here:

http://acorn.huininga.nl/pub/docs/sourcecode/Acorn/BASIC%202...

AFAIK there wasn't anything particular magical about it --- it was just written well, with great care. Programs were stored in tokenised form, where each keyword was reduced to a byte, and line numbers in things like GOTO statements were stored preparsed, but execution happened directly from the tokenised form. Named procedures were faster than GOTOs because the interpreter would cache the address of the line where they were defined, while GOTOs would have to search for the line; variables were stored in a hash table; there were two stacks, one for GOSUBs and one for PROCs (the GOSUB stack was much smaller!); there was a superb 5-byte floating point library...

It's also worth mentioning that Acorn's MOS was in a different ROM, so it didn't have to share space with Basic. The two communicated via a system call interface. I've seen people run BBC Basic on entirely different 6502 machines by reimplementing the system call interface.

I would not recommend writing this style of Basic if you want a simple language these days. Basics are a nightmare of ad-hoc parsing with too many edge cases. Better to write a modern byte-compiled language with a byte interpreter --- you'll end up with something much cleaner and easier to understand. We're not all Sophie Wilson.


"I would not recommend writing this style of Basic if you want a simple language these days. Basics are a nightmare of ad-hoc parsing with too many edge cases. Better to write a modern byte-compiled language with a byte interpreter --- you'll end up with something much cleaner and easier to understand."

thankyou for these suggestions.

"We're not all Sophie Wilson."

agree, very talented individual.


> want to hack a language together a BASIC-like language (are of use) for graphics.

One of the coolest ones was AMOS for the Amiga.


Now I see why BBC BASIC is liked.

It was created by Sophie Wilson FRS FREng, while at Cambridge as a student over a summer break on a 6502 micro processor. Wilson also designed the Acorn System 1. [0],[1] Also a portable C version of BBC BASIC is available. [2]

[0] https://en.wikipedia.org/wiki/Sophie_Wilson

[1] https://en.wikipedia.org/wiki/Acorn_System_1

[2] https://en.wikipedia.org/wiki/BBC_BASIC#cite_note-11 and

http://mdfs.net/Software/BBCBasic/


The port of RISC OS for Raspberry Pi contains a BBC BASIC interpreter:

https://www.raspberrypi.org/blog/risc-os-for-raspberry-pi/

I think you hit F12 and then type 'basic' (no quotes) at the prompt to get to it.


thx @Fr0sty I'm mighty impressed with the RISCOS effort. You can even purchase dev manuals in print. Must fire this one up on a Pi at home. This would be a good start.


It's part of RISCOS, so yes.


Try TurboBasic / QuickBasic




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: