I long wanted to code on a mobile device, or at least fiddle with code, which is more plausible. Most apps made for that are huge and involved, but there are exceptions.
Enter X11-Basic. It's a 4.6MB app available in F-Droid, runs on very old Android devices, and comes with a ton of examples. Also a 700-page reference manual, which is daunting at first sight. I tried and failed twice to learn the dialect. But third time was the charm; see below for a survival guide. It applies to version 1.27, latest as of mid-April 2022.
For development I installed the Linux version from source, which is quick but tricky. Tip: use
make static as explained in the documentation, and manually copy the resulting executables to
/usr/local/bin or so.
Only two because trying to port more advanced games simply didn't work:
Remember that a big part of the fun with Basic games is tweaking them. For example I changed Land/Lord on the tablet to say "disaster!" out loud when the plague strikes, while on the phone I trimmed down the text to fit a very small screen. Figure out your own variations!
Don't panic! While the reference manual is over 700 pages long, most of that is a list of all statements and functions. You only need to read — or at least skim — the first few chapters. Mainly, an X11-Basic program looks like this:
' main program first @hello quit procedure hello() print @hello$() return function hello$() return "Hello, world!" endfunc
You can expand @ to GOSUB for procedures, but not functions. Other notes:
Speaking of which, there are nice touches like array literals (only for numeric arrays):
chances() = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
Also the EXIT IF statement can make for nice compact code in some cases. On the minus side, the parser is kind of fragile. Error messages can be confusing, or worse, absent. To wit:
> print "Hello, ": print "world!" Hello, ": PRINT "world!
Or for an even more baffling example:
> let a = 1: let b = 2 > print a 0 > print b 0
Not to mention (a real error I made):
> dim a(10) > let a = 1 > print a(0) 0 > print a 1
But keep it simple and things should work. Well enough. Usually.