98

Is there a medium-sized Clojure sample application that could be used as a "best-practices" example, and a good way to see what such an application would look like in terms of code and code organization? A web application would be particularly interesting to me, but most important is that the program do something commonly useful (blog, bug-tracking, CMS, for example), and not something mathematical that I've never ever had to implement in the real world (solving the N-queens problem, simulating Life, generate Fibonacci sequences, and such usual fare of function programming languages).

Thanks!

foxdonut
  • 7,779
  • 7
  • 34
  • 33
  • I was going to ask this exact same question. It makes me wonder how practical it is in the "real world" – ScArcher2 Dec 09 '08 at 05:20
  • 5
    People are too asphyxiated on this "Real world" – Rayne Feb 05 '09 at 14:19
  • I made an IRC Bot with it, it's perfect language for it (performance is not a problem, hot-swapping plug-ins, output is trivially related to input - function). For most other uses it's not very good. Too much CPU wasting and especially too much memory usage, memory churning, cache misses. – RokL Dec 29 '11 at 08:38

14 Answers14

42

I recommend cow-blog by Brian Carper. According to the author it was written with your purpose in mind.

mac
  • 9,885
  • 4
  • 36
  • 51
  • As of 2018, cow-blog does not compile following the instructions. `lein deps` fails with this message: ``` Retrieving gaka/gaka/0.1.0/gaka-0.1.0.pom from clojars Tried to use insecure HTTP repository without TLS. This is almost certainly a mistake; however in rare cases where it's intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS. This is almost certainly a mistake; however in rare cases where it's intentional please see `lein help faq` for details. ``` – Teodor Jun 03 '18 at 10:22
19

If you browse the clojure-contrib source code you can see how libraries are implemented in clojure.

You can also checkout "ClojureScript" under the same source tree.

Allows code written in a very small subset of Clojure to be automatically translated to JavaScript.

The ClojureScript translator is a full Clojure app.

I'd also recomend checking out the Stewart Halloway's Port of Practical Common Lisp samples to Clojure if you haven't already.

Brian Gianforcaro
  • 26,564
  • 11
  • 58
  • 77
  • The monolithic Clojure Contrib library has been deprecated in favor of a set of new modular contrib libraries that can be found here: http://dev.clojure.org/display/doc/Clojure+Contrib (note that Clojure has moved from the richhickey repository on Github to the official clojure repository) – Sean Corfield Nov 24 '11 at 02:45
15

Take a look at Compojure. It's a web framework written in Clojure, so it allows you to write and run (on an embedded Jetty) useful web apps in Clojure, and also serves as a good example of a sizable chunk of real-world Clojure code.

It's under active development and has a helpful Google Group.

Christian Berg
  • 14,246
  • 9
  • 39
  • 44
  • 1
    Since most of the code is now gone from Compojure Ring might be the place to look now. – mac Jun 04 '10 at 07:27
  • A lot of Compojure's HTML generating code is now part of Hiccup I believe (https://github.com/weavejester/hiccup) – mikera Oct 21 '11 at 10:39
10

Check out the ants demo that is written by the author of Clojure, Rich Hickey:

http://clojure.googlegroups.com/web/ants.clj

Here's some nice instructions for getting it setup along with an emacs development environment:

http://riddell.us/clojure

Also check out Rich's presentation that goes along with this code:

http://blip.tv/file/812787

pjb3
  • 5,191
  • 5
  • 25
  • 44
  • 1
    I keep getting redirected when I try to view the source. Oddly I also can't seem to find it through Google. – AnnanFay Dec 14 '11 at 00:50
  • Looks like the blip.tv link is now at http://www.youtube.com/watch?v=dGVqrGmwOAw and I think the description of the code starts about 1 hr 24 mins into the presentation. – Roger Allen Sep 10 '13 at 05:03
7

Clojure itself is a good example of Clojure best practices. Read towards the bottom of Core.clj, good stuff.

Rayne
  • 31,473
  • 17
  • 86
  • 101
6

http://4clojure.com

4Clojure is an open source website where you can solve interactive fill-in-the-blank Clojure problems.

dbyrne
  • 59,111
  • 13
  • 86
  • 103
5

I think that Compojure is probably the best way to go for an example. I doubt it's a "medium sized" example, but there's probably subsections of it that are small that would work. At least, that's going to be my approach. smiles

Also, check out

http://github.com/technomancy/mire/tree/master

which is a small m.u.d. client prototype built in clojure, the advantage being that it's totally self-contained, and probably pretty simple, including the concepts involved. Documentation, eh, it's jus' alright, but the concepts in the code tie very closely to the action elements of the M.U.D. that runs easily.

Kzqai
  • 22,588
  • 25
  • 105
  • 137
5

We're two years on from this question and, whilst that's still early in the cycle for a language, Clojure is definitely being used for serious production work. At World Singles, we have several thousand lines of Clojure in production that handle all sorts of general purpose tasks in our web platform - I blogged about this in my Real World Clojure series.

For some reasonably large open source projects - not exactly applications, but high-profile infrastructure - you could look at Storm from Twitter and Cascalog from BackType (now part of Twitter). 4clojure.com has been mentioned as an open source web application, that's worth a look too, but note the new github repo for 4clojure.

Sean Corfield
  • 6,297
  • 22
  • 31
3

A positive sign: there is an article on InfoQ about "one of the first published reports of Clojure being used in a large-scale production deployment." It doesn't appear to be open, but at least it is a sign of Clojure being used in a mission critical application in the real production world. A big step for the Clojure community.

Jim Anderson
  • 3,602
  • 2
  • 24
  • 21
2

http://code.google.com/p/lighttexteditor/

You could try light text editor

Berlin Brown
  • 11,504
  • 37
  • 135
  • 203
1

You can take a look here: http://bitbucket.org/kumarshantanu/blogjure/overview/

It is a tiny blog application written using Hibernate, Compojure and StringTemplate that actually works!

Shantanu Kumar
  • 1,240
  • 1
  • 12
  • 14
1

I can only recommend you to check out Pedestal, a very promising web framework, both server-side and client-side (where it facilitates ClojureScript). The gui stuff is a bit hard to grasp, but quite much the way it should be done to stay sane in a large app.

claj
  • 5,172
  • 2
  • 27
  • 30
1

edge is a moderately sized application showcasing structuring an application with Clojure, ClojureScript, Component, Yada, Aero, and Boot.

Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
0

Clojure is still too young and a moving target to have medium sized applications with available source code yet.

Marko
  • 30,263
  • 18
  • 74
  • 108