Portability of BASIC dialects

Some insights into the differences between BASIC dialects and their implications for program portability.

Comparing dialects

The vocabulary ladder

Colour represents the CPU. Faded cells are keywords that no other machine listed has.

Z80 6502 8080 (Basically uses Z80 to emulate the 8080)

Across all supported dialects there are distinct spellings and that appear on every machine:

Tokenised size comparison

A fourteen-line program run through each machine's tokenizer (same program, not translated). About 68% between the lightest and heaviest machine and dialect.

Sinclair has a 5-byte binary form stored after every numeric literal; the CPC has additional line overhead. ZX80's 141 has no floating point to encode which saves space. This is why a program fit check can't simply reuse the source machines byte count, it has to re-tokenize for each target.

Vocabulary by domain

The three Commodores and the TRS-80 have no graphics, colour, error or sound keywords at all.



Note the CPC: the highest ceiling of any machine at 65,535.

Control codes by class

Visual overview of control code distribution across machines. Important note: This is a general guide, not exact. These are codes understood and supported by Basically, there may be undocumented or missing ones.

Memory maps

Arranged by documented address region. Again this can be generalised, some machines have more complex memory layouts. CPC uses a non-linear line stepping structure for screen memory for example.

The Sinclair layouts have no screen region — the display file lives inside program RAM and moves as the program grows.

Portability between machines

Porting cost matrix

Rows are the source machine (porting from), columns are target. Darker is more work. Tap any cell for a breakdown.

Silent breakages

Risky constructs that don't break but can lead to unexpected behavior when porting between dialects.

Correlation between diff cost and structural risk count is 0.58. 36 of the 182 pairs carry no structural risk at all; 20 carry 4 or more. The 5 worst all target the ZX80, which the matrix scores as low as 46.

Variable collisions

When a variable name is reused across different machines, it can lead to unexpected behavior.

69 pairs collide plain names, another 27 collide only marked ones — the class my earlier reading missed entirely. The Atom and ZX80 use single-letter for everything.

Escape code compatability by domain

Shows whether the target expresses each class fully, partially, or not at all. (Note: This is a general guide, not exact)

False friends

Variables or keywords that have the same name but different meanings across dialects. The table below shows where machines share the same function under different names.

Cheapest and dearest

Summary of least/most difficult to port programs, based on what's known to the Basically IDE so far.