Makers of the Sincalir Sprectum computer. Now that brings back memories
The 80's are so now, as hot on the heels of the RISC OS' Raspberry Pi debut comes the equally retro-tastic news that the BASIC version used in the Sinclair ZX Spectrum can also run on the Pi. The BASIC in question is SpecBAS, is a project run by a chap called Paul Dunn. Full Pi support came to the project with the recently- …
Makers of the Sincalir Sprectum computer. Now that brings back memories
Seriously, what the hell is the point.
a) It can be done.. The root of all evil, but in this case rather innocent.
b) Nostalgia. Quite a few of us commentards started out on/with this kind of BASIC, or one of it's contemporaries.
c) Education. There's several ways BASIC can be used to teach logical and programming concepts to kids who otherwise have trouble grasping said concepts *because* of it's linearity, limitations, and relative simplicity.
d) FUN. Which concept may have eluded you lately. Go get some. It's healthy.
It seems obvious to me that the point is to spend hobby time writing a BASIC interpreter that will no doubt be used by some for fun.
In fact, that's exactly the kind of thing that would stand out on a CV from an application for the developer positions I am try to fill.
Why would anyone want the inferior Spectrum BASIC on a Pi when you can have the full BBC BASIC experience via the RISC OS port. Unless its so Speccy owners can cry themselves to sleep all over again, because they parents couldn't afford a BBC Micro.
Just because you can do a thing doesn't mean you should.
If you want Nostalgia then go and get an emulator, this isn't Nostalgia as it's not Sincalir BASIC at all, it's something else with the Spectrum Basic name on it.
Education? Are you kidding me? BASIC is not a great language to teach programming concepts, especially Sinclair BASIC!
and then FUN. Ah yes, I do remember that, and this may be fun for the person who is writing it but this as you know is subjective. So you could also say it's fun to criticize (correclty) someone writing Sinclair BASIC with a view that its Nostalgic, Education and ... well... because it can be done.
Only a couple of years ago I needed to generate a load of very similar HTML pages. I could have used a proper language but the project was so simple that it was much faster to do in the ultimate procedural language where syntactic errors were flagged up 'in flight'.
Object orientated coding is not optimal for quick & dirty one-offs. IT 'professionals' sometimes forget that.
It's fine to teach simple programming, especially Structured with procedures. The OOP stuff can come along later when the basics (pun half intended) have been learnt.
Anything that can possibly catch the imagination of a learner is a good thing that can lead onto more afterwards. I believe it's a fallacy that BASIC somehow 'corrupts' a would-be programmer's mind. If one has any aptitude whatsoever one will soon appreciate better ways of doing things as one gains experience.
Now how about COBOL and FORTRAN support to amuse all those old banking coders whose jobs have gone to India.
If you like BBC Basic, check here:
This is the same version of BBC Basic that the Z88 and NC100, NC200 ran and it's pretty damn good (for a Basic). It even includes Z80 inline assembler. There's a vanilla CP/M version, so you can run it on your old Amstrad PCW if you want (and you know you want to).
And, of course, it has been exquisitely hacked and munged to run on the Spectrum. http://mdfs.net/Software/Spectrum/BBCBasic/
R.T. Russell produce a Basic for DOS, that's equally good (inline 80186 assembler! Be afraid) and a Windows version which I have no experience of, but it's apparently Basic 4 compatible. But they're commercial. (I have no idea how you can manage to make charging thirty quid for a pretty crappy Basic by today's standard viable, but there you go.)
If you're a Linux user, try 'apt-get install brandy' for an open source version.
Well Fortran, as it has been spelt for 20+ years, is probably there as the gnu compiler collection contains a fortran front end, gfortran
Ian, who doesn't work in a bank
Ah you deluded BBC owners. I remember you crying yourselves to sleep because your parents wouldn't buy you a Spectrum so you could play all the superior games your school mates were playing.
I have about 5 or so old books on programming the Spectrum, they're a fun way to pass a rainy day and you can show the kids of today that they don't know they're born. Typing in two or three pages of crudely printed basic listings only for it to not work or do very little.
b) This is far off Spectrum basic as QL basic was. This is nothing more of a BBC Basic ripp off.
c) Sure basic is indeed educational.
D) Eh? FUN? On a dog slow overly complicated Linux distro? You're kidding are you?
Make these linuxes run as quick on the desktop as that RISC OS port does and THEN I'm really interested. But as of now, I tried Raspbian, OpenElc's etc... and all of them just suck! The only usable OS on the RPI is RISC OS... but it has seriously ommisions in multimedia and websurfing.
IMHO if all those supposedly great linux programmers put the same effort in to a collective to build a propper webbrowser, mediapplayer and a few other apps for RISC OS then they would have much more succes. As it is Linux will always remain niche even with the opportunities brought on with the RPI.
And the RISC OS folk whom still remain don't 'get it!' They keep asking 30 UKP for 'an upgrade from 3.09 to 3.12" (which should be free) or ridiculous asking prices like 150 UKP for an emailprogram or wordprocessor.
"Ah you deluded BBC owners. I remember you crying yourselves to sleep because your parents wouldn't buy you a Spectrum so you could play all the superior games your school mates were playing."
I doubt Speccy games will run on this "basic". Besides this isn't about games but about learn to program. Why so negative? I'd applaud ANY development on the Raspberyy Pi.
So it's not really that much like Spectrum BASIC then?
Sinclair QL SuperBASIC, which would be a much better teaching tool than Spectrum BASIC, as QL SuperBASIC was actually quite good (super, in fact).
Sounds similar to SAM Coupe BASIC, which was based on Speccy BASIC.
SAM Coupe BASIC was pretty damn good.
...was about as developed as it got - and iirc there was a backwards ports of it to the Speccy that featured on one of the magazine cover tapes. I used to program in both and QL SB was fully procedurised, which was a good basis to learn for things like VisualBASIC and Delphi, both of which I had back when they were v1, stack of 3.5" floppy disks to install. My QL shareware releases were always left in SB so that others could modify and update as required, but the commercial stuff got compiled with Toolkit II and a bunch of other add-ons before release.
SAM Basic was based on Beta Basic, which was an enhanced version of Spectrum Basic, so sort of right.
It won't be the same unless it replicates the rubbery multi-function keyboard. It would take a while to get out of the habit of typing things such as "RUN un" though.
Better string handling?
Does it keep the Spectrum's procrustean string logic?
Someone in favour of crabs? Or is that just my warped mind?
I believe the Sinclair BASIC method of string splitting is VASTLY superior to the crippled crappy Commodore method. I think Dunny only added those retarded commands to pander to the people unfortunate enough to have had to endure Microsoft BASIC (of which Commodore BASIC was one dialect).
The Sinclair method is clear and simple, no need to differentiate between left right and middle.
take something off the beginning? PRINT A$(TO 5)
take something off the end? PRINT A$(5 TO)
take something out of the middle? PRINT A$(3 TO 7)
And with the use of such functions as LEN, you could do all kinds of things with that simple format,.
Paris, because Sinclair string splitting was so simple even she could use it.
String handling must have been the only thing that was better. :P
Ok, so it wasn't BBC Basic, and Procrustean strings... but there was also the odd nice feature...
Let cyan = 5
Let magenta = 3
PAPER cyan INK magenta: CLS : PRINT AT 10,10; FLASH 1;"Hello wold"
And streams seemed pretty elegant at the time....
or was that just BBC?
The Speccy indeed had peek and poke, I don't know if this port supports them. More importantly, does it support RANDOMIZE USR (probably the most cryptically named command in any flavour of BASIC)?
RANDOMIZE USR wasn't actually a command. USR was a function (having the effect of executing some Z80 code at the address provided, returning the value in the BC register when the code returned). RANDOMIZE was a command that set the seed for Sinclair BASIC's pseudo-random number generator (the RND function). Because USR was a function, it couldn't be a statement on its own, so you had to do something with the result. I'm not sure who came up with the idea of using RANDOMIZE - one advantage was that it had no side-effects (unless you planned to use RND, of course). Your other option would be to assign it to a variable (LET a = USR x) but maybe RANDOMIZE was quicker to execute? Who knows. It became a convention, anyway, so a lot of people used it without having a clue what it meant.
Less typing; RANDOMIZE was one keypress on the Spectrum's gods-forsaken excuse for a keyboard, while LET a = was at least three (I forget whether it needed any shift keys).
It's not a proper Spectrum BASIC unless it requires you to stare at the keyboard for five minutes trying to find a keyword you don't use very often.
Guessing here but the RANDOMIZE "convention" might come from the ZX81 where it may have been used in preference to the let form as it took up less memory than the LET form, both in storing the source (key words were tokenised) and possibly avoiding having to store a variable - when you've only got ~3/4kByte for your program every little counted!
It was to initiate the random number generator with a seed.
Use the command:
or any other constant and the result returned from the random number generator would always be the same.
Sticking in USR would give an unpredictable number and therefore a random enough seed to the generator to stop any obvious repetitions.
Yep, RANDOMIZE was the quickest way of throwing away the result of the USR function, without taking up any memory. More critical on the ZX81 than the Spectrum. The USR function executed a bit of assembly at the given address. It actually put that address into the BC register pair, and on returning, the contents of the BC register pair came back as the function result.
ULTIMATE / ACG favoured PRINT USR to start their games, but that was on the assumtion that once running, the game never would return to BASIC, so nothing would ever be PRINTed.
Though in-line or callable Z80/6502 assembly will be a bit useless in a Pi BASIC unless you have the equivalent processor emulator.
As for BBC vs Sinclair BASIC, they both had their advantages and their gaps in language terms. The only significant difference was that BBC BASIC ran a hell of a lot faster, but that's not an issue with these implementations.
... now where did I put that ZX81 poster that came with the code for 'bomber' on the back and a wildly optimistic illustration of the game on the front.
I played with Spectrum basic for a number of years, but couldn't wait to move away from the clunky/slow environment and as soon as I had saved enough pocket money I moved on to other languages. And that was my feeling in the 80's never mind now!!
With all those features bolted on it's not really Sinclair Basic anymore is it... This is someone who just knocked out a crap interpretation of BASIC and bolted a load of crap at the end of it to try and make it up to date.No one is ever going to use it., little point developing this.
My, what a cheery soul you are.
Now I can POKE my PI.
...Jet Set Willy?
I heard it got up to level 8...
Are you mad, it's quite obviously not Sinclair flavoured Z80 if it supports procedures. Line Number calls are where it's at in Sinclairland.
Yes, you can use line numbers (in fact, as in Sinclair BASIC, you must use line numbers). Procedures were added due to demand, and they can be quite useful as they support passing parameters by reference or by value, support local variables and can be CALLed to return a result.
I kept line numbers in because I think they really force you to think differently about your code, and can be abused in all sorts of ways. There's no CASE structure, but when you can calculate a GOTO or GOSUB using an expression:
10 GO SUB var*10
Then you can simulate them quite easily.
Because line numbers are used, you can easily abuse procedures too - they use the subroutine stack like other handlers, so you could in theory jump in and out of them at will, without having to even call them. Not that I'd advocate that sort of code, but still...
Aside from all this, I'm frankly amazed at the response - a hell of a lot of people are downloading both the binaries and the source code from the websvn... Not sure I made the right choice about opening up my messy code like that, but it did enable the Pi and linux versions to be made :)
"Because line numbers are used, you can easily abuse procedures too - they use the subroutine stack like other handlers, so you could in theory jump in and out of them at will, without having to even call them. Not that I'd advocate that sort of code, but still"
I never felt restricted enough to need this, but did see it done. I liked the Spectrum 16/48K Othello game (CDS Microsystems, http://www.worldofspectrum.org/infoseekid.cgi?id=0003554) so much I had a go at porting it [to AMOS BASIC on the Amiga, for speed]. To save space for the 16K machine they had subroutines that were sometimes GOTO'd to in it - the routine to determine the computer's best move thus doubled as that for the player's help, except there was a priority order to check the empty spaces in the former case but no such favourable weighting for the latter. It took a few goes to get my head around the spaghetti, and I either I became very good at beating the game as a result or failed to port it sanely ... possibly both ;)
Can I just point out that I was joking? Apparently hobbyists don't understand sarcasm.
Nice work Dunny!
I owe you a beer.
Wait I'm confused now. Is it free as in speech AND as in beer?
Upvoted. Hurrah for hobbying. Boo to naysayers.
Well done and thanks for giving to the community.
And I learnt something today too - never heard that word before :)
Thanks must go to Chris Cowley for compiling it to run on the Pi.