Basic forever

Batch Basic

The Basic programming language is alive and well in 2024, but putting a novel spin on it can be difficult.

Batch Basic is a structured dialect with no line numbers and a few quirks. It's not very useful by itself, and mainly intended to be embedded, or used as a basis for extension / customization. It supports both interactive use and running programs written in advance, and in fact doesn't make any difference between modes of operation internally.

A different language of the same name was intially prototyped, but didn't go anywhere and had to be completely rethought.

Download

There are two versions of Batch Basic.

Batch Basic 3 (25 March 2024)

A modernized version with string support; open source under the Boost License:

Batch Basic 2 (6 March 2024)

A simpler version that supports older compilers; free and open source under the Artistic License 2.0:

Instructions for building on other platforms are included; both versions only require a C++ compiler and standard libraries. Beware that version 3 requires C++17, versus C++11 for its predecessor.

First look

For end users, Batch Basic looks like this:

rem Ahl's Simple Benchmark

let r = 0
let s = 0

for n = 1 to 100
	let a = n
	
	do i = 1, 10
		let a = sqr(a)
		let r = r + rnd()
	done

	do i = 1, 10
		let a = a ^ 2
		let r = r + rnd()
	done

	let s = s + a
next n

print abs(1010 - s / 5)
print abs(1000 - r)

A few notes (see the included language guide for more):

One unique quirk is that control structures of the same kind can't be nested. To help with that, there's an alternate FOR loop syntax. See the included quick reference for more information.

Performance

Note: these results apply to version 2.3 beta, prior to the addition of arrays. Otherwise version 3 is as fast as 2.4 and later.

An informal comparison using the Creative Computing Benchmark suggests that:

Further attempts using the Rugg/Feldman benchmarks suggest that Batch Basic 2 is faster than Tcl for pure arithmetic, but slower when it comes to array access.

Keep in mind: these are quick, informal tests involving a simpler language.

To do

For version 3.1:

More generally: