Twitter on a 1982 BBC Micro

The Twitter platform has become socially worse since I posted this. I’m leaving it up for historical interest only and not as a recommendation of Twitter.

In 2015 the National Museum of Computing at Bletchley Park displayed photographs of some of their classroom activities using 1980s BBC Microcomputers. In one picture, a child had typed the word TWITTER at the 1982 BBC BASIC prompt, perhaps thinking that this would somehow take them to the social networking website called Twitter. (Website? What’s that in 1982?) BBC BASIC had just said Mistake because it wasn’t a well-formed command (the word TWITTER would work as a variable name, but in BBC BASIC you have to specify what to *do* with that variable—even if it were already defined, you’d still need to PRINT it or something; you can’t just inspect variables by typing their names alone as you can in Python).

twitter.jpg

twitter.jpg over HTTP

The organisers evidently thought the child’s attempt to load Twitter to be cute enough to post a photograph of the error message with the caption “Some things the Beeb won’t do.”

I must say: did you want something like *this*?

twitter.png

twitter.png over HTTP

tscreen.png

tscreen.png over HTTP

Admittedly, this (emulated) Beeb had some extra help in the form of an RS423 connection to a Debian GNU/Linux 8 “Jessie” system (running edbrowse in the 1st screenshot, and PhantomJS with pbmtobbc in the 2nd screenshot). But then, some mobile phones use browsers that require a transcoding proxy between the phone and the website, and few people say the phone “won’t do” the website just because it’s not doing *all* the processing by itself. (They might say it’s not doing the site *very well*, but that’s not the same question as whether it will do it at all.)

pbmtobbc

While we understand the caption’s intended meaning, in all fairness we should point out that the Beeb at the museum wouldn’t do Twitter because it wasn’t connected to a suitable server over RS423 (or over Econet via BeebFrame), not just because it was a Beeb.

Technical details

The one-liner to type on the BBC Micro is as follows:

MO.6:OS."FX2,2":REP.IFAD.-1:OS."FX3,1":V.GET:OS."FX3,0":U.0:EL.:IFAD.-2:OS."FX2,1":V.GET:OS."FX2,2":U.0:EL.:U.0

(I said Mode 6 so that “[” and “]” display as square brackets; they’d be arrows in Mode 7. Those with good monitors and eyesight might like to try the 80-column Mode 3 instead, and pbmtobbc works best in Mode 4.)

On the server side, it’s necessary to add a rate-throttling script to reduce buffer overflows, plus translate carriage returns etc. Something like the example script below.

If edbrowse is not available in your distro, you could also try w3c-libwww-apps to get the 1992 CERN line-mode browser as www, which is what I’ve assumed in this example script and is arguably easier for beginners. This will however need Web Adjuster to do its Javascript, SSL and Unicode rendering (none of which were around in 1992)—run adjuster.py with (e.g.) --js_interpreter=PhantomJS --address=127.0.0.1 --default_site=twitter.com.0 --host_suffix=localhost --wildcard_dns=False --open_proxy --htmlFilter="iconv -c -f UTF8 -t ASCII//TRANSLIT" and then tell www to goto http://localhost:28080/ (that iconv command transliterates simple Unicode punctuation into ASCII, but won’t help much if you want to view a non-Latin language).

If you want to run a *screen mode* browser like lynx (with cursor positioning, not just line-mode interaction), some versions of Kermit can emulate the VT-52 “DECscope”, or the Master’s *TERMINAL (press Enter at the = prompt) has ANSI (VT100). Cambridge University used BBC Micros as terminals to its IBM mainframe called “Phoenix” which was retired in 1995, 2 years before I started; I understand they were Model Bs with custom terminal ROMs and matching termcap files on the Unix side, but I don’t know what they were capable of.

The BBC’s entire graphics repertoire can be driven with VDU codes sent over the link: here I’ve kludged my old music program’s plotter output into BBC PLOT codes (VDU 25) in Mode 0, but monochrome images *are* better transferred as bitmaps split into 8x8 blocks for VDU 23 (see pbmtobbc above). The early Phoenix BCPL version of PMS had a BBC-terminal preview mode which used 8x8 characters in some way but didn’t attempt to render curves.

vdu25.png

vdu25.png over HTTP

Below is a simple script for rate-throttling and linefeed translation to go with the above FX one-liner. This script is for GNU/Linux; on the Mac you’ll have to do without pty so you might be more limited in the commands you can run. I’ve also assumed the BBC emulator is running its RS423 connection in Server mode (which tends to be more reliable than Client mode) and is listening on localhost port 2323.

#!/usr/bin/env python2
import os,fcntl,time,sys
toNC,fromNC = os.popen4("nc localhost 2323")
os.system("rm -f /tmp/w3c-cache/.lock")
toWWW,fromWWW = os.popen4("python2 -c 'import pty,time
pty.spawn(\"www\")
time.sleep(1000000)'")
fcntl.fcntl(fromWWW, fcntl.F_SETFL,os.O_NONBLOCK)
fcntl.fcntl(fromNC, fcntl.F_SETFL,os.O_NONBLOCK)
while True:
    try: typed = fromNC.read(1024).replace("\r","\n")
    except IOError: typed = ""
    if typed:
        toWWW.write(typed),toWWW.flush()
        sys.stdout.write(typed),sys.stdout.flush()
    try: out = fromWWW.read(1024)
    except IOError: out = ""
    if out:
        sys.stdout.write(out),sys.stdout.flush()
    out = out.split("\n")
    for l in out[:-1]:
        toNC.write(l+"\r\n"), toNC.flush()
        time.sleep(0.5)
    out = out[-1]
    if out: toNC.write(out), toNC.flush()
    time.sleep(0.5)

But can you log in?

That child might still be disappointed to find they can’t actually *log in* to Twitter, because the login process depends on interacting with graphics. An RS423-based VNC viewer would be theoretically possible (it would have to reduce the colour depth from 8 to 3, 2 or 1, and the mouse emulation could be tricky) but it would be *slow*. If they really were trapped with nothing but a BBC Micro terminal and were still desperate to use Twitter, I’d suggest preparing in advance by getting an API key that lets you do what you want with curl commands—but if they just want to ‘tweet’ then perhaps they’d be better off using another platform, such as Gemini, which I can update from any command-line terminal (although I wouldn’t go as far as doing it from a Beeb—besides anything else, some years after I stopped using BBCs I switched to the Dvorak keyboard layout, so in order to work on a BBC terminal comfortably I’d now have to remap its keyboard for a start).

Programming the BBC instead

Of course you could always do what we used to do and just program the BBC. Immediate-mode “one-liners”, being limited to 238 keystrokes, are relatively quick to type in; here’s some I made earlier:

For the sanity of museum personnel, I’ll refrain from posting a noise demonstration here.

The Cambridge Centre for Computing History has a BBC whose F key is broken. If you’re on that one and don’t fancy rewriting code to avoid the letter F, try OS."K.0"+CHR.70 to program function key *f0* to F. Or use my horrible hack !2832=17937 to program all 10 function keys to F (works only on an unexpanded Model B with no *KEY before or after).

Legal

All material © Silas S. Brown unless otherwise stated. Debian is a trademark owned by Software in the Public Interest, Inc. Javascript is a trademark of Oracle Corporation in the US. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Mac is a trademark of Apple Inc. Python is a trademark of the Python Software Foundation. Twitter and Tweet are trademarks of Twitter Inc. Unicode is a registered trademark of Unicode, Inc. in the United States and other countries. Unix is a trademark of The Open Group. VNC is a registered trademark of RealVNC Limited. Any other trademarks I mentioned without realising are trademarks of their respective holders.