Getting back to BASICs

10 Print “Happy!”
20 Goto 10

Yes, I am a computer programmer!
(You, too, can update your resume)

I don’t know what’s worse: that someone started this thread, or that I could still write a BASIC program right now.

The sad part is, I’m only 19, and I was writing stuff like that about 6 or 7 years ago.

However, it did prepare me for a lucrative (hah!) career in high school as “the calculator programmer.” I spent all of Algebra I writing programs because my teacher sucked. By the time I graduated, I think over half of my senior class had my programs.

Anyway, let’s see what I remember:

Not much, obviously.

10 FOR A=1 TO 100
20 PRINT “RICO REMEMBERS BASIC”;
30 PRINT " HE LEARNED IT IN 1973";
40 PRINT " AND IT’S BURNED INTO HIS SKULL"
50 NEXT A
60 END



10  FOR K = 1 TO N - 1
20    FOR J = K + 1 TO N
30      A(K,J) = A(K,J) / A(K,K)
40    NEXT J
50    FOR I = K + 1 TO N
60      FOR J = K + 1 TO N
70         A(I,J) = A(I,J) - A(I,K) * A(K,J)
80      NEXT J
90    NEXT I
100 NEXT K

(Compact Crout LU factorisation on diagonally dominant matrix)

That is astonishngly Compact for a Kraut design

Just to clear up what I said in the post above, let me elaborate: I hate Germans.

BASIC was a teaching language developed at Dartmouth in 1964. It should have died when Algol68 was standardized in 1969, but it hung on to an unholy life when it became the standard language of low-end microcomputers (beginning with the Gates-Allen implementation for the Altair 8800). It pretty much sucks for doing anything but algebra.

Anyway. :slight_smile:

Like many teaching languages (Pascal, Logo, etc.), it was a crippled version of something in real use at the time. In BASIC’s case, this was FORTRAN (FORmula TRANslation), the first high-level language (FORTRAN I was developed in the late 1950s for the era’s supercomputers) and still the pre-eminent language for mathematical number-crunching (mainly because a huge amount of really good mathematical and engineering FORTRAN software still exists). BASIC mimic’s FORTRAN’s basic line-oriented structure (as opposed to Algol’s block-oriented structure, copied to great success by BCPL, which begat C, which then was copied by everyone else :)) and use of a single loop structure (the BASIC FOR loop is exactly the same as FORTRAN’s DO loop except for syntax details).

Some examples:



10 REM THIS IS A SIMPLE ITERATION PROGRAM IN BASIC
20 LET A = 5
30 FOR I = 0 TO 20 STEP 2
40 PRINT A*I
50 NEXT I
60 END


Now, FORTRAN



C   THE SAME PROGRAM IN FORTRAN
C   (I'M IGNORING LINE-FORMATTIG RULES. THEY'RE A HUGE PAIN.)
    INTEGER A, I
C   FORTRAN ACTUALLY HAS IMPLICIT TYPING BASED ON THE
C   FIRST LETTER OF THE VARIABLE'S NAME. IT'S EVIL.
    A = 5
    DO 10 I = 0, 20, 2
      WRITE(5,1) A*I
 5    FORMAT(1X, I3)
 10 CONTINUE
    STOP
    END


Basically the same. :slight_smile: The main difference with the FORTRAN version is its inconstant use of line numbers (only used on statements other statements explicitly reference) and the format of the output statements (WRITE gets the output, FORMAT tells the program how to print it). Other than that, they’re very close.

The line formatting rules in FORTRAN specify what kind of information can go in which columns of the line. This rule dates back to when FORTRAN programs were punched on cards and fed into cardreaders as jobs. Formatting rules are now considered Very Bad Things (most modern languages have adoped Algol-style freeform syntax) and only exist in one major modern language: Python. Python can get away with it because its formatting rules are really close to what most programmers of other Algol-descended languages already do to improve readability.

I am almost tempted to break out the Timex Sinclair or the Panasonic 32k…
Nah…I spent three weeks getting it to beep out Dark Star back in '84.

Wow… I knew BASIC when I had my old Apple II clone, but later on I got a TI-82 calculator, which used a bastardized, unnumbered form of BASIC, which ended up taking real BASIC’s place im my brain.

10 FLASH
20 PRINT “Tricky RF Modulation program!”
30 NORMAL
40 PRINT “Shhh! If you listen very carefully, you can hear your computer produce a tiny version of Bach’s Crab Canon!”
50 LET X=RND(9999)
60 Y=X*50
70 FOR Z=1 TO Y
80 NEXT Y
90 PRINT “BOO!”;
100 FOR X=1 TO 50
110 PRINT CHR$(7);
120 NEXT X

You didn’t terminate your Z loop, Larry Mudd.

And Derleth, your “WRITE(5,1)” should be “WRITE(6,5)”.

Yeah, but how many of you have written a BASIC compiler?

Desmostylus: The numbering of the write statement was very implementation-dependent. It had to do with what the program would be writing to (tty, paper tape, disk, etc.) and what the machine’s conventions were.

But you are right about the unit number coming first. It’s been a while. :slight_smile:

In the modern nix world, the g77 compiler (the FORTRAN 77 frontend to the GNU Compiler Collection (gcc)) can take writes of the form WRITE(,5), which means no unit number is specified. WRITE writes to stdout, like a good little *nix filter. :smiley:

Some time ago, a coworker and I began insulting each other in code. After going through various languages, I resorted to BASIC.


10 PRINT "YOU SUCK"
20 GOTO 10

So he trimmed that down a bit.


10 PRINT "U SUK"
20 GOTO 10

So I trimmed it down a little bit more.


10 ? "U SUK"
20 GOTO 10

And then we got yelled at and told to get back to work.

10 ?“U SUK” : GOTO 10
10 HGR: HCOLOR=6
20 X = 140: Y = 100: D = 90: GOSUB 1000
30 X =100: Y = 90: D = 20: GOSUB 1000
40 X =180: Y = 90: D = 20: GOSUB 1000
50 X =140: Y = 120: D = 40: GOSUB 1000
60 GET A$
70 TEXT
80 END
1000 FOR I = 0 TO 6.28 STEP .01
1010 HPLOT X + COS(I) * D, Y + SIN(I) * D
1020 NEXT I
1030 RETURN

:eek:

Radiowave, why do I get a type mismatch, error 13, on line 60 in qbasic?

QBASIC??? In my day BASIC programming languages weren’t procedurally based and we liked it just fine! Grrrr…

Seriously, it’s an old APPLESOFT program from way back when. After running it, I found line 50 should change the 120 to 135.

Nope, still hangs up on the “get” - Sorry, I’m NOT a programmer, In fact, I still can’t get the hang of circular logic…guess that’s why I’m a better bass player than lead.

But I can break out the apple II and dos and try it if you insist.

petcat:

10 SCREEN 1: COLOR 6
20 X = 140: Y = 100: D = 90: GOSUB 1000
30 X =100: Y = 90: D = 20: GOSUB 1000
40 X =180: Y = 90: D = 20: GOSUB 1000
50 X =140: Y = 120: D = 40: GOSUB 1000
60 INPUT A$
70 SCREEN 0
80 END
1000 FOR I = 0 TO 6.28 STEP .01
1010 PSET (X + COS(I) * D, Y + SIN(I) * D)
1020 NEXT I
1030 RETURN