

Is Haskell a Good Choice for Web Applications? (2009) - dmitriy_ko
http://jekor.com/article/is-haskell-a-good-choice-for-web-applications

======
danieldk
Please update the title to indicate that this was written in 2009. In the
meanwhile, Haskell has gained (besides Happstack) two excellent web
frameworks: Snap and Yesod.

One of the points of critique has been addressed now is database access. For
instance, Persistent provides type-safe database access:

<http://www.yesodweb.com/book/persistent>

The author also mentions the problem that exceptions can only be caught in the
IO monad. But this has become less of a problem, since more people started
using monad transformers (such as ErrorT) to add error handling to their
monads. ErrorT allows you to catch exceptions within that monad. For instance,
quoting from one of my own projects:

    
    
        readEntry :: MonadIO m => Corpus -> String -> ErrorT CorpusError m Text
    

_readEntry_ is a function that takes a _Corpus_ and a _String_ , and returns
_Text_ in a monad of the class _MonadIO_ if the function is successful.
Otherwise it reports errors in the form of a _CorpusError_. You could now, for
instance, run this function with _runErrorT_ , and it will return an ordinary
_Either_ value in the given monad ( _Left CorpusError_ in the case of an
error, _Right Text_ when the call is successful).

~~~
ps8ed
Also, if you aren't wedded to SQL, Haskell now has acid-state, a memory
resident database written in Haskell (formerly happstack-state).

~~~
gujk
How does a memory resident database satisfy the D in ACID?

~~~
jfoutz
IIRC happstack-state has a journaling system. You don't have the state on
disk, but you can reconstruct it. you could also journal to a remote machine
for a live failover.

------
jnbiche
As someone who's learning Haskell, I read the post because I'm interested in
the language's capabilities in the web arena. But your site itself is
brilliant! You are really on to something with vocabulink.com. I've formally
studied 10 human languages, of which I can speak/write/read 3 fluently, and
have passive understanding of another 2-3. People often ask me how I learn
languages, and a good part of my answer is very similar to what you are doing
with vocabulink. As you've discovered, the key is to use vivid, even silly,
mnemonic devices. Building up a large vocabulary is key to learning a
language. Don't waste your money on flashy tools like Rosetta Stone -- they
don't work for most people above the age of 8 or 10. Adults learn differently
than children.

So if someone out there is looking to learn a foreign language, my
recommendation is to combine vocabulink's approach to build up a large
vocabulary, and find the best concise grammar available for your target
language. If you don't remember grammar fundamentals (e.g., what's a
prepositional phrase, direct object, relative pronoun, etc.), then you need to
find a good book in your native language to review those concepts.

In any case, cool concept for a web site. Sorry for the off-topic post. Thanks
for telling us about your experiences with Haskell. I do think that Haskell
web capabilities have come a long way since 2009, particularly Yesod (I'm not
familiar with Snap).

------
sp00nman
How secure are these Haskell web frameworks? (snap, happstack, etc.). Without
a django and rails level of exposure, presumably they have quite a few holes
still?

~~~
tikhonj
I don't know about their maturity, but I think Haskell's type system and
purity would help with security.

It doesn't have anything like `eval` and is much less tolerant of weird input
by default than dynamically typed languages (at least in my experience).
Having no or limited state also helps--bad input and other mistakes tend to be
more localized when they can't possibly change anything else in the program.

If you're _really_ crazy about security, then I suspect the Haskell code would
also be much easier to analyze and verify.

~~~
danieldk
Also, many underlying components are tested using QuickCheck. QuickCheck
allows you to verify that the properties of functions hold under random input.

Of course, since such checking is used when the number of possible inputs is
too large to check (or infinite), it is not watertight. But it helps
tremendously in uncovering bugs.

------
scarmig
I've been wondering how well-suited FRP (implemented either in Haskell or
something else) is for back-end technology. It seems like it might be
overkill, but it does have a certain conceptual elegance to it.

Anyone play around with this idea?

~~~
davorak
Check out elm: <http://elm-lang.org/Elm.elm>

Recent reddit conversation:
[http://www.reddit.com/r/haskell/comments/mwbvj/elm_functiona...](http://www.reddit.com/r/haskell/comments/mwbvj/elm_functional_reactive_webprogramming_compiles/)

------
dustingetz
the source link[1] doesn't work for me. anyone know where i can find this
document?

[1] <http://jekor.com/vocabulink/vocabulink.pdf>

~~~
dowskitest
It worked here, but only when I did a right-click and "save as".

