User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Introduction to BBC BASIC

Sun Apr 14, 2019 11:34 am

(Cross-posted from the new Raspberry BASIC forum)

BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. It has since been extended and ported onto at least seven CPUs and more than thirty different platforms. Today BBC BASIC is a modern, structured, language capable of most programming tasks.

The Raspbian edition of BBC BASIC is free and open-source. It is highly compatible with the Windows, MacOS, Linux, Android and iOS editions, and generally BASIC programs will run on all these platforms with no modification, even if they use 2D or 3D graphics, sound, joystick input, file or network access etc. More than 100 example programs are supplied with BBC BASIC to demonstrate its capabilities.

Raspbian BBC BASIC needs at least an RPi 2; an RPi 3 or later is recommended for best performance. It may be downloaded as a precompiled binary in the form of a Zip file or the source code, libraries and examples may be obtained from GitHub. There is a makefile in the bin/raspi directory (the SDL2 development libraries must first be installed from the Raspbian repository).

Here are some YouTube videos which illustrate things that BBC BASIC can achieve on the Raspberry Pi:

Video games
2D graphics
3D graphics
Ceefax simulator
Sprites
Music and 3D animation
Shader programming

User avatar
rpdom
Posts: 15408
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 12:22 pm

This would be my BASIC of choice, if I still programmed in BASIC. I used to use it a lot in the 1980s and 1990s on PCs and RM Nimbus.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23883
Joined: Sat Jul 30, 2011 7:41 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 12:38 pm

Please don't cross posts from other forums, we've had quite a few posts on basic recently, we don't need this as well.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

fruitoftheloom
Posts: 20916
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 12:42 pm

RichardRussell wrote:
Sun Apr 14, 2019 11:34 am
(Cross-posted from the new Raspberry BASIC forum)

BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. It has since been extended and ported onto at least seven CPUs and more than thirty different platforms. Today BBC BASIC is a modern, structured, language capable of most programming tasks.

The Raspbian edition of BBC BASIC is free and open-source. It is highly compatible with the Windows, MacOS, Linux, Android and iOS editions, and generally BASIC programs will run on all these platforms with no modification, even if they use 2D or 3D graphics, sound, joystick input, file or network access etc. More than 100 example programs are supplied with BBC BASIC to demonstrate its capabilities.

Raspbian BBC BASIC needs at least an RPi 2; an RPi 3 or later is recommended for best performance. It may be downloaded as a precompiled binary in the form of a Zip file or the source code, libraries and examples may be obtained from GitHub. There is a makefile in the bin/raspi directory (the SDL2 development libraries must first be installed from the Raspbian repository).

Here are some YouTube videos which illustrate things that BBC BASIC can achieve on the Raspberry Pi:

Video games
2D graphics
3D graphics
Ceefax simulator
Sprites
Music and 3D animation
Shader programming

Already an open post here:

viewtopic.php?f=34&t=237562

Plus a new post for each release, would be better to just have all in one post ????
Retired disgracefully.....

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 12:58 pm

fruitoftheloom wrote:Plus a new post for each release, would be better to just have all in one post ????
I'm never too sure about that; I'm happy to take advice. Some forums behave 'strangely' if you edit the subject line (for example to reference a new version) so starting a new thread can be cleaner. Also, if it attracts followups it can be confusing if multiple releases all get discussed in the same place. But equally I can see that having isolated posts in separate threads, on effectively the same subject, could be considered wasteful.

User avatar
scruss
Posts: 2561
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:12 pm

jamesh wrote:
Sun Apr 14, 2019 12:38 pm
… we've had quite a few posts on basic recently, we don't need this as well.
In a “People keep asking for it, but there's no demand” kind of a way?

I really like what Richard has done with BBC BASIC, from being on the committee that defined it to producing the definitive open-source version.

Matrix Brandy BASIC is not quite as polished as Richard's version, but will build and run on Raspbian on all Raspberry Pis, even headless ones.

Now, if only I could find the A5 booklets (from BEEBUG?) I learned BBC BASIC from back in 1983 …
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
DougieLawson
Posts: 36316
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:21 pm

jamesh wrote:
Sun Apr 14, 2019 12:38 pm
Please don't cross posts from other forums, we've had quite a too many posts on BASIC recently, we don't need any more.
FTFY. BASIC is in the same league as Comic Sans.
Dijkstra wrote: It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

http://www.cs.utexas.edu/users/EWD/ewd04xx/EWD498.PDF
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:31 pm

scruss wrote:
Sun Apr 14, 2019 1:12 pm
In a “People keep asking for it, but there's no demand” kind of a way?
Ouch! :lol:

Thank you for your kind comments. I suppose I must have been involved with BBC BASIC, one way or another, for more than 38 years now. :shock:

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:38 pm

DougieLawson wrote:
Sun Apr 14, 2019 1:21 pm
Dijkstra wrote: It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
Fortunately BASIC has progressed a long way since then, it was after all the BBC (way back in 1980) who insisted that a fully structured BASIC - not needing GOTOs - was a requirement for their Micro. BBC BASIC is still popular for teaching programming in schools, and for some time was recommended by the Oxford, Cambridge and RSA examining board, so clearly they didn't share Dijkstra's opinion.

User avatar
DougieLawson
Posts: 36316
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:55 pm

He wasn't just attacking BASIC. He had it in for FORTRAN, PL/I, COBOL and APL. Having spent the last six months working on a mainframe COBOL project where all the code is written in French, I'm inclined to agree with all of Dijkstra's sentiments.

I wonder what he might have said about Python.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 1:56 pm

Yes but, Dijkstra's opinion was obviously based on whatever version of BASIC was the thing when he made that statement in 1975. Dijkstra had a downer on GOTO and that is what BASIC had for control flow. We have no idea what Dijkstra might have said about totally different, more modern languages that happen to have "BASIC" in their name.

Dijkstra was right of course, I was first introduced to programming with BASIC and I never did go on to become a world class coder rock star like Linus Torvalds.

Luckily they introduced us to assembler programming at the same time so all was not lost.
Memory in C++ is a leaky abstraction .

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 2:10 pm

Heater wrote:
Sun Apr 14, 2019 1:56 pm
Luckily they introduced us to assembler programming at the same time so all was not lost.
And BBC BASIC is probably the only BASIC that includes an assembler in the run-time engine (with the exception of the iOS edition, admittedly). Assembling code on-the-fly at run-time, allowing 'variables' to be expressed as 'constants' in the assembler source code, can even outperform conventional assembled-and-linked code. :geek:

jahboater
Posts: 4769
Joined: Wed Feb 04, 2015 6:38 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 3:39 pm

RichardRussell wrote:
Sun Apr 14, 2019 2:10 pm
Heater wrote:
Sun Apr 14, 2019 1:56 pm
Luckily they introduced us to assembler programming at the same time so all was not lost.
And BBC BASIC is probably the only BASIC that includes an assembler in the run-time engine (with the exception of the iOS edition, admittedly). Assembling code on-the-fly at run-time, allowing 'variables' to be expressed as 'constants' in the assembler source code, can even outperform conventional assembled-and-linked code. :geek:
Sounds great, but it must be a real maintenance nightmare :(

I mean the BBC Basic interpreter must fully implement the assembler on all the platforms it is ported to.
A duplication of effort because the assembler does it too - and that's its job.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 3:59 pm

jahboater wrote:
Sun Apr 14, 2019 3:39 pm
I mean the BBC Basic interpreter must fully implement the assembler on all the platforms it is ported to. A duplication of effort because the assembler does it too - and that's its job.
All very true: it doesn't make for easy cross-platform programming! But when BASIC isn't fast enough it makes things possible that simply wouldn't be otherwise, except by 'shelling out' to some external app.

It's particularly valuable for debugging tools, for example the supplied profiler works by running a periodic interrupt in a separate thread, something that is possible in assembler but not in BBC BASIC. The relevant module, which you can look at yourself (sdldebug.bbc in the lib/ directory) has three sets of assembler source code - 32-bit x86, 64-bit x86 and 32-bit ARM - the appropriate version being selected at run-time.

But only one of the supplied example programs uses assembler code (mandel.bbc); even though BBC BASIC is interpreted it's fast enough for all but the most time-critical applications. All those that you can see in the YouTube videos I linked to are 'pure BASIC'.

BBC BASIC is quirky in several ways: the embedded assembler is one and the low-level C-style indirection operators are another. It's probably one reason why it has survived for so long.

User avatar
rpdom
Posts: 15408
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 4:10 pm

In my days of using Richard's BBC BASIC on 286 and 386 based DOS and early Windows systems, we didn't have any assemblers, just a few simple office tools. The assembler in BBC BASIC enabled me to create a number of stand alone utilities, including TSRs and also access MSDOS INT functions from within a BASIC program. As practice I wrote a simple version of Minesweeper in BASIC with mouse support and also wrote a program that interfaced to a specialised optical mark reader - it read forms shaded in by students with their interests in order to suggest future careers for them. We had the hardware and the software that ran on the mainframe to process the data, but nothing to interface to the reader and decode the responses from it and send them to the mainframe.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 4:27 pm

Any chance of a BBC BASIC for the 32 bit RISC V? https://riscv.org/

I have a RISC V core in FPGA running here: About 50 MIPS, 64K RAM only a UART for I/O so far. If I'm lucky I'll get the 32MB SDRAM working with it. No MMU so no Linux or such possibility.

It needs some software...
Memory in C++ is a leaky abstraction .

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 4:29 pm

rpdom wrote:
Sun Apr 14, 2019 12:22 pm
This would be my BASIC of choice, if I still programmed in BASIC.
I note that you live in the UK, and are of an age to have used BBC BASIC at its peak of popularity, so that's not surprising. In parts of the world where the BBC Micro had little impact (particularly the US, where it bombed - too expensive and too incompatible with the UK model) people have often never heard of it!

User avatar
John_Spikowski
Posts: 1543
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 4:37 pm

Thanks Richard for establishing the BBC BASIC presence on the https://RaspberryBASIC.org forum.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 4:40 pm

Heater wrote:
Sun Apr 14, 2019 4:27 pm
Any chance of a BBC BASIC for the 32 bit RISC V? https://riscv.org/
The C source code of my 'generic' BBC BASIC interpreter (i.e. with the SDL2 I/O stuff omitted) is reasonably portable, although it does depend on some GCC/clang extensions (for example that sizeof(void) is 1) and intrinsics. However, and this could be a killer with some RISC architectures, it does assume that unaligned stores and loads are allowed (the -munaligned-access compiler switch is specified). If RISC V can load and store only at aligned addresses, as with the original ARMs, porting would be a major hassle.

In that event Brandy BASIC (or Matrix Brandy), which are also 'BBC BASIC' and open-source, but without many of the 'modern' extensions of mine (e.g. structures, 64-bit integers etc.) might be a better choice. I'm pretty sure they don't depend on unaligned accesses.

Heater
Posts: 13643
Joined: Tue Jul 17, 2012 3:02 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:08 pm

No worries, we will be using GCC or Clang compilers for RISC V.

From the RISC V ISA manual:
For best performance, the effective address for all loads and stores should be naturally aligned for each data type (i.e., on a four-byte boundary for 32-bit accesses, and a two-byte boundary for16-bit accesses). The base ISA supports misaligned accesses, but these might run extremely slowly depending on the implementation.
Potentially a misaligned access will cause a trap and the access performed slowly by a trap handler.

Off hand I'm not sure what the picorv32 I'm using does with misaligned access.
Memory in C++ is a leaky abstraction .

hippy
Posts: 6087
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:10 pm

There is a good analysis of what Dijkstra wrote about GOTO being harmful, and what the author thinks he was meaning here -

http://david.tribble.com/text/goto.html

For me, Dijkstra was railing against 'spaghetti code' and languages which facilitate that rather than prevent it. And he had a good point in that respect.

When it comes to it being impossible to teach good programming practice to anyone exposed to BASIC, his damning criticisms of other programming languages, I believe Dijkstra was being rather hyperbolic, deliberately 'stirring the pot'.

His assertion on his claimed "uncomfortable truths" that "nearly all computing scientists I know well will agree without hesitation to nearly all of them", is a classic use of propaganda technique; the 'everyone in their right mind agrees with me' ploy.

It got the debate going which was appropriate for where we were back then, which is what I imagine Dijkstra wanted, but unfortunately it left a legacy of something out of context and more than I believe Dijkstra intended.

That one line of what Dijkstra said, unfortunately, now often gets cited by rote by those who wish to use it as a club to denigrate Basic in its modern variants and programmers who choose to use those.

User avatar
rpdom
Posts: 15408
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:17 pm

RichardRussell wrote:
Sun Apr 14, 2019 4:29 pm
rpdom wrote:
Sun Apr 14, 2019 12:22 pm
This would be my BASIC of choice, if I still programmed in BASIC.
I note that you live in the UK, and are of an age to have used BBC BASIC at its peak of popularity, so that's not surprising. In parts of the world where the BBC Micro had little impact (particularly the US, where it bombed - too expensive and too incompatible with the UK model) people have often never heard of it!
Yup. Started with the ZX-80, then ZX-81, ZX Spectrum, Sharp MZ-80K, BBC Micro and so on. Spent a couple of years as Technical Manager for CommunITel writing Viewdata software for BBC Micro, Acorn Archimedes, RM Nimbus and IBM PC (The latter using versions of your BASIC).

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:20 pm

Heater wrote:
Sun Apr 14, 2019 5:08 pm
No worries, we will be using GCC or Clang compilers for RISC V.
By all means contact me privately if you want to attempt a port. All my versions of BBC BASIC (back to the 1982 Z80 version) have had a clear delineation between the generic 'language' modules and the platform-dependent 'input-output' modules, so in principle you shouldn't need to make any changes to the core interpreter. I can give you details of the bare minimum I/O support you would need to provide to get something running.

If you have only 64K RAM available that will compromise support for 'huge strings' (normally 64K is set aside for the 'string accumulator' alone) but I can probably guide you around that.

jahboater
Posts: 4769
Joined: Wed Feb 04, 2015 6:38 pm

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:23 pm

Heater wrote:
Sun Apr 14, 2019 5:08 pm
No worries, we will be using GCC or Clang compilers for RISC V.
The option has a different name for RISC-V

Code: Select all

   -mstrict-align
   -mno-strict-align
       Do not or do generate unaligned memory accesses.  The default is set depending on
       whether the processor we are optimizing for supports fast unaligned access or not.
I presume if you select -mstrict-align GCC will "break up" large misaligned items and write them out as individual bytes.
Last edited by jahboater on Sun Apr 14, 2019 6:18 pm, edited 1 time in total.

User avatar
John_Spikowski
Posts: 1543
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Introduction to BBC BASIC

Sun Apr 14, 2019 5:31 pm

In that event Brandy BASIC (or Matrix Brandy), which are also 'BBC BASIC' and open-source, but without many of the 'modern' extensions of mine (e.g. structures, 64-bit integers etc.) might be a better choice. I'm pretty sure they don't depend on unaligned accesses.
I'm using Brandy's SDL BBC BASIC graphic library module with ScriptBasic which seems to work okay.

Return to “Other programming languages”