[racket] I've implemented a Scheme Interpreter. But it's too slow. Next step?

From: Gregory Woodhouse (gregwoodhouse at me.com)
Date: Mon Mar 21 13:03:27 EDT 2011

This may sound overly simplistic, but have tried profiling your application? Where does it spend the majority of its time?

Sent from my iPhone

On Mar 21, 2011, at 9:42 AM, Patrick Li <patrickli.2001 at gmail.com> wrote:

> Hello everyone,
> 
> For educational purposes, I've implemented a simple Scheme interpreter in C, but it's way too slow at the moment. (eg. just macroexpanding and evaluating a function definition takes a few seconds.) I would like some advice on how to proceed next to get a adequately performing Scheme system.
> 
> My goal is simply to get out of C as quickly as possible. ie. Get the basic forms and a macro system working which will allow me to write the rest of it in Scheme.
> 
> So far this is what I have done:
> 
> I wrote a simple Scheme interpreter in Scheme in continuation-passing style, so that I can get call/cc working.
> 
> Then I basically just manually translated that code into C. So all continuations are heap allocated. 
> 
> How should I proceed from here? These are the options that I've come up with:
> 
> (1) Optimize variable lookup. Currently the environment is represented as a list of key-value pairs. Variable lookup is done by searching through the list.
> 
> (2) "Analyze" the code before evaluating it (ie. as in SICP). Ie. for an (if) form, it will determine that it is an if form during the analysis phase, so that at execution stage it won't have to repeatedly figure out what sort of form it is.
> 
> (3) Write a very simple VM, and develop a simple byte-code compiler.  The problem here is that I don't really know how to deal with first-class continuations. 
> 
> Thanks for your help
>   -Patrick
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.