News for hackers. Stuff that matters.

Ask HN: Clojure best practice for web applications?

Does anybody here have experience building a web application using Clojure?

I would like to be able to set up a mysql driven web application using clojure as the language to build it in, but I don't know where to begin to look for the 'best of breed' components to do this with.

This is my first foray in to the big and scary world of functional programming, a trial project to be followed by a much larger one.

Any pointers in the right direction would be greatly appreciated.

( 10 comments | 28 points | on HN )
Re:Ask HN: Clojure best practice for web applications? by tcrayford on Sunday January 10, 2010 @01:36PM (#1043419)
Compojure is a good bet for clojure web applications.

To get you started, have a look at the source for clojars and briancarpers cow-blog.

http://github.com/ato/clojars-web http://github.com/briancarper/cow-blog

Brian Carper has a load of information about using compojure on his site (http://briancarper.net). In particular interest are:

compojure to the rescue: http://briancarper.net/blog/clojure-and-compojure-to-the-res...

deploying clojure sites http://briancarper.net/blog/deploying-clojure-websites

Re:Ask HN: Clojure best practice for web applications? by Quiark on Sunday January 10, 2010 @01:39PM (#1043423)
I wrote a website on Google App Engine using Clojure. I used compojure and some Java library for OpenID. My database was (naturally) Google Datastore for which I had a custom wrapper based on http://github.com/duelinmarkers/appengine-clj/tree/master. I'm not giving the link, because it's all in Czech, so it would be no use for you :)

It was a nice experience, functional programming fits well to website programming (the response is a function of the request and data in the database).

For debugging/development purposes I strongy recommend to reload the code on each request using load-file. Restarting the server every time a change is made is unbearable.

Re:Ask HN: Clojure best practice for web applications? by sunkencity on Sunday January 10, 2010 @01:13PM (#1043388)
Use compojure and clojure commons. You might want to use leiningen too. It is definately worth really checking out the clojure commons thoroughly before you start looking for other software packages, you'll have something to judge them against. For my own purpouses I've found the database bindings in commons good enough, and there's tons of cool stuf in commons that I would like to play with.
Re:Ask HN: Clojure best practice for web applications? by ericlavigne on Sunday January 10, 2010 @04:57PM (#1043734)
I tried a Google search for clojure commons, and your post here was the third result. Maybe you meant clojure contrib?

I wrote a small Compojure application about a week ago. It's only an afternoon's worth of work, plus some cleaning up later, so should also be easy for a newcomer to digest.

The source code is here: http://github.com/ericlavigne/island-wari

You can try out the application here: http://ericlavigne.net:8054

Re:Ask HN: Clojure best practice for web applications? by jacquesm on Sunday January 10, 2010 @05:15PM (#1043776)
Very neat. Can I use your code to jump off from ?
Re:Ask HN: Clojure best practice for web applications? by ericlavigne on Sunday January 10, 2010 @06:18PM (#1043878)
Do whatever you want with it. I hope you enjoy Clojure - I certainly have.
Re:Ask HN: Clojure best practice for web applications? by jacquesm on Sunday January 10, 2010 @06:53PM (#1043919)
Ok, thank you very much, I will definitely credit you in whatever I derive from it.
Re:Ask HN: Clojure best practice for web applications? by sunkencity on Tuesday January 12, 2010 @03:29AM (#1047136)
Yep, sorry, I'm always confusing commons and contrib. What I meant was clojure contrib.
Re:Ask HN: Clojure best practice for web applications? by Rantenki on Sunday January 10, 2010 @01:14PM (#1043391)
Two hours old (albeit on a Sunday), and the only thing in this post is the sound of crickets chirping.

I have been learning Clojure, and the lack of responses is a bit of a surprise.

Perhaps #clojure on freenode will get more responses?

Re:Ask HN: Clojure best practice for web applications? by jacquesm on Sunday January 10, 2010 @02:02PM (#1043463)
thank you all! More reading to do :)