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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Jun 22 01:26:41 EDT 2011

Do brainfuck programs lend themselves to parallelism? If so, futures might help.

Robby

On Wed, Jun 22, 2011 at 12:03 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
>> Doh.  I screwed up again, and forgot the flag that enables JIT
>> compilation here.  I'll regenerate the PyPy-driven bf evaluator by
>> using:
>>
>>    $ python ./pypy/pypy/translator/goal/translate.py --opt=jit example5.py
>>
>> and generate corrected numbers soon.  My apologies for being hasty.
>>
>
>
> Followup: tests on my machine indicate that the PyPy JIT-compiled
> brainf*ck evaluator produces absolutely amazing performance.  It'd be
> interesting to see how it works on larger languages.  For brainf*ck,
> the PyPy folks righteously kick butt.  That being said, it takes a
> very, very long time to produce the specialized PyPy evaluator:
> roughly about 11 minutes.  That makes even Scribble documentation
> generation time look reasonable.  :)
>
> Here's what I see when I run the mandelbrot benchmark with their
> JIT-ed evaluator:
>
>   fermi ~/local/pypy-tutorial $ time ./example5-c mandel.b
>   [after fractal output]
>   real    0m12.000s
>   user    0m11.677s
>   sys     0m0.120s
>
>
> I'm comparing this vs. the planet dyoo/bf from my latest github repo.
>
>   $ raco make mandel.rkt && time racket mandel.rkt
>   [after fractal output]
>   real    0m49.845s
>   user    0m49.299s
>   sys     0m0.420s
>
>
> So it looks like a multiple of 4.  It would be nice if that constant
> were smaller, but I'm still impressed that Racket gets even that
> close, given how little time Racket takes to do the actual
> compilation.
>
>
> I've documented the optimizations I coded up in:
>
>    http://hashcollision.org/brainfudge/
>
> They are all in the new Section 10, as is a subsection on producing
> structured runtime errors with the source location property.
>
>
> Comments would be appreciated!
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.