

Ask HN: Snap v Nitrogen v Lift v Compojure - acconrad

I feel like this is the new "Rails v Django" discussion, but I'm really new to functional programming languages. My only experience is a bit of PLT Scheme/Racket and OCaml in college, but I want to get back into it via web development. Everyone seems to lean towards Haskell, Erlang, Clojure and Scala over here so I'm curious to hear your experiences with their most popular web frameworks. Are they as analogous as a Rails v Django comparison? The only thing I can comment on is Lift appears convincing with their users list, but Scala seems like it would be a poor way to learn functional programming because it's not purely functional.
======
pavelludiq
Of the listed frameworks I only have (limited) experience with compojure, but
here is my advice. I love functional programming, but i think that we've over-
hyped it a little. As you know(i hope), there are no silver bullets. I
wouldn't worry about a language being impure, purity is over hyped as well,
clojure is also impure. What I used to do with clojure was to take a bunch of
components(compojure, sandbar, hiccup etc.) and glue them together to make an
app. I haven't been following the clojure scene for a while, but i believe
thats the idiomatic way to write web apps, not the full stack style of rails
or django, where you just fill in the blanks.

~~~
ibdknox
I wrote the majority of my startup's code in Clojure using compojure et al.
and that is indeed the way you end up doing it. These pieces that you use
together, however, didn't require any glue for me. Like all functional
programming, you use the pieces that you need in your application. In general,
compojure and hiccup will take care of just about everything you need. If
someone wanted a full service rails-like package, though, conjure can give
that to you.

The benefit of not using a one sized fits all kind of framework, is that you
have immense flexibility. Want to write your templates in more of a PHP style?
Use string template instead of hiccup. Want to do it like JQuery on the
server, use enlive. You have tons of options.

That being said, it's definitely new territory and not for the faint hearted.
You will have to feel your way around a bit, but at the same time there is an
extremely active and helpful community. The guy who works on compojure, for
example, often responds in a matter of hours.

Now having written a fairly sizable app in clojure, I'll happily say it's by
far the best experience I've had writing a web app. Once past the rough edges,
there's just something to be said for generating your html in manipulable
clojure structures that can be mapped over and all sorts of other fun things.

------
parfe
I've been using Clojure and Compojure this weekend. So far it's a big thumbs
down. Documentation is terrible. Pretty sure I just killed a weekend on an
over-hyped development style with an under documented ecosystem.

Oh, and good luck finding a tutorial for any recent version of Compojure or
any of the components. Seems they rearranged all the code and broke it out
into several different projects, which makes all the pre-0.4 tutorials
useless.

So far it looks like the most helpful resources are:
<http://vimeo.com/8356990> [http://stackoverflow.com/questions/3122749/good-
current-docu...](http://stackoverflow.com/questions/3122749/good-current-
documentation-and-or-tutorials-for-compojure-ring-development) and
[http://cleancode.se/2010/08/30/getting-started-with-
compojur...](http://cleancode.se/2010/08/30/getting-started-with-
compojure.html)

~~~
runevault
Piecing together the documentation can certainly be painful, especially if you
are doing things that don't mesh with the norm (for example last time I was
refreshing myself on enlive the tutorials for that had switched to mustache,
while I prefer compojure) making things entertaining until you get back into
the groove.

However for me I love the power that comes with the fact I can piece together
the parts I want easily after some initial experimentation, as they are all
built to be independent of each other. Makes the workflow more fluid.

Though if I were to even want more of an "all in one box" solution I would be
more prone to use Scala + Lift right now.

------
ucsd_surfNerd
There is a growing community with quite a bit of support surrounding scala
particularly for web development. Lift is well documented and in production at
Foursquare which is vote of confidence. The Guardian is also switching to
scala as described here <http://www.infoq.com/articles/guardian_scala>. Plus
Twitter, Yammer and a bunch of others are also using scala for "web related"
development.

Overall I think as it exists now Scala has the best community particularly
around web development. Much like the Django v Rails debate try them out and
see what you like.

I know personally scala is second on my list behind Ruby.

------
amock
There's definitely some subjectivity and it comes down to what you want from a
language and framework. I think Haskell is the best way to learn functional
programming because it's pure, has a powerful type system and helpful
community, and it's easy to use it to replace shell scripts. One of the things
that really bothers me about JVM based languages is the startup time that
makes it painful to use them as shell scripts, but if you're just writing a
web application this might not be an issue.

If you decide to go with Haskell then you need to decide what kind of
framework you want. I started with Snap and it I enjoyed using it but it
doesn't have the high level functionality that Rails or Django do. I'm now
using Yesod and it's great. It seems very Haskelly to me and the high level
functionality means I don't have to write my own authentication system and
persistence layer.

~~~
whacker
<http://github.com/icylisper/jark>

~~~
whacker
Project Website: <http://icylisper.in/jark/>

~~~
amock
That looks interesting, but at least for the near future solutions like that
aren't good for things you want other people to run without having to do a lot
of work. That said, I'll definitely look into using that as I learn Clojure.

------
brehaut
Regarding Clojure, while compojure is popular, a compojure centric view of web
programming is misguided. Compojure is part of a growing ecosystem of
libraries built on top of ring[1][2].

Firstly this ecosystem is not analogous to rails or django. The closest is
that Compojure is similar to Sinatra i believe.

If you are looking at getting started with web programming in Clojure you need
to get familiar with ring (the http abstraction) and look at Compojure and
Moustache (routing and handler composition), and Enlive[4] and Hiccup[5]
(templating/html generation). Compojure and Moustache are fairly similar, but
Enlive and Hiccup are extremely different. A web application will consist of
ring plus one of each layer.

As has been mentioned by others in this thread, the depth, breadth and
currentness of documentation for these libraries varies. David Nolen has a
great tutorial for enlive[6] that i would encourage anyone looking at these
libs to work through. Enlive is one of the most compelling aspects of the
clojure web ecosystem at present.

These libraries provide the core pieces you would expect to see in any web
framework, but a lot of the smaller details are missing. Of note there is no
ORM for clojure (for obvious reasons) - If you are looking for a good SQL
abstraction you should look at ClojureQL[7] - and aspects such as form
generation, validation and processing is still in early days.

My day job has me building web apps with Django. I wouldnt suggest that my
coworkers and I jump to clojure / ring et al yet. The breadth of libraries and
out of the box stuff in django is still a huge advantage for the day to day
rapid web site / web app development, however clojure's story is improving
rapidly and i think that the functional model is a particularly good fit for
web applications.

I cannot compare clojure's story with the other languages and frameworks
mentioned.

    
    
      [1] https://github.com/mmcgrana/ring/ 
      [2] This is true of compojure 0.4 and newer. compojure existed prior to ring (with hiccup as part of it).
      [3] https://github.com/cgrand/moustache
      [4] https://github.com/cgrand/enlive
      [5] https://github.com/weavejester/hiccup
      [6] There is a link in the enlive readme
      [7] https://github.com/LauJensen/clojureql/

------
asymptotic
RE: Nitrogen. I've started using an Erlang RESTful HTTP toolkit called
Webmachine (<http://webmachine.basho.com/>) paired with an Erlang-based
distributed key-value store called Riak (<http://wiki.basho.com/>) and I am
very pleased with the ease of using these libraries. However, I can't offer
you a comparison with other functional languages as I only have experience
with Erlang.

I'm starting an extended and thorough series of technical articles regarding
deploying Webmachine and Riak on Amazon Web Services on my personal website.
Over the next week feel free to follow the articles and see what you think of
Webmachine/Riak!

