happs-tutorial-0.8: 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>However, in this tutorial we'll be talking about Happstack, not Haskell in general.</ 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>An argument for Happstack is 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>
<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. 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>.
<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>. 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.</p>
<p>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
<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.
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
<a href=http://www.patch-tag.com>patch-tag</a>.</p>
<p>In short, Happstack is awesome, and webmonkeys everywhere should use it.</p>
<p>Let's get <a href="/tutorial/getting-started">started</a>.</p>