[Haskell-cafe] what GUI library should i select?

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sun Nov 12 19:36:32 EST 2006

On Mon, 2006-11-13 at 02:50 +0300, Bulat Ziganshin wrote:
> Hello haskell-cafe,
> afaik, there are just two good enough libs - wxHaskell and GtkHs. can
> anyone point (or write) detailed comparison of their features? i plan
> to write large GUI program in Haskell and want to select best one.
> the requirements that i can imagine at this moment is the following:

I maintain Gtk2Hs, so I can tell you about that.

Much of the difference comes down to the difference between Gtk+ and
wxWidgets. You can read detailed comparisons between them elsewhere. The
main touted advantage of wxWidgets is that it is a wrapper over
different 'native' widget sets on each platform. This is also it's main
disadvantage as it means the semantics of the API are not always 100%
portable, it adds an extra indirection layer and it can't provide all
the features of the native widget set as it has to provide a lowest
common denominator API.

On the other hand Gtk+ is a portable implementation that uses themes to
provide a 'native' look (on windows it uses the native WinXP themeing
dll). This means the look is not always perfect (though it has improved
dramatically recently) but the semantics are much better preserved
between platforms.

As for the bindings, there's a great deal of similarity. One difference
is in memory management. Gtk+ was designed while keeping in mind the
goal of having bindings in garbage-collected languages where as
wxWidgets uses ordinary C++ object lifetime management. Basically this
means that with Gtk2Hs, if you get a segfault then it was my fault and a
bug in Gtk2Hs. With wxHaskell you can get into situations where you can
get a segfault and there's nothing wxHaskell can do about it.

Axel wrote more about that here:


> * my main target is Windows but ability to compile the same code both
> for Windows and Linux would be a plus

Gtk2Hs works on both.

> * the program developed is a sort of advanced file manager, so i need
> treeview, table view and tabbed view controls

Gtk+ has quite a flexible tree/list widget. With the upcoming release
there is a new Haskell api to this to make it much easier to use and
more Haskell-like. The tree/list widget follows the model/view and the
view is very flexible in how it displays data from the model. You can
set arbitrary Haskell functions to map data from the model to attributes
of the cell renderers in the columns. There are also several different
cell renderers, eg simple text, check buttons, icons, combo boxes etc.

> * user likes beauty, so various bells-and-whistles are welcomed. in
> particular, it would be great to have skinnable interface

Gtk+ uses themes. Of course on windows the default theme is the same as
the native global theme. Similarly, on Linux it follows the global
Gtk/GNOME theme.

> * use of resource file for all texts to make internalization easier

If you use glade for the UI (which the recommended style) then it's
possible to internationalise it. This is how most of the Gtk/GNOME
programs do internationalisation of their UIs.


More information about the Haskell-Cafe mailing list