Interpreter vs compiler



Stavros Macrakis wrote:
> 
> Having written the first version of the translator in the early 70's
> (I was either in high school or a freshman), I can tell you that a
> basic translator is not that complicated.  The current translator
> (which contains none of my code as far as I know) is much more
> elaborate partly because it is better, but also because it is
> over-engineered, and handles many more special cases.
> 
> Having an interpreter and a compatible compiler is standard practice
> in the Lisp world, and I see no reason that we can't do a good job in
> Maxima without inordinate effort. There are certain constructions
> which are very difficult to compile effectively, but that's not fatal,
> because the interpreter is always available as backup. And perhaps
> some of the messier semantics need to be reevaluated -- for example
> dynamic vs. static scope.  In fact, all functions which try to be
> clever about evaluating their arguments in special contexts (e.g. cf,
> ev) are rather a mess.
> 
> It seems important to me that users need learn only one new language
> to take advantage of Maxima and anyway, few users nowadays know Lisp
> or are willing to invest in it.  Not to mention that the Lisp style
> used in Maxima internals is rather... um... dated... and um... hard to
> read. In fact, I would go in the opposite direction, and try to make
> it easier for users writing in the Maxima language to do more, notably
> to write simplifiers for mathematical functions.

I agree with this idea.  Users should only have to deal with Maxima and
not Lisp.

I have thought about always translating Maxima's input into Lisp and
then running the Lisp code, instead of interpreting the internal s-expr
representation.  If the translation is done correctly, we could have
lexical scope by default.  And since the code is Lisp, a Lisp compiler
could be used to make things go faster.  And that would allow things
currently in Lisp to be moved to Maxima if desired.

This could also clean up some semantics because we would use Lisp
semantics for the most part.

I don't know if this is feasible, but having more stuff in Maxima and
less in Lisp sounds like a good idea to me.

Ray