packages feed

happs-tutorial-0.7: templates/whyhappstackiscool.st

<h3>Look Ma, No Database</h3>

<p>There 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>

<p>But we're here to talk about Happstack, not Haskell.</ p>

<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>
   
<p>What got me interested in HAppS was a strongly held feeling that as
modern software systems tend toward ever increasing complexity,
database usage is an unnecessary source of complication that
<a href=http://gilesbowkett.blogspot.com/2007/05/sql-unnecessary-in-haskells-happs.html>should be factored out</a> where possible.

<p>Ruby's <a href="http://rubyonrails.com/">Rails</a> and Python's <a href="http://www.djangoproject.com">Django</a> have become popular largely because of their 
	  <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">object relational mapping</a> 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. But pretty soon ORMs started seeming hackish to me too. At some point,
the metaphors I wanted to use just <a href="http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch">broke down</a>.


$!Or to put it another way, that <a
href=http://gilesbowkett.blogspot.com/2007/05/sql-unnecessary-in-haskells-happs.html>sql
is an ugly hack</a>. !$
<p> Happstack is Haskell's answer to Rails and Django (and Perl's 
<a href="http://www.catalystframework.org/">Catalyst</a>, 
    and <a href="http://www.php.net">PHP</a>).

    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
    <a href="http://www.google.com/search?q=scrap+your+boilerplate">powerful</a>
    machinery</a> that's running <a href="http://www.haskell.org/th/">behind the
    scenes</a>. And if there are existing databases that you need to connect to, you can do that too 
    -- you're not locked in to using macid for everything.

<p>MACID,
the Happstack storage mechanism, is no vanilla serialization layer that will
start acting in weird ways when an application has many concurrent users doing possibly conflicting things. 
By <a href="http://research.microsoft.com/~simonpj/papers/stm/">leveraging Haskell's type system</a> 
(see composable memory transactions paper),
you get the same <a href="http://en.wikipedia.org/wiki/ACID">ACID</a> guarantees that
normally only come with a database.  </p>


<p>There are some <a href="/tutorial/macid-stress-test">limitations</a> to using macid 
   as a datastore that you should familiarize yourself with
   if you are looking into using Happstack for heavy-usage transactional applications.
   But 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
   <a href=http://www.patch-tag.com>patch-tag</a>

<p>In short, Happstack is awesome, and webmonkeys everywhere should use it.

<p>Let's get <a href="/tutorial/getting-started">started</a>.