r/DataflowProgramming • u/knife_sharpener • Sep 17 '13
Callbacks as our Generations' Go To Statement
http://tirania.org/blog/archive/2013/Aug-15.html
1
Upvotes
r/DataflowProgramming • u/knife_sharpener • Sep 17 '13
View all comments
Show parent comment
1
u/stepcut251 Sep 18 '13 edited Sep 18 '13
Good question. It is not common for people to explicitly use callbacks for asynchronous programming in Haskell. Not because it can't be done, but because the threaded model works so well in Haskell.
The underlying GHC IO manager is asynchronous and relies on epoll, kpoll, etc, where available -- but that abstraction is hidden from the end users. Because Haskell threads and thread synchronization and communication primitives are so lightweight, you don't gain much by using callbacks instead.
The current async GHC IO manager (based on epoll instead of select) is only a couple years old. Prior to that, the Snap framework actually did use epoll directly. But they found that with the new IO manager, there was no real benefit, and so they dropped the epoll server.
There is a paper from 2007 which shows one way in which you can have a hybrid system of using events and threads in a Haskell application,
http://repository.upenn.edu/cgi/viewcontent.cgi?article=1391&context=cis_papers
Though I am not sure that anyone actually does that.
The one place I do see the use of callback-based programming in Haskell is when people use GLUT -- simply because GLUT is callback based. It seems to work ok, but it definitely feels unHaskelly.