Was Locomotive BASIC significantly better than Sinclair BASIC?
TL;DR: Oh, yes, it was!
I'm aware that both Basics were more advanced than the C64 Microsoft implementation,
Comparison of C64 BASIC to other BASICs of the same time is never in favour for the C64, as it's a quick port of the original 1977 PET Version.
but neither [Locomotive BASIC, BBC BASIC] had the subroutine functions or other niceties of BBC BASIC.
While Locomotive BASIC differs in some parts, it is quite close to BBC Basic - in functionality and due to history - while offering many improvements over BBC BASIC.
In what ways did Locomotive BASIC significantly improve the language when compared to Sinclair BASIC, for example on the 48k or 128k Spectrum?
Sinclair BASIC, developed by Nine Tiles in Cambridge is a rather conventional BASIC, based on the standards set by Microsoft regarding functionality. The Spectrum version is a straight evolution from the 4 KiB BASIC of the ZX80, over the 8 KiB ZX81 BASIC, which grew out of the FP version for the ZX80, to the 16 KiB Spectrum ROM. In fact, its development had much in common with the way Commodore BASIC evolved. Much like Tramiel, Sinclair's focus was on the product to be sold - with a core point about cramping as much functionality in at a given cost point.
Unlike Tramiel, he could be convinced by his developers about necessary improvements - like doubling the ROM size for the Spectrum to cover new functionality. Still he didn't give them a go for a real redesign, while adding much time pressure(*1), resulting in untidy and slow code, while at the same time missing essential functionality - to be fixed with the shadow ROM of the Interface 1 (*2).
As a result, Sinclair Spectrum BASIC is a straightforward standard BASIC with additions to handle
- Screen (
- Colour (
- Graphics (
- SOUND (
- File I/O for microdrives (
Plus the quite helpful
BIN to enter binary numbers for graphics.
for example on the 48k or 128k Spectrum
Above is true for the original 48 KiB Spectrum as the 128 is a beast of its own - well, when not looking at all the unfinished features :))
Locomotive BASIC in contrast is a newer development based on the BASIC for the Z80 tube. Development started for a proposed but never released Z80-based business system by Acorn. It was thus heavily influenced by Acorn/BBC BASIC. It's last incarnation is Mallard BASIC for the PCW.
It is said that it was Locomotive Software's request that changed the CPC design from using a 6502 to be Z80-based. Amstrad agreed, as it would save quite some cost in software development (*3). As a result, Locomotive Software delivered most system software for the CPC, including AMSDOS.
Listing everything where Locomotive BASIC is enhanced over standard BASIC would go way off-road - much like doing the same for BBC BASIC. But comparing the latter two is an interesting point, due to their common origin. Here Locomotive BASIC improves a lot of the rather awkward parts. For example, most of the cryptic
VDU commands in BBC BASIC have nice keywords in Locomotive BASIC. Of course hardware-related issues will differ - like screen modes, colour numbers or coordinates - as they did on almost any machine back then.
Comparing two BASICs is, to some degree, up to taste and opinion - as many articles show. For a somewhat objective approach it has been proven useful to see what effort it is to port/convert a program between two BASIC dialects.
When porting BBC BASIC programs to Locomotive BASIC, only the BBC's approach to (somewhat) structured programming is a hurdle. While
FALSE can be replaced by
REPEAT ... UNITL replaced by
WHILE ... WEND with an inverted test, the mentioned PROCedures are missing at all and needs replacement by classic parameter passing and
Porting the other way around is way more challenging, as Locomotive BASIC added a lot of directly accessible functionality. It not only made screen handling much more readable, it also added basic functionality which would need large code sections or assembly routines in BBC BASIC. For example, the timer handling as mentioned by Stephen Kitt, but also really comfortable sound management, including queue management, text windowing and much more.
While BBC BASIC has an advantage with the mentioned PROCedure in structuring, Locomotive and BBC are quite feature rich BASICs of their time and in general on par with Locomotive being the richer of both - no wonder, given it being the newer of both.
Sinclair BASIC on the other hand is a much more simple implementation than either. It does cover the basic functionality of its machine quite well, due to fitting commands, while missing innovation on the BASIC side.
*1 - Again, as the same already happened with the ZX81 ROMs resulting in the infamous square root of .25 bug for the first series.
*2 - A nice twist of history here is, that Sinclair never owned the rights to the original ROMs, just the shadow ROM patches. So Amstrad had to buy them from Nine Tiles later on.
*3 - Back then BASIC interpreters, and next to all other system software, was written in Assembly, making the choice of the CPU to be used reliant on more than just speed and chip cost.