|
Look Ma, No DatabaseThere are a lot of advantages to programming in a typed functional language like Haskell. Certain bugs, like misuse of global variables, are virtually impossible unless you bend over backwards to do things wrong. Code tends to be incredibly short, and modular. The Haskell community is very friendly, and with coders in every time zone the #haskell irc channel seems well populated seemingly 24 hours a day. p> However, in this tutorial we'll be talking about Happstack, not Haskell in general. p> Happstack has its origins in the HAppS project. Happstack is a successor to HAppS under the leadership of Matthew Elder and the work of the Happstack team. p> An argument for Happstack is that as modern software systems tend toward ever increasing complexity, database usage is an unnecessary source of complication that should be factored out where possible. Ruby's Rails and Python's Django have become popular largely because of their object relational mapping systems, which hide the complexity of database engines by converting application data manipulation logic into sql. When I first used an ORM, it felt like a huge improvement over writing sql statements every time I wanted to manipulate an application's state. Pretty soon ORMs started seeming hackish to me too. At some point, the metaphors I wanted to use just broke down. Happstack is Haskell's answer to Rails and Django (and Perl's Catalyst, and PHP). With Happstack, there is no wrangling data structures into and out of the database, because there is no database. You use whatever data structures are natural to your application, and serialize them transparently using powerful machinery that's running behind the scenes. If there are existing databases that you need to connect to, you can do that too -- you're not locked in to using Happstack's state management system, MACID, for everything. Still, MACID is no vanilla serialization layer that will start acting in weird ways when an application has many concurrent users doing possibly conflicting things. By leveraging Haskell's type system, you get the same ACID guarantees that normally only come with a database. There are some limitations to using MACID as a datastore that you should familiarize yourself with if you are looking into using Happstack for heavy-usage transactional applications. In the long term, Happstack with MACID looks promising enough that the original author started using it as a platform for building commercial web 2.0 type apps such as patch-tag. In short, Happstack is awesome, and webmonkeys everywhere should use it. Let's get started. |