Sunday, July 10, 2011

Functional UI programming

I started using Scala recently to develop a movie player as a side project, with the goal of using functional constructs whenever possible. I found myself using imperative-style programming when interacting with the UI framework. This got me thinking, is there a functional state-less way to develop UIs? A bit of Googling revealed the following:

  • StackOverflow post that talks about this problem and references functional reactive programming (FRP). 
  • The Haskell people have developed UI frameworks around FRP.
  • For the rest of us non-Haskell people, there is Flapjax, an FRP model built on top of JavaScript for the web.
  • The spreadsheet is an example of a FRP model where cells are re-evaluated when dependent values change.
  • Clojure creater Rich Hickey recommends sticking with state-ful programming but keeping it to a minimal.