26 luglio, 2019

10 PRINT CHR$(205.5+RND(1)); : GOTO 10

Una cosa che avevo già visto ma di corsa (manca sempre il tempo) e c'è voluto il suggerimento di Mariano Tomatis, the Wonder Injector, a farmelo apprezzate come si deve.

Tutto qui, 95 secondi densi; da rivedere più volte. Notare che lo schermo è attuale ma il 'puter è quello che dice, il Commodore 64.

Il libro cui fa riferimento è distante un hoogle, qui: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10. E in questa stessa pagina c'è il link al PDF liberamente scaricabile, lo faccio subito-subito.

Il volume fa parte di una serie dedicata al software: Software is deeply woven into contemporary life—economically, culturally, creatively, politically—in manners both obvious and nearly invisible.

This book returns to a moment, the early 1980s, by focusing on a
single line of code, a BASIC program that reads simply:

10 PRINT CHR$(205.5+RND(1)); : GOTO 10

One line of code, set to repeat endlessly, which will run until interrupted.


Segue una descrizione dettagliata che salto ma ne approfitto per qualche considerazione strettamente personale. Io allora ero già indaffarato nel lavoro, su Prime, minicomputer simile al più noto PDP-11. Per i giovani una precisazione: "mini" significa grosso come un armadio, era inteso relativo ai mainframes; non dico delle caratteristiche tecniche perché non sarei creduto. E sì, in Fortran, c'era solo quello (praticamente).

La rivoluzione dei personal come il Commodore 64 e gli altri raccontati nel libro me la sono persa tutta fino all'arrivo del PC IBM (e compatibili, di marca e assemblati (si capisce ancora questo termine?)).

Ripensandoci dopo è stato come quella volta dell'asteroide sui dinosauri. Cambiato tutto anche il linguaggio. Il nuovo era --grosso "ohh!" per me-- il BASIC.

Salto, si può (deve) leggere nel book originale, molto dettagliato. Salto anche tutto quanto detto sui labirinti (dei due tipi, in italiano c'è quella distinzione?) ma apprezzo la figura 20.2 a p.42 raffigurante [i]nformation theory pioneer Claude Shannon pictured ca. 1950 with his mechanical mouse Theseus and its magnetic metal maze. Bellissima.

A p.52 si parla di port, adattamento di un programma a un sistema differente, cosa che allora era un'attività normale per i i mini, ognuno aveva un OS proprio e anche i linguaggi di programmazione dovevano essere adattati. Per esempio con il Fortran le unità (canali?) di I/O non erano predefinite; e le connessioni venivano stabilite all'esterno del programma --roba che oggi risulta difficilmente comprensibile.

Ma il port di cui tratta il nostro caso è più generale, e affrontato per le macchine comparabili al Commodore 64. Per Apple "Applesoft BASIC is one of two standard BASIC implementations for the Apple II; Applesoft is the one that supports floating point math and seems very similar to Commodore 64 BASIC. The Apple II family of computers was of the same era and uses the same processor as did the Commodore 64, the MOS 6502. Applesoft BASIC, like Commodore 64 BASIC, was written by Microsoft and based on its 6502 BASIC, a version [...] that derives from Microsoft’s Altair BASIC. The Apple II computers and the Commodore 64 were really quite alike, almost as if they were siblings separated by corporate circumstance". Ma i caratteri da stampare sono diversi, non c'è l'estensione all'ASCII oltre 127 del PETSCII. E "[a]lthough the “/” and “\” characters on Apple II computers are exactly diagonal, they do not span the entire square that bounds a character". c'era anche "the TRS-80 Color Computer (or “CoCo”), sold through Radio Shack" con ancora una diversa variante, dovuta alla funzione RND.

Esistono ovviamente versioni nei linguaggi contemporanei, tre sono riportate nel testo ma più interessanti quelle disponibili nel Web.

Io avevo già scritto una versione Python che poi ho scoperto versioni molto simili online (mi hanno pre-copiato!). E al posto di "/\" (quest'ultimo da escapare) si può/deve usare "\u2571\u2572".
Ma meglio partire da qui, qui e qui.

Salto a p.76 dove si parla di Joseph-Marie Jacquard e il suo telaio programmabile, antenato di nastri e schede perforate, vedi figura 30.9 a p.77 per un esempio esagerato; le schede IBM per il Fortran (vecchie e in disuso quando ho cominciato a lavorare) erano molto più semplici. Ma questo non riguarda il Basic, anzi ecco qui (io lo scopro adesso) il vero aspetto rivoluzionario del Basic.

I computers (commodore 64, Apple I e II e simili) sono descritti per quanto riguarda le caratteristiche dell'output in "The Computer Screen", p.85. A me interessa un altro aspetto: [e]arly interaction with computers happened largely on paper: on paper tape, on punch cards, and on print terminals and teletypewriters, with their scroll-like supplies of continuous paper for printing output and input both [...]. The standard output devices for computers through much of the 1970s were print terminals and teletypes. Output was not typically produced on pages of the sort that come from today’s laser printers, but on scrolls of standard or thermal paper. The form factor for such output was not a standard 81/2 × 11-inch page, but an essentially endless scroll that was typically 80 columns wide.

Adesso devo tenermi forte, ci arrivo con 40 anni di ritardo:

Teletypes were used to present the results of the first BASIC programs written at Dartmouth in the 1960s, and they were the typical means of interacting with important early programs such as Eliza and Adventure. With such a system for output, there was no need for an automated means of saving and viewing the “scrollback” --a user could actually pick up the scroll of output and look at it. Of course, this sort of output device meant that animation and other effects specific to video were impossible.
Why are typed line numbers required at all in a BASIC program? Programs written today in C, Perl, Python, Ruby, and other languages don’t use line numbers as a language construct: they aren’t necessary in BASIC either, as demonstrated by QBasic and Visual Basic, which don’t make use of them. If one wants a program to branch to a particular statement, the language can simply allow a label to be attached to the target line instead of a line number. Where line numbers particularly helped was in the act of editing a program, particularly when using a line editor or without access to a scrolling full-screen editor. The Commodore 64 does allow limited screen editing when programming in BASIC: the arrow keys can be used to move the cursor to any visible line, that line can be edited, and the new version of the line can be saved by pressing RETURN. This is a better editing capability than comes standard on the Apple II, but there is still no scrollback (no ability to go back past the current beginning of the screen) in BASIC on the Commodore 64. Line numbers provide a convenient way to get back to an earlier part of the program and to list a particular line or range of lines. Typing a line number by itself will delete the corresponding line, if one exists in memory. The interactive editing abilities that were based on line numbers were well represented even in very early versions of BASIC, including the first version of the BASIC that ran on the Dartmouth Time-Sharing System. Line numbers thus represent not just an organizational scheme, but also an interactive affordance developed in a particular context.
Ecco: la quantità di memoria estremamente ridotta, la mancanza di un editor e un OS estremamente ridotto tutti motivi che portano alla soluzione (ottima, lo ammetto del BASIC). Anche se --no questo lo dico dopo; probabilmente; forse.

Ovviamente il libro contiene molte altre cose, tante, troppe anche per solo elencarle in questo post. Solo un'eccezione: l'Atari 2600, non sapevo delle sue particolarità; un suo successore, l'ST diventò l'utensile indispensabile per compositori musicali computerizzati --OK, sono OT con ricordi perso.

Gli autori tutti rockzs! 💥 anche se sono solo Basic, si parla dei personal di quell'era e allora è giusto così.

Però --torno a dirmi-- altrove si faceva in modo diverso, completamente. E --ma sono solo io che mi sono perso quell'avventura-- il Basic e i programmatori Basic come dice EWD the teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery.

Peraltro negli stessi anni diceva: FORTRAN, 'the infantile disorder', by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use. E: In the good old days physicists repeated each other's experiments, just to be sure. Today they stick to FORTRAN, so that they can share each other's programs, bugs included. Qui si sbagliava.
🔴

1 commento:

  1. Una nota trovata cercando altro che riporto come prova a mio discarico di essermi perso la fase iniziale della rivoluzione dei microcomputer, Commodor 64, Apple II e altri consimili. Prego vostro onore di classificarla come Exhibit-A.

    L'argomento principale è altro ma c'è anche quanto descritto in questo post.

    Il modo di inserire i programmi, certo, ma anche [p]erhaps people who hacked larger computers of the era did not interact with microcomputer hobbyists.

    Ah! si parla anche del Forth; devo raccontare che io l'ho usato sul Vic 20? (ma era più tardi, mi sembra di ricordare).

    Si trova tutto qui.

    RispondiElimina