Why Proper Tail Recursion Matters
Interpreters for general purpose programming languages are
serious programs.
In particular, the interpreters we wrote for ps11
are serious programs.
As you have seen from the sieve
and vectors
example programs,
ps11
is powerful enough to define structured
data types.
With a few extensions to its concrete syntax, a type checker,
and a way to call library routines written in another language,
ps11
would be more than competitive with languages
such as Python.
All of that could be added without making any changes to the
ps11
interpreters we've already written.
We can therefore use those interpreters as examples of serious Java programs that would benefit from proper tail recursion.
Let's use the sieve.ps11
program as a benchmark
to compare the performance of one of those interpreters,
written in Java, to a ps11
compiler (also written
in Java) that generates Scheme code, which can then be
executed by any implementation of the current Scheme standard.