Enchilada in Haskell
Sunday, 5. August 2007, 15:44:20
For the past three weeks i've been porting Enchilada to yet another language, this time Haskell. The reason? I didn't like the Factor code I was writing: it turned out to be too Object Oriented. I also experienced a lot of runtime errors at tricky corner cases. But most importantly, I couldn't understand the Factor code I wrote months ago.
This isn't the fault of Factor of course: it's just that my coding style currently doesn't go well with idiomatic Factor code. Nevertheless, I can say that manipulating the stack without using named parameters was painful at times. Probably that's because I didn't factor my code enough. Anyway, I wanted to give Haskell a try, just to see if I my coding style could benefit (=cleaned up) from strong typing.
And I must say that I'm very impressed with the result. Besided strong typing, type classes, higher order functions, etc, Haskell's laziness has given me new ways of expressing Enchilada's algorithms more succinctly. Another big plus is that Haskell's pureness matches that of Enchilada, which probably gives GHC an opportunity to optimize certain algorithms and data structures more agressively. And not surprisingly: my Haskell code turned out to be very easy to (re)read (at least for me).
But the most interesting result is that the Haskell implementation of Enchilada runs MUCH faster than the previous Java and Factor implementations I did. The Glasgow Haskell Compiler is a very amazing piece of technology indeed.
This isn't the fault of Factor of course: it's just that my coding style currently doesn't go well with idiomatic Factor code. Nevertheless, I can say that manipulating the stack without using named parameters was painful at times. Probably that's because I didn't factor my code enough. Anyway, I wanted to give Haskell a try, just to see if I my coding style could benefit (=cleaned up) from strong typing.
And I must say that I'm very impressed with the result. Besided strong typing, type classes, higher order functions, etc, Haskell's laziness has given me new ways of expressing Enchilada's algorithms more succinctly. Another big plus is that Haskell's pureness matches that of Enchilada, which probably gives GHC an opportunity to optimize certain algorithms and data structures more agressively. And not surprisingly: my Haskell code turned out to be very easy to (re)read (at least for me).
But the most interesting result is that the Haskell implementation of Enchilada runs MUCH faster than the previous Java and Factor implementations I did. The Glasgow Haskell Compiler is a very amazing piece of technology indeed.








Sjoerd Visscher # 5. August 2007, 19:26
Robbert van Dalen # 6. August 2007, 05:41
Also, the current site (enchilada.javaforge.com) doesn't really apply anymore. I guess I have to find another place to host both the factor and haskell version of enchilada.