Friday, January 12, 2007

Tiny BASIC Revisited

Scott and I decided to port Tiny BASIC over to Liberty BASIC last week. What we have is mostly working now and I'll make it available after I've polished it a little more.

In the Wikipedia article I mentioned before there are two versions of Tiny BASIC implemented in BASIC. The one we decided to use is here: http://www.aldweb.com/articles.php?lng=en&pg=7407 We decided to use this one because it is simpler. It is also open source.

So what we have is a cute little line numbered BASIC interpreter. In fact the version of BASIC used in the original TRS-80 Model I computer was Tiny BASIC. So if you've ever used this machine or anything like it (VIC-20, C64, Atari 400/800, Sinclair ZX81, etc.) you remember entering code a line at a time each with a line number, typing LIST and RUN. You also have immediate evaluation, which is a nice feature that most languages (even BASIC) don't have today.

The limitations? Single letter variable names. No string variables at all. Only about 100 lines of code per program (a completely artifical limit left to the reader to remove). No GOSUB/RETURN.

Okay, so why do this at all? Clearly this is not a useful programming language, right? I'm not so sure.

First, as an example of how to create a simple programming language it is great. The code is pretty well written (even though it looks like it is also written in a version of Tiny BASIC) and I had no trouble following it.

Then, when I consider just how small this program is I am impressed. In very little code the author has created an interactive programming environment.

If someone wants to use this as a platform to experiment it is wide open. One could try extending the language with string variables, add graphics support, or build a programmable robot battle game on top of it. Perhaps it could even be used to support scripting for Liberty BASIC applications.

Very cool. :-)

No comments: