Structured Programming (shading into Computer Folklore)

Chris Torek chris at mimsy.UUCP
Mon Feb 27 19:14:44 AEST 1989


[discussion redirected to comp.misc]
>In article <234 at jarthur.UUCP> wilkins at jarthur.UUCP (Mark Wilkins) writes:
>>... Ever try writing 10,000 line program that works in Applesoft BASIC?
>>THAT will make you a believer.

In article <1348 at ubu.warwick.UUCP> mirk at warwick.UUCP (Mike Taylor) writes:
>Hmmm ...  A few years ago BASIC was all I had, structured programming
>was a closed book to me, and yet I seemed to get by without any of the
>sorts of problems that Structured Programming is supposed to alleviate.
>I will admit I never wrote a 10000-line BASIC program, but I certainly
>got into the 1000s ....  But looking at it objectively, I never had as
>much difficulty debugging my huge, sprawling unstructured BASIC programs
>as I do now debugging my huge, sprawling, but structured, C programs.
>(Only 1/2 a :-)

When it comes to debugging, BASIC has two big advantages over C:
First, it is interpreted (usually).  You can use `printf-style'
debugging quite freely.  C systems usually force you to recompile
everything with a special `debug' flag, and run under a special
debugger, and even then the debugger often does not match the language,
so that you cannot print or set variables properly.  Second, BASIC
is a much simpler language: there are not as many ways for you to
hang yourself.  The rope is simply too short.

Despite the near-necessities missing from most BASICs---local
variables, for instance---it is possible to write large programs in
them.  I once (in 1979 or 1980, I suppose) wrote a Z80 assembler in
TRS-80 Model I Level II BASIC.  The line count was certainly greater
than 1000.  The system I used was to keep a large sheet of paper
covered with entry points and variable use.  In fact, I still have that
paper (curious what one finds in the desk drawers under the H19):
	...
	10200 - Line input & parsing
	...
	11200 - O1$: "BC" RP <- 0, "DE" RP <- 1, "HL" RP <- 2,
		"AF" RP <- 3, "IX" 4, "IY" 5, else -1
	...
	12100 - Label table search, FI = `subscr' for label (*not* mod 25)
	...
	12400 - write 1 disk record, C bytes
	...
(many of these comments now seem unutterably cryptic; but some of it
comes back to me now).

The input, output, and labels were all stored on floppy disk.  This
was necessary as the assembler itself used most of the available RAM
(48 kB, minus the sizes of the various patches needed to use lowercase,
fix the keyboard, and so forth---about 35 or 40 k left, I think).
The assembler was a conventional two-pass job, and ran at the blinding
speed of 15 lines per minute.

Per pass.

I used to start it assembling, then go eat lunch or something.

I did add a `buzz' assembler directive that made use of the cassette
recorder relay to alert me when the assembly was done.  But somehow I
never got around to rewriting the assembler in assembly....
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list