Bywater BASIC

Implementation of programming language Basic

Bywater BASIC (or bwBASIC for short) is a small BASIC interpreter similar to GW-BASIC. It was developed by Mrs. Verda Spell in 1982, then restored by Ted A. Campbell around 1993 and improved to its final version by Jon B. Volkoff around 1997.

bwBASIC is written in C (ANSI C). Initially it was created for Osborne I CP/M, but nowadays it runs on most UNIX-like systems. It is distributed under GNU GPL.

The dialect of the language implemented is a superset of Minimal BASIC (X3.60-1978) and a subset of Full BASIC (X3.113-1987), extended by shell programming capabilities. Generally the interpreter is highly portable but rather slow due to simplicity of design.

It features implicit typing (types are inferred, and only arrays have to be declared explicitly) and optional line numbers (the convention is that in interactive mode commands are entered without line numbers, while in programs they keep them).


Hello, World!:

Example for versions QBasic 1.1, QuickBASIC 4.5, bwBASIC 2.50
PRINT "Hello, World!"


Example for versions bwBASIC 2.50

Factorials are calculated iteratively. Note the type inference: data type for storing factorial values is not declared explicitly, and yet the larger values are calculated without an overflow error.

f = 1
FOR i = 0 TO 16
    PRINT i; "! ="; f
    f = f * (i + 1)

Fibonacci numbers:

Example for versions bwBASIC 2.50

This example shows iterative calculation of Fibonacci numbers and storing them in an array. Note the explicit array declaration and the string variable S$ — string variables names must end with a $.

DIM F(16)
F(1) = 1
F(2) = 1
FOR i = 3 TO 16
    F(i) = F(i - 1) + F(i - 2)
S$ = ""
FOR i = 1 TO 16
    S$ = S$ + STR$(F(i)) + ","
S$ = S$ + " ..."