Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Aristotle's Topics

Aristotle's Topics

A lightning talk I gave at PyTennessee 2020, about running an old program by writing an interpreter for it.

Many thanks to Erin Rose Glass and Hugh Burns.

7 March 2020

Jason Orendorff

January 11, 2021
Tweet

More Decks by Jason Orendorff

Other Decks in Programming

Transcript

  1. This is a picture of Erin Rose Glass, who is

    a librarian and activist. This picture is from six days ago. Erin was giving a talk to programmers, an inspiring and harrowing talk, the point of which I think was, how about we take a look at where we are and what we’re building.
  2. She had this slide, it says, “lost computing futures”. The

    idea is, if you look at the past, and try to forget what you know about the present—the omnipresent surveillance, the erosion of society, the propaganda, how annoying everybody is on twitter—if you look back, you can recover a feeling that it didn’t have to be this way. And—she brought some examples.
  3. Here is one of those lost futures. This is simple

    Computer-Assisted Instruction software from 1979. In case you can’t read this, imagine you’re sitting in front of a green screen and the computer is like, “I hear you’re writing a paper, what’s it about” and you say,
  4. “FEAR OF DEATH” and the computer replies, “HOLY ELECTRONICS! THAT’S

    WEIRD. I USED TO DATE A COMPUTER INTERESTED IN FEAR OF DEATH.” Friends. I learned about this program six days ago. I must run this program.
  5. So I guess what happened here is, in 1981—coincidentally the

    same year I got a Commodore 64—a librarian somewhere took photographs of this dissertation and put it on microfiche and archived it, and then something something now it’s on the Web as a PDF? So, OK, I get the PDF.
  6. And tucked away in Appendix A it’s got all the

    flow charts for the program. And guess what’s in Appendix B? Place your bets now.
  7. Full source listing. In BASIC. If you don’t know BASIC,

    it has um… non-Unicode strings, and a PRINT statement. It’s basically Python 2.
  8. This is what you get. So again, if you don’t

    know BASIC, it might not be obvious, but this is garbage.
  9. KLEOU.TEUSE COTO 7?40 YOURMNHIE.MT(EGTATION.E"VS as010 PRINT 'WOW DOES '35' CMANGCE

    INTO 50WETMNG ELSE.' 3S966 PRINT *ELABORATE.* 61940 GOTO 7940 iqlw GOT1 7104
 21462 OINT *NOW G0E0 '55' INTERACT 4IVT FORCES ARCUNO' 2500 POINT "ITSELF?" a4,4. PRINT 'WOW COULD '33m C4ANNE 30 TWky 400E P!OPLE ? abo1g PRINT 'WOUL SELEVE, ACCEPT, OR jUNOERSTAND EXPLAIN.. 603a Z(27161 34aa GCTO 7oss 6416 P0I4T 'maw I3 '55' LIKE A COAIN REACTION? OfSCQI9E.' Jbobe GOTO 70148 10le PRINT *po is 'S3' LIKE AN OCEAN TIDE? IEAC'q 26846 PRIM? 'OF4 IT, *41sw1' 246o SOTO 7046 361ai *m 444 'FIELD0 PEISPECTIVE . P6118 PRINT 'ON TW1S PLANET. MOM IS 'S1' 01ST3ISUTEO?'
 Ab1la PaNT 'OESCRISE.
 016130 COTO ?Was
 .1%140 PRINT *IS 'S3' WOUN0 AMONG ALL PEOPLES, ALL 4A0I0NSW 361b6 SOTO :,679 9OINT 701a This is what you get if you paste right into your slides instead. Also very garbage.
  10. So, that was a setback. But I was prepared for

    this by COMPUTE! magazine, which was a paper publication that had long printouts of BASIC programs that you could type into your computer and run. I’m not making this up.
  11. And yeah, I did it. It was just 18 pages

    of a PDF. Took a few hours. I had CAPS LOCK on. It was weird.
  12. Sometimes it’s not easy. Like, what is THAT? Or for

    that matter any character on this page. Is that a K or an X? (Note: these are load-bearing integers, so a mistake is a big deal. If I get this digit wrong, it’s not like we get three thousand of something when it was supposed to be three thousand and sixty. It’s a line number. So we jump to the wrong statement in the program. The behavior becomes super strange.)
  13. Well, I told you I was going to run this

    program, right? So I started with a regular expression to break BASIC code down into tokens. The part with the quotes, for example, matches a single BASIC string.
  14. I made a class for every single thing that can

    appear in a BASIC program. Like, BASIC programs can have numbers in them, so there’s a Number class. With methods for executing a number — it just returns the value of the number.
  15. I can’t show you all the code, but I needed

    something to take the raw text and turn it into the objects, so I wrote a little parser. The nice thing about BASIC is there is no high-level structure to your code, no functions, no blocks, nothing. So if you can parse one line of BASIC, you can parse BASIC.
  16. And here’s the main interpreter loop. I’m not going to

    win any prizes for self-documenting code here, but basically, big WHILE loop, WHILE the status is “run”, run the current line of code. And that’s basically it. Wanna see it run? (DEMO)
  17. I want to leave you with this picture, because I

    think it’s beautiful. Somewhere along the line this code got converted from digital to analog and back to digital one too many times, and it came apart. Maybe: a computing future is never really lost until we first lose the computing past.