back to article Basic instinct: how we used to code

Reg Hardware Retro Week Logo I’ve recently caught myself, like some horrific solo re-write of the Monty Python Four Yorkshiremen sketch, waxing lyrical to my two iPod-wielding young ‘uns about the good old days; when men were men, computers were effectively clockwork, and computer games… well, come to think about it, they …

COMMENTS

This topic is closed for new posts.

Page:

Re: Nothing wrong with BASIC (line nos)

What's wrong with putting __FILE__ and __LINE__ in fprintf(stderr,...) statements, or equivalent in other languages? I'm glad I got into this stuff before BASIC became popular, by which time I had moved on from FORTRAN taught in a 1 semester course at uni in '69, to Coral 66, PL/1, Pascal and even played with BCPL. It's funny, though, how playing with lots of languages pays dividends. I found I could easily hack on the ancient FORTRAN code in the NEC2 electromagnetic modelling program, and more recently some amateur radio stuff where the author probably uses FORTRAN because he used it all his career.

I've seen some funny code in my time, but the one that takes the biscuit is some C code (no names, no pack drill) that, if possible, is even more convoluted than a BASIC program and no, it's not a submission to IOCCC . Virtually no indentation (though that can be fixed with astyle), and too many gotos without reason. Perhaps the guy started with BASIC & never really escaped the mindset.

I do confess, however, that I've never really got to grips with functional languages and that programming style.

0
0
Silver badge
Pint

Re: Nothing wrong with BASIC

@David12

Line numbers in BASIC were great for exactly the reasons you state.

Your collegue, however, obviously only ever encountered BASIC on a stripped down memory sparse computer. My first computer was a Video Genie, a Hong Kong knock off of a TRS-80 model 1, Level II. The basic editor had the AUTO command. Simply type AUTO and away you go. Each time you press RETURN, the next line starts, already numbered, starting with 10 and incrementing by 10 each time.

It had arguments for start and increment too, although that might have been the "Level III" BASIC in TRS-DOS or LDOS.

It also had error trapping, ON ERROR GOTO/GOSUB with RESUME so you could deal with the error and jump back to main program as well as ON n Goto/GOSUB n, n+1, n+2 etc. Surprisingly advanced for the vintage if lacking in graphics and drawing primitives.

The TRS-80, remember, pre-dates many of the 8-bit computers we've been re-encountering in this series of articles.

0
0
Silver badge

Re: Nothing wrong with BASIC

"BASIC only ever 'needed' line numbers because the language designers thought it made a better language."

No, BASIC only needed line numbers, because with a line editor you have no other way of specifying where in the program code the bit of code you've just typed needs to go. With a screen editor line numbers are completely superflous, and any BASIC can be edited with a screen editor without any recourse to line numbers if you don't use GOTOs or GOSUBs.

0
0
Boffin

If you subscribed to early issues of Byte ...

...you didn't have to type in your Basic programs. You could get a 'floppy ROM' which was an audio disk (ie: as in 45 rpm) which you could play on your record player and pipe the audio out to some a-to-d circuitry on your home computer. The ones and zeroes were different tones on the disk, but good luck getting your sister's Dansette to sync up to the software on your Altair 680.

I think I could still find a floppy ROM around the house, and somewhere I still have a business card wallet full of Exatron Stringy Floppies with a Forth interpreter and various other software for said Altair.

1
0

Shop demo models

If you were messing around with a demo model in WH Smiths then a quick program along the lines of your first image was admittedly tempting:

10 PRINT "<MYNAME> RULES OK"

20 GOTO 10

However this was usually spotted very quickly and a shop floor bod would come over to sort it out.

I preferred the more subtle approach, which for the Dragon in your screenshot would have been:

10 CLS

20 PRINT "(C) 1982 DRAGON DATA LTD"

30 PRINT "16K BASIC INTERPRETER 1.0"

40 PRINT "(C) 1982 BY MICROSOFT"

50 PRINT

60 PRINT "OK"

70 GOTO 70

16
0
Happy

Re: Shop demo models

That's truly evil! I like it.

2
0
Pirate

Shop Demo Software Shenanigans

A friend of mine had some serious phun with BBC model B's in stores that also sold software.

He would take a box of 5.25 inch floppy disks, all but a few of which was labelled "Watford Electronics Compatibility checker". (Watford Electronics were a third-party supplier of peripherals; they made an improved disk system for the BBC, better than but slightly incompatible with the "official" Acorn upgrade and some software, especially games, would not work with it.)

So my friend would ask to "check" if a game would be "compatible" with his Watford disk system. Inserting the "compatibility checker" disk into the drive of a BBC computer and pressing shift+BREAK produced a fancy screen with a progress indicator; which then asked for the game disk to be inserted, thrashed the drive a bit, then asked for the checker disk again. After a series of such disk swaps came the dreaded announcement that the game was not compatible with the WE DFS. He would return the compatibility checking disk to the back of the box, and ask the shop assistant if he could compatibility-check another game. While the assistant was away fetching it, my friend whipped out the compatibility-checking disk from the front of the box (nobody ever noticed this blatant switch, which was done with no sleight-of-hand) and booted it up.

Again the compatibility-checking process would require several disk swaps, and again it would fail. And my friend would wander off, dejected, before the shop assistant could work out what had just happened right under their nose.

8
0
Trollface

Re: Shop demo models

Ah the joys of tormenting the numpty shop staff.....

On the BBC micro you could control the tape relay and disable the Break key in BBC Basic. We used to set up a simple delay using a for next loop to give us time to escape (usually 30 seconds or so) followed by a goto loop that rapidly switched the tape relay making a loud annoying buzzing noise. The only way to stop it was to ctrl-break (which most of the numpties didnt know about) or pulling the power.... Happy days....

2
0
Silver badge

Re: Shop demo models

I remember getting an Apple II for the lab and programming a little BASIC that put up a normal Apple prompt ( ] I think ) any keypress then produced a "SOD OFF" for a few seconds before the program then deleted itself and returned to the normal prompt.

2
0
Anonymous Coward

Re: Shop demo models

The most fun shop demo model I ever saw was a machine (C64 I think) which the shop had hooked up an external speech synthesizer to. Control was via an extension to the basic to add a SAY command. Most people were happy just typing commands for immediate execution, naturally I imediately put it into an infinate loop program instead. Oddly enough I never saw that speech synthesizer connected ever again.

0
1
Anonymous Coward

Re: Shop demo models

My favourite was to run a loop to copy the C64 ROM to RAM. A few POKEs would then replace SYNTAX ERROR message with something obscene. I'd then wander away and watch kiddies bash the keyboard a few times and then ask their Mum's what THAT meant!

Snigger

1
1
Pint

Re: Shop demo models

100 cls

110 print "I remember using a bit nibbler track and sector editor on my c-64 and while I was looking around at the floppys code past track 80 I saw a message from a Mr. Burger and it said -If you read this please contact Mr. Burger. I did call and was 8 years too late and they put that "IF YOU READ THIS" as a way to hire their programmers.

I loved scanning all floppies to see if there were any secret messages like that.

I would do it hours on end as if on a XFILES case."

120 end

0
0
Happy

xmas morning 1983, age 12

Finding that miracle of miracles, my parents had found a 48k spectrum.

I had donkey kong, and later that day, TTL to play.

But the star of the show was the basic manual.

I read it from cover to cover, and by boxing day had my first program:

- some flashing colours and text, and an 'enter password' screen with me and my mates 'handles' as passwords.

get it wrong, and go no further,

get it right and be granted permission to the 'secret screen'.

By April 1984, aged 12 1/2 I was producing an educational maths platform game for 'Poppy Sotftware' after finding their games in the local library and contacting the company.

I still have a printout of some of the code - I remember I couldn't really get my head round sub routines, so would sort of use them, but have a GOTO to somewhere else, and then a GOTO to somewhere else, etc... it was an absolute mess. I'd added various machine code routines for fancy stuff, masses of bin arrays for character sets, etc... and all relying on a temperamental tape recorder for backup.

38 years later, I'm still coding.

kids these days - don't know what they're missing.

8
0

Re: xmas morning 1983, age 12

The Original zx81 and Speccy manuals were masterpieces, and certainly among the best of their types for learning Basic on the machines.

I was still using the character code references (Which also had the full list of machine code instructions) in the back right up until i switched over to the Amiga.

4
0
Silver badge
Happy

Re: xmas morning 1983, age 12

I too am part of the aged 12 xmas morning 1983 club!

We should all get together to talk about it. What a day going through the Sinclair Horizons demo tape. I still remember sitting watching the foxes and rabbits thing...why???? Never did that again.

I remember that supply was very limited. Dad had his name on a waiting list since October and got a call a week before xmas that his name was up! He had to sneak out of work in the afternoon to drive into town to buy it.

Xmas 1984 was a bit flat in comparison with that one.

4
0
Coat

Re: xmas morning 1983, age 12

38 years later? Maybe it's time to pack it in :-)

1
0
Thumb Up

Re: xmas morning 1983, age 12

jason 7: "I still remember sitting watching the foxes and rabbits thing...why????"

I also remember doing that with my Dad on Christmas day 1983! (Well, it did serve to prove the 'educational' aspect of the Speccy). Of course I could hardly wait to load-up Manic Miner again afterwards. :-)

0
0
Anonymous Coward

Re: xmas morning 1983, age 12

Hopefully you've grasped 'sub routines' by now, else your colleagues must be having a grim time of it.

0
0
Mushroom

Re: xmas morning 1983, age 12

Absolute work of art, that was. I used to use that with a CP/M portable to hand-assemble programs and through some horrendous abuse of a word processor got my code loaded to 0x0100 so I could run (and use the CP/M SAVE command) it. Having figured that out I wrote a small tool that would relocate to 0x8000, then enter a loop where it would accept two hex digits, poke that value to the program pointer initially 0x0100, then increment that. Entering a * would cause it to exit, any other characters would have undefined results.... it was HARD entering that initial tool, slightly easier to enter a program using hex digits as the initial wordprocessor hack only gave me a subset of machine code commands - and 0xC9 (ret) was not available, I had to do that one by doing some maths, writing the result into RAM then let the program counter hit it.

It got a bit easier after that, as my next tool entered using that hex input thing above would read hex pairs from a file. Spaces, carriage returns and linefeeds were harmlessly skipped, a * ended the reading, but anything else would still be undefined. But I could use the word processor to enter the files so I had full line and file editing capabilities - all hand assembled using the ZX Spectrum manual.

0
0
Silver badge

old memories

Having learned basic on a TRS80 I then went on to use Borland Turbo-Basic on a 286 running DOS 5. It felt like proper programming, as it would compile to an exe or a com and would accept assembler inline as well. Great for writing TSRs

0
0

BASIC

Originally it was "Interactive" not "Instruction" and in fact "instruction code" is a bit of a tautology. Interactive in the sense that you could type something in and run it there and then, without having to compile/assemble/ whatever it first. Those days on the PDP11 were not wasted.

0
0
Anonymous Coward

Happy days remembered with a PET

0
0
Silver badge
Thumb Up

Memories, memories... (16k, 48k or 128k :) )

This whole series is bringing back so many memories - just goes to show what an old fart I'm becoming.

One thing that does strike though is actually how good a grounding BASIC (especially BBC Basic) actually was for some more modern "hobby" programmers like me. These days in my spare time I code mods for an open-source game in Javascript (plus the occasional similar thing for webspace in the past) and the fairly natural progression from one to the other is clear. The structure and set-up are quite similar (give or take line numbering) and so is the general logic behind it.

Now I know all you "proper" programmers could look down on it, but it certainly set up a wider generation of amateur coders than all our modern point-and-click apps etc are going to. Let's hope the Pi hasn't arrived too late.

4
0
Pint

My first computer

My first computer was an Elliott 803 in 1968/9-ish and we were taught to program it in Algol.

I say "my" computer, there were other people using it! We wrote the program on a coding sheet and handed it in. The punch ladies then punched it onto cards. The results were returned on tractor feed "music" ruled paper, wrapped around the cards. The turnaround time could be around 1 hour.

1
0

Re: My first computer

Hey, me too! Except we didn't hae a card reader/punch, everything had to be self-punched on papaer tape. No Algol, either. Elliott Autocode and/or the assembler. Assembler was by far the most interesting.

0
0
WTF?

They could get away with anything...

Just looking through that listing for Towers of Hanoi, t he description says it's "velly velly good".

In my head is a picture of Peter Sellers in Murder by Death as Mr Wang :)

2
0
Silver badge
Stop

No ELSE in Sinclair BASIC?

I know it wasn't in the ZX80 or 81 versions, but I'm pretty sure the Speccy had it.

0
0

Re: No ELSE in Sinclair BASIC?

I thought so too, but it doesn't seem to be in the manual:

http://www.worldofspectrum.org/ZXBasicManual/

I was quite surprised about that. It's amazing what we take for granted.

On a side note, they really don't write manuals like this any more. Re ^ and its applicability to compound interest:

If you try this command

FOR y=0 TO 198: PRINT y,10*1.15^y: NEXT y

you will see that even starting off from just £10, it all mounts up quite quickly, and what is more, it gets faster and faster as time goes on. (Although even so, you might still find that it doesn't keep up with inflation.)

Excellent.

0
0
Anonymous Coward

Re: No ELSE in Sinclair BASIC?

If it's not written on the keyboard, it's not there!

http://en.wikipedia.org/wiki/File:ZXSpectrum48k.jpg

2
0
Happy

If I can type through these misty eyes...

Anyone else remember having basic code dictated to them from the manual / magazine and then taking it in turns with your brother to be typist, often with your mum proofreading?

Brother: 10 FOR I = 1 TO 20

Me [typing]: 10 4I=1220

Brother: no, 10 eff oh arr space eye = 1 tee oh 20

and

Brother: 1040 RETURN

Me: 1040

Brother: no, 1040 space arr ee tee you arr en

5
0
Anonymous Coward

Re: If I can type through these misty eyes...

That's why Sinclair BASIC was brilliant - with tokenised keyword basic you couldn't get it wrong - the command verb HAD to follow the line number and you couldn't spell it wrong because it was all one 'character' in the character set, and one keypress to enter it.

0
0
Silver badge

Re: If I can type through these misty eyes...

The neat thing about the speccy basic was that it cut out the tokenisation process through having the user enter the token direct as the keyboard simply produced the token as the scan code.

Other (more sophisticated systems) such as the BBC and Commodore 64 had to parse the line text and tokenise it at that point. While this was less efficient as it introduced another step, it did allow the hacking of basic on the Commodore 64 through the trick of copying the current ROM into the underlying RAM bank under it, changing the tokens (IIRC they were terminated with bit 7 being set in the ASCII string) and the token index was then used with a jump table to execute the functionality. Reverse engineering this to hack it taught me a lot about how the basic interpreter worked and good usage of subroutines, including adding my own basic commands and using the underlying standard BASIC subroutines to help process them.

1
0
Silver badge

Re: If I can type through these misty eyes...

That's perhaps the first time I've ever seen the word 'sophisticated' used in a discussion of Commodore BASIC. That old skinflint Tramiel could have had a much better version of Microsoft BASIC for the C64 if he'd coughed up a few extra pennies per machine. Instead all Commodore programs quickly descended into a mass of unintelligible POKEs.

3
0
Coat

Re: If I can type through these misty eyes...

"1040 RETURN"

That's what we in the States call a taxing statement!

2
0
Silver badge

Re: If I can type through these misty eyes... @ Mike Richards

Ha! I can understand that, I certainly didn't mean "sophisiticated" by way of feaures, more by the implementation method. The lack of any form of graphics or sound functions in the language on the C64 was a permanent pain and the reason that assembly was so used (other than speed of course).

I don't think it would have been on a few extra pennies per machine, the constraint of the 8k basic ROM block probably had a big factor - IIRC there weren't much more than a few extra bytes spare, certainly not enough to introduce graphics and sound functions. Fitting a larger ROM would have doubtless caused all kinds of design issues.

0
0

running into a shop and typing

10 print "Program: Elite 2"

20 randomize usr 1310

on a spectrum, leaving the confused shop keep thinking Elite 2 is out

1
0
Silver badge

I still have a complete set of "INPUT" magazine by Marshall Cavendish. I've even spoken to one of the authors of the programs in there (who was a teenager at the time) on Slashdot.

It's fabulous to go back and just read through them again, but I doubt I'd have the time to type anything in without being a teenager with no homework again.

BASIC started me programming. People can bash BASIC as much as they like, but I can program, and BASIC allowed me to be self-taught from ZERO experience. Not a lot of languages can do that. Hell, I took most of my own A-Level Computer Science classes on programming because the teacher knew I programmed better than him and could explain it easier and I could parse others programs and spot errors quicker than he could. Maybe I don't program at Knuth or Djikstra's level but I can get the job done every time, and if I expend extra effort, my code is maintainable and pottable, and I have done that as part of my career too. There are schools running on my code, years after I'd left.

All because of the little orange book that came with the Speccy. I intend, at some point, to teach my daughter to program. She'll have zero interest, but that doesn't mean I shouldn't try anyway. I had zero interest until I'd spent a few lazy days with that orange book on my own and got results I never expected.

6
0
Anonymous Coward

Yay for the orange manual!

seconded on the orange ZX Spectrum manual, even the spiral binding was yet another stroke of genius as it made it so much simpler to leave it open on a page while trying something out.

So much awesome design in one product was just astonishing.

1
0

Re: Yay for the orange manual!

The Beeb manual was also spiral bound, and over an inch thick.

I had an advanced user guide too, I think it's still about in a box somewhere. That had loads of low down info and a complete circuit diagram - much fun with that!

These days you're lucky if you actually get a copy of the OS on removable media, let alone any kind of manual or welcome tape.

1
0

Ah, memories

I, too, still have all my INPUT magazines. Their series on 3D graphics was what started me on 3D; my initial graphics programming happened on the Spectrum (also yay to the orange manual, which is where I learnt the "x is a cross, so wise-up" mnemonic). I remember an adventure game in INPUT that used a partial predictive matcher for compression - pretty good for the time.

The higher level constructs in BBC BASIC (especially on later machines) were a pretty good stepping stone to more powerful languages. I still list BASIC on my CV (so I don't have the hacker's test point for denying that I know it). I never really picked up 6502/Z80 assembler (although I could probably work them out in retrospect now), but I learnt ARM assembly using the inline assembler in BBC BASIC on the Archimedes - a bit of a step up from my spectrum.

I still have my Speccy. My wife made me get rid of the Archimedes. I cried.

I don't know that I'd be where I am now if I'd been starting out with a 1990s PC instead of an 1980s micro that let you write simple animated graphics in an afternoon. I remember writing BASIC to draw a car. With racing stripes. And speed "woosh" lines. And the text redraw was probably faster than the virtual remote machine I'm having to use at the moment.

Thanks to all the pioneers. Sent from a Khronos conference in Dublin.

2
0
Silver badge
IT Angle

I also had the INPUT magazines, although I don't have them now. They were probably the best way of learning BASIC, seeing if you could debug the code in this issue before the issue next week which had the Erratum came out. What often help was seeing the listings for other computers although towards the end of the series when they dived into machine code with pages and pages of DATA statements it wasn't much help.

The orange book was probably the best book at teaching a programming language that I've ever read (despite it teaching Spectrum BASIC which is fairly restricted). I think the best decision Amstrad basing most of the +2 manual on it after Sinclair's + and 128K+ manuals which can only be described as failures. The +3/+2A was worse than the +2 one as they decided to introduce more of their own material.

0
0
Paris Hilton

@Lee Dowling

"my code is maintainable and _pottable_".

Good for you! I still have to grow mine out in the garden. But my systems grow organically.

0
0
Thumb Up

Type-n-Run-Away shop programs

My favourite 2-liner code to leave running on the Spectrums in the shop drew a line of random length taking into account the current position, in a random colour (quite a long line with RND's aplenty).... and then 20 GOTO 10

It left the screen a constantly (and fairly quickly) changing mess of coloured blocks, which made the machine look like it was capable of doing a lot quite quickly (as most of the speed was coming from the built-in machine code routine for line drawing).

I miss the old speccy, especially the typeface of the character set and those block graphics chars :)

The manual was a concise and brilliant introduction to programming. These days it's all so complicated to programme on a PC, in comparison - you just can't beat a fairly limited Finite Universe of a programming language where you've actually got some chance of mastering it.

0
0
Devil

Re: Type-n-Run-Away shop programs

How about

10 randomize usr 1331

A spooky precursor to l33t i guess ;-)

0
0
Thumb Up

Starcross?

Had a Vic 20 but the Tandy TRS-80 kept pulling back. Fantastic Machine!

Most games bored me unless others were there except for Starcross (I think that is what was called) spent hours on end patrolling the ship.

Ah slips off into pleasant memories...

0
0
Happy

Re: Starcross?

Ah, the TRS-80 with its glorious128x48 monochrome graphics! CHR(180) was my favorite.

0
0

You were lucky...

"I’ve recently caught myself, like some horrific solo re-write of the Monty Python Four Yorkshiremen sketch, waxing lyrical to my two iPod-wielding young ‘uns about the good old days; when men were men, computers were effectively clockwork, and computer games" ... "Actually it was my Nanna who bought me that 1KB ZX81, and my sister the small B&W rotary dial TV to run it on."

In my day we spent numerous weekends stripping wallpaper and moving furniture for dodgy student landlords to save up enough money to buy our own ZX81's. Then we had to solder them together ourselves from a kit because it was 10 quid cheaper than a ready made one.

0
0
WTF?

Jupiter Ace

In the mid-eighties I worked under a bloke who wrote his own BASIC *compiler* for the Jupiter Ace.

Scary.

0
0
Silver badge
Happy

Re: Jupiter Ace

I bought a SPECTRUM BASIC compiler (at a computer faire I believe).

It wasnt too bad, the biggest issues were that it didnt handle floats, just integers.

And you had to have enough room for the BASIC program, the compiler, and the resulting machine code .

0
0
Thumb Up

BBC Basic

I had a BBC B but I had to wait a year or two for it as it was a lot of money for us. As I recall because the basic had proper REPEAT....UNTIL Loops, procedures and functions there was a culture of never using GOTOS at all so it did teach you some good habits. I also recall doing some stuff in Assembly language but then my taper recorder broke and wouldn't record so it was a good few months before I could save any code again and never got back to the hard code.

That said it when I was a college and had to write a little PASCAL it was a very eaesy convertion and I earning a living in VBA these days so the £400 was a pretty decent investment.

As for all this BS about "proper" programming languages, I'm a firm beliver that you can write bad or good code on any platform.

3
0

Page:

This topic is closed for new posts.

Forums

Biting the hand that feeds IT © 1998–2017