[Yhc] Re: YHC for use in Lego Mindstorms NXT

Stefan O'Rear stefanor at cox.net
Wed May 30 19:24:56 EDT 2007


On Thu, May 31, 2007 at 12:13:26AM +0100, Neil Mitchell wrote:
> Hi Alexis,
> 
> Sorry you couldn't post originally, perhaps you need to join the list first?
> 
> >I am an MSc student working on the
> >development of a Haskell system for use with the Lego Mindstorms NXT
> >(My intent is to port it using the GCC-ARM toolchain and get it
> >running with the NXT firmware). For the most part I need a Haskell
> >compiler that will run within the 256KB memory space. YHc seems like
> >it could be perfect for such an application, but I am curious about
> >the following:
> >
> >- Is YHc VM based? Or can it compile Haskell directly to C code, or
> >both, or some intermediate code?
> 
> It compiles to a bytecode, which you execute using a C interpreter.
> 
> >- What is the typical memory footprint of the compiler/programs?
> 
> The programs are small. The interpreter can be made quite small. The
> compiler is in the region of 5Mb, and would be impractical for running
> on the Lego machine, and should be unnecessary. You will probably find
> that porting Yhc is a lot easier, and the binaries are smaller - if I
> had to pick between GHC and Yhc for this task I'd choose Yhc.
> 
> That said, 256kb is probably the lower end of what you can squeeze Yhc
> into. You may need to look at removing features like libgmp and ffi -
> Tom is probably in a better position to give you a minimum size.

If you can't squeeze yhi, you can always rewrite it.  Yhc bytecode is
the best documented Haskell IR in existance; it took me a week and ~8
kbytes to produce a (throwaway prototype) implementation of most of
yhi in Intel assembly. 

Also, the FFI is *mandatory* (Tom correct me), since all of Yhc's
primops are pure (unlike GHC) - so FFI calls are the only way to
perform IO.  You might be able to revert to the nhc-ffi
implementation, baking a set of allowable foreign functions into the
interpreter.  Also, gmp is bound using the FFI.

Stefan


More information about the Yhc mailing list