Hacker News new | ask | show | jobs
by buckwild 5219 days ago
Does anyone know of a good web framework for Clojure? Perhaps a rails of django equivalent?

I love using Java for the exact reason the author claims Clojure is so powerful--the magnitude of libraries.

If a decent web framework is available, then I would be inclined to give it a go.

8 comments

There's some (none so mature as django or Rails)... take a look at Noir (http://webnoir.org/)

However, the Clojure philosophy seems to be trending towards building your own composition of highly composable micro-libraries, rather than being handed one monolithic framework. It works very well, but does have the side effect that there isn't real "one stop shop" for beginners.

And when you're designing a webapp (or any app) in Clojure, you'll notice that you have a much higher degree of freedom regarding how to do things. There's no "one true way" the way there is with Rails. Again, this is extremely powerful, but it makes the next step somewhat less obvious for beginners.

I wrote Noir primarily to help people new to Clojure to get up and running really quickly. It provides a simple set of core abstractions that allow you build whatever you want. As others have said though, I don't think something like Rails or Django should exist in Clojure. Large frameworks like those are very limiting and I would argue don't really end up letting you build real apps any faster than you can using simple composable libraries.

There's immense value in the approach the Clojure ecosystem has taken. For example, how many other places can you seamlessly swap out your webapp's server from something like jetty (thread-based) to tomcat (battle-hardened) to netty (NIO) to ...

FWIW, https://www.readyforzero.com/ is a non-trivial app in production that is built entirely on Noir.

Nearly everything web in Clojure is built on Ring. I personally like using Compojure (which bundles together clout for routing and a bunch of good defaults for sites or web services) and Enlive (for templating). This is the stack we describe in depth in the web portion of the book.

Frameworks are largely not used, at least in the monolithic, un-composable way that 'frameworks' generally are in other languages. This is what makes it so easy for alternative conceptualizations of the problem to come about (i.e. Noir, which also uses Ring and Compojure, but with different defaults, some macro sugar, and hiccup for templating), and themselves to be mixed/integrated with other web codebases. For example, you can trivially compose a noir application with a couple of "low level" Ring handlers with another app written using Moustache and stringtemplate.

That is all to say, yes, you'll find all the pieces you need for web development.

This is probably the best overview out there: http://brehaut.net/blog/2011/ring_introduction, though it doesn't mention the new kid on the block, Noir (http://www.webnoir.org/)
If you love Java and want a magnitude of libraries, and don't have any particular attachment to Lisp syntax or dynamic typing (which 'love Java' seems to imply), then it would benefit you to check out the Play [1] and Lift [2] frameworks as well. Lift is Scala-based but is 100% interoperable with Java libraries, and Play apps can be written in either Java or Scala and is also 100% interoperable with Java. Play is quicker to learn, Lift has superb built-in security and very easy Ajax/Comet.

1. http://www.playframework.org/

2. http://liftweb.net/

Thanks SkyMarshal, I use Play all of the time. I've never tried Lift though--I might give that a go soon as well. I'm curious about whether or not there is a framework of Clojure however. From the responses, it seems like Noir is the popular solution these days :-)
Ok, cool. It wasn't clear whether you wanted Clojure-only, or might be interested in other acceptable JVM-based ones. As for Lift, the folks on the mailing list (liftweb @ Google Groups) are very helpful when it comes to figuring out whether Lift is appropriate for any given project or not (basically, do you specifically need its features and have a developer team with the ability and bandwidth to ramp up quickly enough for your deadline).

PS - nothing against Clojure, not trying to hijack this whole thread, just add to it. Clojure + Scala makes the JVM a truly awesome platform. The power and features of both Lisp and ML, the brevity of both.

Note that everybody says Noir because Noir is the only thing that could be called a 'framework'. I pretty sure most clojure webapps are not written in Noir itself, people use all kinds of diffrent combinations of librarys to gather alot of the feature a framework would give you.
many said noir, there's also http://clojurescriptone.com which is noir plus a seemingly working integration of clojurescript
There's Noir, which is more minimalistic that Rails, but it's easier to customize as a result. I've had some fun playing around with it, but I personally haven't used it in production yet.

webnoir.org