8 minute read

The best version of BASIC

by Robin Jubber

For a great many games coders, especially the older generation of this young industry, the BBC User Guide, explaining the BBC BASIC language, was our Bible. I have two or three original User Guides in my house, just in case I lose my primary copy. They’re all falling to pieces after thirty years of service.

Advertisement

I’m a games programmer in my 40s, and like almost every games programmer in their 40s, my first introduction to programming began with BASIC. Every 8-bit micro from the mid-70s onwards had a variation of this influential language built into the hardware, with varying degrees of implementation success. Since those days I’ve been lucky enough to program in C and C#, unlucky enough to program in languages like C++ and PHP and cursed by the gods themselves to dabble in the horror shows that are Objective-C and Lisp. And those aren’t even the worst languages out there. Some of the languages I’ve coded in no longer exist, or were exclusive to one company or even one game. Others, like C, have declined a little in popularity over the years, but still influence all the new languages, by lending familiar syntax to platforms like Java and C#. But long before I encountered pointers, classes and memory management, I, like all my contemporaries, started coding in Beginners All-purpose Symbolic Instruction Code, a language first invented more than half a century ago.

Microsoft cornered the BASIC market for a long time, with the version that Bill Gates and Paul Allen created for the Altair in around 1975. This 8K language rom ended up in many flavours of machine back in the 70s and 80s, including Apple, Commodore, IBM, Tandy, Atari and CP/ M computers. Despite its primitive nature, the implementation was a safe bet for garage companies building kit computers and even established hardware manufacturers turned to Microsoft. MS Basic was in essence the bedrock for the entire Microsoft company we know today.

Not every computer manufacturer subscribed to the MS

The BBC Micro home computer

monopoly of course. My first exposure to any form of programming was struggling to construct simple Basic programs for the Sinclair Spectrum at school. Sinclair Basic was a pretty poor version of the language, due in no small part to being limited by the Spectrum’s one key input system and unsophisticated editing environment.

The Spectrum’s hateful rubber keys were also a profoundly limiting factor. Try typing in a Spectum program using the original keyboard – it’s shockingly difficult. Other manufacturers were also experimenting with their own versions of the language, for instance Atari Basic for the XL, Wozniak’s Basic for the Apple II and Tiny Basic, which somehow fitted a functional version of the language into just a couple of kilobytes.

Luckily for me my first personal computer was a BBC Micro – a truly remarkable machine that dominated the UK education market but saw only limited success outside these islands. I have to assume my dad sold a kidney to

Sophie Wilson – designer of BBC Micro and ARM chip

set the world on fire, but to be able to write full screen games using an interpreted language wasn’t something you could do on any other machine. Sophie Wilson based her version of BASIC on Atom Basic, from an early Acorn machine, along with key changes brought in from languages like COMAL and Pascal. These included proper structural programming features – most notably functions, procedures, repeat loops, if-then-else construction and an assembler built directly into the language. These features were remarkably forward thinking at the time and certainly ensured that young programmers lucky enough to have access to an Acorn machine were well served when they started computing courses and needed to understand proper structure. It may help explain why the UK had such a presence in the early in pretty much every school in the country. pay for the machine. That was fine by me as long as I got

BASIC code without using GOTO and GOSUB commands. to play Elite and shoot some Thargoids.

The BBC Computer Literacy project was designed by the UK’s public broadcasting corporation to introduce both children and adults to the brand new world of home computing that was opening up at the start of the 1980s. Part of the literacy project involved finding a computer manufacturer who could build an all-purpose machine that would spearhead the television programs associated with the project. A number of manufacturers, primarily in the UK, raced to build a machine that would become the official BBC microcomputer. Acorn Computers, which had started a few years earlier in Cambridge, would become the eventual winner, due in no small part to the powerful and comprehensive version of BASIC incorporated into the machine. The BBC wanted a language that could do everything, would be well structured, and allow users to access the huge array of specialised input and output systems on the machine.

The language was designed and implemented by Sophie Wilson (Roger Wilson at the time) - a British computer scientist who would go on to have an unparalleled career. Sophie Wilson is a name to remember – she was one half of the team that went on to design the ARM RISC processor, which initially sold as a coprocessor module for the BBC Micro. The ARM chip can be considered a pretty impressive legacy of the BBC Micro, with more than 100 billion manufactured. There are probably two or three right next to you now, hidden in every conceivable electronic device on your desk. One of the stated aims for the ARM chip was to run BBC BASIC at the same speed the original 8bit micro could run assembler. It’s fair to say Sophie Wilson knocked that objective out of the park. The ARM was fast. BBC Basic V, the version she made for the Archimedes range of machines, would entirely fit inside the cache of later ARM chips ensuring main ram was rarely accessed by the interpreter. This of course made a very fast language even quicker and was one of the reasons so many multitasking desktop apps on the Archimedes V back in the day. The games themselves may not have computer games industry as BBC Micros were available

On other machines you couldn’t really write complex could easily be written in BASIC instead of C or assembler.

These were hard coded jumps in the codebase that forced execution to move to a new area of code. However they made the code inflexible and hard to maintain or understand. GOTO does have its place in programming, especially in error trapping, and isn’t quite the code villain it has traditionally been painted, but it’s a very low-level command. GOTO essentially acts like a branch instruction in assembler, forcing the processor to jump to a new memory location. The big problem is that just by looking at a line like 10 GOTO 90 you’re none the wiser about what you might expect to find at line 90, which would in turn have to jump elsewhere with another GOTO. This leads to spaghetti code and a coding style that doesn’t extend well to larger projects. With BBC Basic, the GOTO and GOSUB commands were entirely unnecessary. You could instead write PROC_Draw_Square or FN_Root(10), which makes the code far easier to parse and modify.

I still use BBC Basic today, especially when I’m writing a side project for an older machine like the Vectrex. I can have a BBC emulator running on the desktop to use as a scratch pad for simple coding experiments or generating look up tables in a format the Vectrex will understand. I have even used BBC Basic to generate table data for

I actually had a couple of commercial games on the Arc released that were almost entirely created in BBC Basic

JSBeeb – an amazing online BBC emulator

games running on much more powerful hardware, such as the PSP – it’s just a handy tool to have lying around. The editing environment is as powerful and easy to use as I remember from the 1980s and I would strongly recommend fans of 8-bit machines load up JSBeeb (written by a friend of mine called Matt Godbolt, another coder who got started on BBC Basic) to get a taste of what programming in this very immediate environment felt like. Not only could you copy sections of the screen into new lines, you also had trace functionality, sophisticated line renumbering tools, the aforementioned assembler that could be called from within BASIC (and use BASIC functions and constants) and complete control of the BBC Micro graphics capabilities. Other versions of Basic had no graphics or sound commands, with PEEK and POKE required to drop values into individual areas of memory and trigger chip functionality. It is fair to say that BASIC on the C64 was barely useable, which meant many aspiring young coders of the era were denied access to the Commodore machine’s impressive graphics and sound chips. BBC Basic has had a storied history, ending up on Amstrad, Sinclair, Windows, Archimedes and Texas Instruments platforms to name a few. It’s even still doing actual work, when almost every other version of BASIC (with the honourable exception of Visual Basic) has long since disappeared. A couple of years ago my brother, who ran a sweet shop at the time, was having trouble with his Point of Sale machine. I took the computer apart, loaded up the code that was crashing, and discovered to my amazement it was running a modern version of BBC Basic.

Needless to say that made it particularly easy to fix. It also means that somebody out in the business world is still getting away with writing commercial software using a language he first learnt as a child. That unknown coder

is my kind of hero.

External links

• Acorn Computers https://en.wikipedia.org/wiki/Acorn_Computers

• BBC Basic http://www.bbcbasic.org • Microsoft Basic https://en.wikipedia.org/wiki/Microsoft_BASIC

• Tiny Basic https://en.wikipedia.org/wiki/Tiny_BASIC • Elite per BBC Micro https://en.wikipedia.org/wiki/Elite_(video_game)

• Sophie Wilson https://en.wikipedia.org/wiki/Sophie_Wilson • JSBeeb: online Acorn BBC emulator https://bbc.godbolt.org

• Antigrav, one of Robin's games for Archimedes http://www.apdl.org.uk/apdlpd/library/files/g/ g131.zip • Fred The Needle, another Robin's game fully written with BBC/Electron's BASIC https://jubberbbcmicro.webnode.com/fredtheneedle/

• Chip ARM's history - from Acorn to Apple https://www.telegraph.co.uk/finance/newsbysector/ epic/arm/8243162/History-of-ARM-from-AcorntoApple.html