Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good Clojure Code Examples? [closed]

Tags:

clojure

I'm in the process of checking out Clojure for the first time. I've found it useful looking at the (doc xxx) and (source xxx) of the Clojure core library, but I'm more concerned with how you would organise and put together a full application.

Are there any excellent, open source examples of this?

For example, to learn how to code well in Java I might look at the Spring source-code, or something similar.

like image 552
lucas1000001 Avatar asked Sep 02 '10 16:09

lucas1000001


3 Answers

Prominent open source Clojure projects:

  • Compojure - a web framework (since you mentioned Spring)
  • Ring - HTTP abstraction API
  • Incanter - R-like statistical computing and graphics environment
  • Leiningen - a build tool for Clojure
  • Clojure-Contrib - you mentioned the core library, but contrib is definitely worth looking at as well.
  • Enclojure - Clojure IDE tools (used with Netbeans/Redcar)
  • Counterclockwise - Eclipse plugin for Clojure
  • 4Clojure - Website with interactive fill-in-the-blank Clojure problems

A few blog posts explaining bite-sized Clojure applications:

  • Pong in Clojure
  • Buddhabrot in Clojure
like image 155
dbyrne Avatar answered Nov 03 '22 16:11

dbyrne


http://corfield.org/blog/archives.cfm/category/clojure

This guy is doing a blog which among other things, has an article series on "real world clojure examples". I think this is one of the best places for this sort of thing, because the articles don't simply provide source files for you to read, he often taken on specific practical problems, describes them first, the rationale behind choosing clojure, and rationale behind choosing a specific way of doing things in each article. (And then some code excerpts as well.) This gives much more eclectic view on the examples themselves, and better understanding of not only What and How, but Why.

(You may want to scroll down a bit in the archives, he has a lot of clojure articles which are good themselves, but this post is especially true about the mentioned "real world clojure" series, which begin with articles like http://corfield.org/blog/post.cfm/real-world-clojure-email-status-tracking)

like image 25
Cray Avatar answered Nov 03 '22 17:11

Cray


I find that looking at the project.clj for most of these projects is a good first step in getting a good idea of the core libraries these projects are relying on. Mostly if one of the more popular and heavily used open source libraries, like Compojure for example, are using certain base libraries, like Ring in the case of Compojure, I can then focus on how those base libraries are being leveraged. This is how I got a good idea of how Ring middleware works and that helped me understand Noir worked and allowed me to also understand how one could substitute something like Grizzly for Jetty or how to implement something like OAuth 2 using just middleware.

like image 2
Marc Avatar answered Nov 03 '22 17:11

Marc