By far Haskell is the prettiest of the programming languages. If I am in doubt about how an algorithm works, I often just find an example in Haskell to get enlightened quickly.
Have a look at the canonical quick sort
or merge sort, borrowed from here
Can´t be done better, can it?
So far I have not done any web stuff with Haskell. It would be fun to try out some of the solutions that exists for this.
After a quick look I decided to take a look at Spock. The server looks simple enought as well as easy to build out. These two features are by the way always two of the most important factors I look for, when evaluating techlogies.
Okay, so I create a stack project and add Spock to the build-depends in my cabal-files. When doing a “stack build” I see that the latest stack version of Spock does not like the current version stm-containers.
So I decide to learn a little more about how to use stackage.
I checkout version 1.1.02 of stm-containers and build - and a stack install.
I checkout latest version of Spock and Spock-core and bulids.
In my own stack project I have to add these two lines in the packages section:
In the extra-deps:
And then my stack project uses my local repos - and (hey!) it works.
I am now able to run my project.
Creating hallo world with Spock is now as easy as writing this Main.hs
Okay, now running it with
stack exec testspock-exe
and it answers fine on port http://localhost:8080
Okay, now I am curious to do some benchmaking. I use wrk
Results are like this:
This are very nice numbers, as I am running on an old (but nice) Linux box.
One thing, however. Several minutes after running the benchmark the Spock sever still use 16% of the resurces in while doing a top.
I do a new an more aggressive benchmark
wrk -t 10 -c 50 http://localhost:8080
The results are a little lower, but cpu now seems stuck at 30% usage even hours after the benchmarks and when the server has nothing to do.
I am not sure what happends here. Could be a regression as I work on the bleeding edge of the git, or something that I have not configured right?
But for now I think I will test another framework.