5-in-5.com

twbasic: BASIC for Twitter

My day 2 project is called twbasic. It’s an implementation of classic, line-numbered, home computer-era BASIC that runs on top of Twitter. You can start using twbasic right now by twittering your program listing to @twbasic. Here’s how to get twenty rolls of a six-sided die:

@twbasic 10 for i = 1 to val(ARG$)
@twbasic 20 print rnd(6) + 1
@twbasic 30 next i
@twbasic run 20

(The above screenshot depicts twbasic providing a listing of the program above, and then the results of running the code.)

A reference for using twbasic can be found after the jump.

Twbasic Language Reference

Twbasic is built on top of Malcom McLean’s liberally licensed MiniBasic. Twbasic supports all of MiniBasic’s keywords (see the manual for a list and explanations), with the following additions and omissions:

  • The INPUT keyword is unsupported. (It doesn’t make sense in the context of twitter, since there is no keyboard to retrieve input from.)
  • An additional global variable, ARG$, is available to your program. This variable contains the whatever string follows the run command (see below).
  • Keywords are insensitive to case. (MiniBasic requires keywords in all-caps. I found that to be annoying for use from mobile phones.)

Twbasic also limits the output of any program to 120 characters (approximately one tweet). The server is currently set up to automatically kill any twbasic process that runs longer than fifteen seconds (so keep your programs brief).

Using twbasic

To use twbasic, simply start tweeting your program listing to twbasic using the reply syntax, like so:

@twbasic 10 rem my first twbasic program
@twbasic 20 print "hello!"

To retrieve a listing of your program, send @twbasic list. Your program will be sent back to you as a reply, one line at a time. (This might take a while.)

To clear your current program and start from scratch, send @twbasic clear.

You can revise a line in your program by sending another line with the same line number. For example, if you had originally sent the program above, then sent @twbasic 20 print "goodbye!", then you’d receive the following listing from @twbasic list:

@twbasic 10 rem my first twbasic program
@twbasic 20 print "goodbye!"

Once you’re satisfied with your program listing, run your program with the following syntax: @twbasic run. Any characters following run will be available within the program as the ARG$ variable.

After you’ve run your code, twbasic reply with its output (if any). If you’re following @twbasic, the output will show up on your timeline. If not, you’ll have to visit twitter.com/twbasic.

(Please be patient with twbasic: it’s only as responsive as its friendly whale master allows it to be.)

Rationale

The abbreviated, text-heavy and asynchronous nature of Twitter reminded me of my formative years in front of a TRS-80 Color Computer 2. I used BASIC then, why not use it now?

While twbasic is mostly just a fun hack, it could potentially form the basis of a mobile, cross-platform programming platform. Twitter’s biggest assets are its scriptability (via the excellent API) and its accessibility (if you can text, you can tweet). So if you’re on the road somewhere with only your uncle’s crippled mobile phone, you can still use twbasic to write some trigonometry algorithms.

Let me know if you have any problems (that can’t be explained away by twitter’s recent flakiness) or if you come up with any ideas for interesting applications.

July 30th, 2008

1 Comment

  • 1. Mark Foster’s Blog &hellip  |  July 31st, 2008 at 11:57 am

    […] computing we got earrings compatible with your PC, AsteriskFTP, and thank goodness there’s finally BASIC for Twitter. Clink your glasses for a laser photo trigger, trip the family crest fantastic, snap a jacket, work […]

Daily Posts

  • Day 1 July 28th
  • Day 2 July 29th
  • Day 3 July 30th
  • Day 4 July 31st
  • Day 5 August 1st
  • Guest Stars*

  • Day 1: Bre Pettis
  • Day 2: Dennis Crowley
  • Day 3: Kate Hartman
  • Day 4: Jonah B-C
  • Day 5: Andrew Schneider
  • Credits

  • Vikram Tank Coordinator
  • Rob Faludi Producer
  • David Steele Overholt Webmaster
  • Rob Ryan Tech Manager
  • feed

    Search


    type and hit 'enter'