Kestrel ROM Forth: Why?
As is perhaps customary when bringing up new hardware, Forth
is to be one of the first high-level languages to be implemented for the
Kestrel. Indeed, just as most early 8-bit home computers were
shipped with BASIC as their default operating system, Kestrel will
ship with Forth as its default in ROM.
Forth was chosen for the following non-exhaustive set of reasons, in
no particular order:
-
Easy to learn. To absolute beginners, who have no prior programming
experience, Forth is often as easy, if not easier, to learn than
BASIC.
-
Extremely easy to implement. Forth, as a language, lacks any kind
of syntax beyond a simple string of symbols, evaluated strictly from
left to right. As a result, there is no need for a lexer, parser,
tokenizer, etc.
-
Forth is extremely compact. Likewise with the software
written for it. For example, the target assembler used to develop
Kestrel Forth is only 270 lines long, and consumes only 7740 bytes
on a 32-bit implementation of Forth. Kestrel's port of the
software is expected to be, more or less, 1/2 to 2/3rds this size.
See the 65816 Target Assembler page for more
information.
-
Forth is vari-level. This sounds strange, but it makes sense
when you consider that most software is written either in a
high-level or low-level language, often without any
way of spanning the two abstract levels. Forth starts off as a
low-level language, and can be made arbitrarily high or low
level as the application requirements see fit. The environment
will even come with a built-in 65816-compatible assembler.
Therefore, the "level" of Forth "floats" where it is needed,
depending entirely on the problem to be solved.
-
Extremely high productivity. Compared to developers who work in
other languages, Forth programmers can often achieve a project
milestone substantially faster, and with substantially fewer
programmers.
-
Interactive and interpreted. This facilitates extremely high
programming throughputs by allowing a coder to test software as soon
as they're done writing it! The edit-compile-run-debug cycle, while
it still exists, diminishes asymptotically towards zero.
-
The replaces keyword is a Kestrel Forth exclusive feature
that allows the programmer to replace an existing definition
with another retroactively. This permits makes coding even faster
still by allowing the programmer to retroactively adjust parts of an
already compiled program without having to recompile everything else
after that point (a feature that I miss from BASIC). For example:
ok> : hello ." Hello, " ;
ok> : world ." world!" ;
ok> : runme hello world ;
ok> runme
Hello, world!ok> ( oops -- forgot the carriage return )
ok> : world2 ." world!" cr ; replaces world
ok> runme
Hello, world!
ok> _
-
Forth boots insanely fast. If you make some kind of mistake that
causes the computer to lock up, just hit the Kestrel's reset button.
By the time your finger lifts off the button, Forth will already
have run its memory checks and be sitting at the familiar OK prompt.