Haskell is a purely functional programming language with strong static typing. Being purely functional means that it doesn't support the widely used imperative programming paradigm and variables are not mutable (so they are more akin to constants).
This programming language is used in production in some large companies like Facebook, and it's strict functional structure makes it very good for algorithms theory studies.
The Haskell platform includes a compiler that generates native code (GHC) and an interpreter with a REPL (GHI) that helps you develop and test code more easily.
Compilation was done using GHC version 7.6.3.
$ time ghc -O3 -o hsrb hsrb.hs real 0m0.937s user 0m0.224s sys 0m0.036s
Compilation time is quite fast making it difficult to compare with other platforms, mainly because the source code for they path tracer is quite compact. Although it seems to be twice as fast as mono.
$ time ./hsrb real 26m34.955s user 26m5.968s sys 0m21.108s
Line count: 159 code, 30 blanks, 189 total.
File size: 7455 bytes.
Something here is quite odd, for starters, 159 lines of code might make the Haskell code look much more expressive, compared to the 303 lines of code from the C codebase. But the file sizes are not that different, only 237 characters apart, and the C code has many more lines of comments. For comparison, this paragraph is 343 characters long.
I found that writing branchy code gets ugly quite fast and because of the purely functional aspect of the language, working with
Because of the purely functional aspect of the language, converting branchy imperative code to functional gets ugly very fast; and also working with random numbers is a mess.
On the plus side, because of the type strictness whenever your code finally compiles, it works correctly most of the time, and knowing what type of data a function accepts and returns helps you keep a cleaner codebase.
Working this example, forced me to use a different data structure than on previous programs (less object oriented) that might be worthwhile to bring to them.
Nonetheless it was quite fun working out this implementation, Haskell is really a different experience and quite a (fun) challenge.
P.S. This code will have to be refactored later.
You can follow the development of this project on GitHub: