Tuesday, March 17, 2009

Haskell

So I've been messing with scheme for little while now and I have a few things to report. Gambit-C and Chicken Scheme are quite fast, fast enough for real time games or any other application I want to develop. Of course that probably isn't news to anyone who uses either of those implementations of scheme. The C FFI on both is quite easy to use, which is nice. The biggest thing that the language is lacking is a good IDE, sure there is emacs if your twisted, like to memorize a bunch of commands and work with an odd interface made for computers before windowing systems were invented but I don't fit into that group. There are some real IDE's as well, such as schemeide and theschemeway however both are based on eclipse and I had issues getting both running. I wasn't really impressed by either of them however. The last ide if you can call it that, is Dr Scheme with PLT scheme, it's ok but quite slow compared to the implementations I preferred and I didn't really like it very much.

That being said there is nothing wrong with scheme however the community support is somewhat lacking. The irc channel (#scheme on freenode) while there are quite a bit of people there, many are away and no one really says much of anything (common in irc I guess). I did say a few things in the channel and the people are generally nice and helpful and pointed out quite a few resources for learning.

In Comes Haskell

The lack of a good ide and community support have lead me searching for something new again. Through out my looking for languages haskell has popped up quite a bit. I joined the haskell irc channel just to see what happens there and to my surprise it's quite busy most the time (busy enough that I don't want to read all the chatting that goes on). The next thing I looked at is an IDE, there are quite a few out there although most of them seem dead. The last thing that really won me over is the great amount of packages that are easy to install.


The IDE that looked the best to me was leksah. It is fairly new but looks to have a good feature list and is in active development. The installation was a bit of an issue on ubuntu 8.10 because they tend to use older packages. GHC, the main compiler for haskell, was only 6.8.x in ubuntu and the current is 6.10. Unfortunately ghc 6.10 requires a newer version of glib than ubuntu has as well and if you have ever tried to update glib on linux you know what a pain it can be. Anyways I decided to switch to OpenSuse 11.1, it's packages are more up to date than ubuntu's and is easy to install/maintain. Once up and running with opensuse I only ran into one issue with getting leksah running and it was my fault for not looking hard enough for a manual/install guide. For others who want to install leksah, here is a simple install guide (thanks to J├╝rgen for the help).

Open up the package manager and install the following packages:
  • glib-devel
  • gtksourceview2-devel
  • make
  • gcc
  • g++
  • ghc
Next you want to install cabal-install
wget http://www.haskell.org/cabal/release/cabal-install-0.6.2/cabal-install-0.6.2.tar.gz
tar -xvjpf cabal-install-0.6.2.tar.gz
cd cabal-install-0.6.2
./bootstrap

Now you need to install gtkhs
wget http://downloads.sourceforge.net/gtk2hs/gtk2hs-0.10.0.tar.gz
tar -xvjpf gtk2hs-0.10.0.tar.gz
cd gtk2hs-0.10.0.tar.gz
./configure
make
sudo make install

Make sure that gtksourceview2, glib and gtk all say "yes" after you do "./configure", otherwise you have missed installing one or more of the packages above.

The last thing you will want to do is add cabal to your path. My ~/.bash_profile looks like this:
PATH=$PATH:/home/sean/.cabal/bin
export PATH

If you change your path you will have to restart X to make it apply automatically or you can type
source ~/.bash_profile
each time you open a new terminal until you get a chance to restart X.

Finally we are ready to install leksah.
cabal update
cabal install leksah
Once you are done, just type "leksah" to run it.

I'm still playing with the IDE and it seems good so far but it looks like you have to make your own cabal package before you get started working on something and some of the dialogs seem a bit rough or I don't know what they are looking for exactly. I'm going to look over the manual and see how I like it.


To summarize a bit, I'm trying out new things again and Haskell seem to be the most mainstream functional language out there at the moment with quite a bit of support and community.

4 comments:

  1. usually mainstream is a signal: "Avoid this, it f____ing sucks!"

    ReplyDelete
  2. Anonymous, that's true for the mainstream of the mainstream, Haskell is the mainstream of the fringe - i.e. the most popular language among those who've decided that the mainstream isn't good enough.

    ReplyDelete
  3. Since you liked Gambit scheme, but didn't find an IDE to you liking, you might want to check out "JazzScheme" (at jazzscheme.org). They recently released an IDE targeting Gambit scheme and JazzScheme (their new OO scheme dialect based based on Gambit).

    George Kangas

    ReplyDelete
  4. Although some want to make Haskell on the fringe of the mainstream. Either way, Haskell is a semantically consistent language, based on a higher order logic called typed lambda calculus. There are very few rules governing the syntax, and that is the reason that Haskell seems magical. Things seem to just work because the syntax stays out of your way (once you know what types *really* mean).

    While there does seem to be a little competition between EclipseFP and Leksah as Haskell IDEs, and both are decent programs, neither have special functional programming support. Special functional programming support would be an embedded theorem prover for Haskell programs, test case/quickCheck test/test coverage framework, editing tools specifically related to functional languages (displaying grammars in a graph, auto generating the fold, visualization of the fold, etc), program transformation tools, and so on. Of course, I don't really complain; as soon as I find some free time, I will help contribute to the IDEs of Haskell.

    ReplyDelete