less is more

June 20, 2011

A number of recently added standard Forth words have been dropped from the core vocabulary:

Surprisingly few haikus had to be updated to accommodate, suggesting not much has been lost.

I recently added a number of standard Forth words to the Haiku Forth core word list. Theoretically these words might have allowed interesting behavior. In practice, only 4 haikus (two of which were derived works) required updating. In both cases, the result was smaller.

The exclusive user of IF, THEN were the two mandelbrot haikus. They each contained the sequence:

dup 0 < if drop 0 then
This sequence is easily replaced with:
dup 0 >= *
And if fact, I now realize, even more tersely:
0 max

The only user of VARIABLE, @, ! were the two variations of the red ball. At a small performance penalty, this:

variable xx x 0.5 - xx ! ... xx @
was replaced with:
: xx x 0.5 - ; ... xx
Fewer total words, and less 'line noise'.

Despite my 'ambitions', the words ELSE, HERE, ALLOT were never used. They were also dropped.

As a result of dropping these words, the effort involved in adding an optimize pass which eliminates the internal use of the dstack + rstack arrays in favor of temporary variables was greatly reduced. This optimization noticeably speeds up Android performance, and is a hearty step towards being able to add WebGL support, and thereby animation via a 't' word.