SmallBASIC
A free, open-source BASIC interpreter that started on Palm OS handhelds and still runs on everything from Raspberry Pi to Android. SmallBASIC is notable for its built-in ASCII graphics engine, which renders programs as text art on devices with no graphical display.
The ASCII Graphics Engine
Most BASIC dialects assume a pixel-based display. SmallBASIC does not. Its graphics engine can fall back to ASCII art rendering, drawing shapes and text using printable ASCII characters instead of pixels. A circle becomes a ring of * characters. A filled rectangle becomes a block of # symbols.
This matters because the same SmallBASIC program runs on a Palm Pilot with a 160x160 pixel screen, a Linux terminal with no X server, and a modern Windows desktop - without changing a single line of code. The ASCII renderer was not a toy feature. It was the portability layer that let SmallBASIC target hardware where graphical output simply did not exist.
SmallBASIC ran on Fossil wristwatches - actual Palm OS wristwatches made by Fossil, Inc. in the early 2000s. On a watch face with limited resolution, the ASCII graphics mode was the only practical way to display program output. This is probably the smallest hardware that has ever run a BASIC interpreter with graphical capabilities.
Built for Mathematics
SmallBASIC includes mathematical libraries that most BASIC dialects require external packages for. Trigonometric functions (sin, cos, tan, and their inverses), matrix operations, linear algebra, statistics, and unit conversion are all built into the interpreter. You can multiply two matrices with the * operator directly - no library import, no function call overhead.
The language also includes 2D and 3D equation graphing. Combined with the ASCII graphics engine, this means you can plot mathematical functions on a text terminal. A sine wave becomes a series of * characters positioned using the AT cursor command. This is not pretty, but it works on any device with a text display - including serial console connections where no GUI toolkit is available.
History and Portability
The "Small" in SmallBASIC refers to the Palm - a small handheld device. The project started as a way to run BASIC programs on Palm OS, where memory was measured in kilobytes, CPU cycles were scarce, and screen real estate was a 160x160 grayscale square. Every design decision reflects those constraints.
The interpreter is written in C with strict separation between platform-independent logic and platform-specific code. Each target platform (Palm OS, Linux, Windows, Android, MS-DOS) has its own module that handles I/O and display. This architecture lets the same BASIC source code produce output on a Palm wristwatch, a Raspberry Pi running headless, an Android phone, or a Windows desktop.
The platform list is unusually broad for a BASIC dialect: POSIX systems (Linux, BSD, Unix), Windows (native Win32 and Cygwin/MinGW), MS-DOS via DJGPP, Android (available on Google Play), Palm OS, the Franklin eBookMan, the Nokia N770 Internet Tablet, and the Helio/VT-OS platform. Any system supporting SDL, FLTK, SVGALib, or the Linux framebuffer can also run it.
Syntax and Code Examples
SmallBASIC syntax is close to QBasic. No line numbers required. Statements end at newlines. Multiple statements on one line are separated by a colon. The language supports structured programming with IF/ELSE, FOR/NEXT, WHILE/WEND, SUB, and FUNC blocks.
PRINT "Hello, World!"
Standard output. No boilerplate, no imports, no main function.
I = IMAGE("photo.png")
I.SHOW(100, 100)Loads a PNG and renders it at coordinates (100, 100). On text-only devices, the graphics engine approximates this with ASCII characters.
FOR x = 0 TO 6.28 STEP 0.1 y = SIN(x) * 10 AT INT(x * 10), INT(y + 12) PRINT "*" NEXT
Plots a sine wave using character output. The AT command positions the cursor, making text-mode graphing straightforward.
DIM A(2, 2) DIM B(2, 2) A = [[1, 2], [3, 4]] B = [[5, 6], [7, 8]] C = A * B PRINT C
Native matrix math with no external library. Matrices are first-class values that support arithmetic operators directly.
Loadable Modules
Since version 12.20, SmallBASIC ships with three built-in loadable modules: Raylib for 2D/3D graphics and game development, Nuklear for immediate-mode GUI rendering, and WebSockets for real-time network communication. A community-maintained module for Raspberry Pi GPIO access also exists, turning SmallBASIC into a hardware control language.
External modules are written in C and loaded at runtime. This extends the interpreter without modifying the core, keeping the base installation small (true to its name) while allowing serious graphical and networking capabilities when the target platform supports them.
SmallBASIC vs. Microsoft Small Basic
| SmallBASIC | Microsoft Small Basic | |
|---|---|---|
| License | GPL v3 (free, open-source) | Proprietary (free to use) |
| Origin | Palm OS community project (late 1990s) | Microsoft DevLabs (2008) |
| Syntax | QBasic-compatible | Simplified, unique to MS |
| Platforms | Linux, Windows, Android, BSD, Palm OS, embedded | Windows only |
| Math | Matrices, trig, algebra, statistics, graphing | Basic arithmetic, Math object |
| ASCII graphics | Built-in ASCII rendering engine | TextWindow only (no graphical fallback) |
| Target audience | Hobbyists, math users, embedded developers | Children and absolute beginners |
The naming overlap causes frequent confusion. For Microsoft Small Basic ASCII character code references, the ASCII table has the decimal, hex, and binary values that work in any BASIC dialect.
Sources
- SmallBASIC official site - Downloads, documentation, and release notes.
- SmallBASIC on GitHub - Source code, C-based interpreter with platform-specific modules.
- SmallBASIC on Wikipedia - History, platform list, and language overview.
- SmallBASIC plugins repository - Raylib, Nuklear, and WebSocket module source code.
- David Mertz, Ph.D. and Andrew Blais, Ph.D. - "PalmOS Hosted Programming Languages" at Gnosis Software. Noted SmallBASIC's development interface as one of the best among Palm OS languages reviewed.