[racket] Tutorial: writing a language (brainf*ck) in Racket

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Mon Jun 20 14:05:40 EDT 2011

>
> You'd want to do the following:
>  - add some bounds checking in `increment-ptr' and `decrement-ptr'.
>  - change the `vector' operations to their `unsafe-vector' counterparts.
>  - change `sub1' and `add1' to use `unsafe-fx+' and `unsafe-fx-'
>  - change `=' to `unsafe-fx='
>  - change the uses of `set-state-ptr!' and `state-ptr' and such to use
> `unsafe-struct-set!' and `unsafe-struct-ref'.
>
> All of those will almost certainly improve performance.

Yup, this is done now.



> Other ideas:
>  - defining the semantics functions as macros, to produce inlining.

Yes, this too is done now.


>  - lifting out the definition of the state vector and pointer to the
> top level, so that you don't have to reference the state all the time.
>
> Those I'm less sure will improve performance.
>
> It would be even better if you wrote it up as an optimization section.  :)

I think I'll do that... but only after I finish Whalesong.  I'm not
intending to present the bf compiler during RacketCon.  :)



Posted on the users mailing list.