Hacker News new | past | comments | ask | show | jobs | submit login
Clojure Programming (clojurebook.com)
194 points by turbinemonkey on Feb 27, 2012 | hide | past | favorite | 36 comments



I have been interested in learning Clojure for some time (spent many years as a Java dev, and intrigued by the chance to develop again on the JVM and learn a Lisp style language). This is a resource I have bookmarked as potentially helpful when I get around to learning: http://blackstag.com/blog.posting?id=5

I haven't had the chance to check it out yet so can't vouch for quality. But it seemed that a few people on the thread are considering getting into Clojure, so I thought I'd share.



Anyone have insight into how this might complement / compare with "The Joy of Clojure" http://joyofclojure.com/the-book? At first glance, having read JOC and seeing the TOC for this new book, what most piques my interest are the sections on macros, protocols, and the web stuff.


I imagine that Clojure Programming is going to be similar to Programming Clojure, when compared to the others (for a better rundown of others books: http://stackoverflow.com/a/2928998) Or as this answer from SO puts it, Clojure Programming probably teaches the "what" of Clojure: http://stackoverflow.com/a/2579877

Personally, I think Joy of Clojure is the "why" as well as "how to do it well". I learned the "what" mostly from Practical Clojure, which was good enough, but definitely not great. Programming Clojure (2nd ed. for clj v 1.3, still in progress) seems organized like a conversation in chapters, i.e., you'd have to read it entirely sequentially, and targeted random-access might be difficult for first-time learners. I don't how Clojure Programming will be, but I hope it raises the bar for teaching newbies.


IIRC, O'Reilly was flat-out refusing to publish any Lisp books as recently as 2005. How things have changed. :)


Last I looked, their author proposal FAQ still has that exclusion.

FYI, a Common Lisp book nearly made it out of the gate a couple of years ago, Nick Levine's 'Lisp Out of the Box'. The contents of it are available under a Creative Commons license:

http://lisp-book.org/


Looks like that exclusion is still there: http://oreilly.com/oreilly/author/writeforus_1101.html

It seems to be a strong recommendation rather than a hard rule, though. Clojure is worthy of an exception in my opinion.


Thanks for this! I took a look at the home page and have bookmarked the page.

I've been dabbling in Lisp (read Land of Lisp and am going through PCL) and eventually I'd like to create my own text-based game using common lisp. However, I am indeed wondering if/how it would make sense to use it at work.

I mostly do full stack web stuff (ruby/sinatra/rails, javascript) and I'm not at all sure where Lisp would fit in. In fact, I don't really know what it brings to the table except its expressiveness. As opposed to e.g. python, java, c, or objective-c where I have a decent idea of the domains where they shine.


I think you'll find Clojure to be superb in the web space. I've never been a ruby guy, but I did spend a lot of time with python in web dev, and Clojure compares very, very well IMO. In short, all the creature comforts of ruby/python + an efficient runtime + an unbeatable selection of libraries.


Thanks! This and the other comments in the thread are definitely motivating me to check out clojure. My dream of the moment is to make my command-line text-based game playable through a web front end and deployed to heroku using the clojure buildpack. I think that will give me at least, like, 5 geek points.


I actually wasn't aware of the 'clojure buildpack' until you mentioned it. All I've ever done to put Clojure/Ring apps on Heroku is add a one-line Procfile to my Leiningen project, and `git push heroku`. :-)


Just curious, does anyone know why O'Reilly would refuse to publish any Lisp books?


I guess they didn't consider the market for Lisp books very profitable:

»We're NOT looking for: (...) Books on topics that have dismal sales despite quality books being available. (If you're addressing a topic where good books have sold dismally in the past (for instance, LISP, LaTeX, or Web-based training), you have a much higher threshold to clear with your proposal. Convince us why there is a revival of interest in your topic, or why your approach to a deadly topic will provoke interest nonetheless.)« (from http://oreilly.com/oreilly/author/writeforus_1101.html)

However, in 2009 an O'Reilly editor wrote: »I think there's reason to believe that's changing, particularly with the right book; LISP awareness has been growing for the past couple of years. Our Haskell book has outsold expectations; Erlang has obviously made a comeback; so there has been a relatively recent shift in the language map.« (from http://lisp-book.org/talks/eclm-2011-10-23/plan.txt)


Because it takes some effort to write a good Lisp book. There are several very good books: SICP, PAIP, AMOP, On Lisp, PCL, LoL, ...

Also typical Lisp hacker won't buy a slightly edited and printed version of the HyperSpec or a printed version of the SBCL manual.

Add to that that Lisp made a deep dive after the AI winter and that they were sure to not sell enough copies. At that time it was also a good idea not to be connected to Lisp.

Plus, I guess they did not like Lisp. 'Clojure' has the 'advantage' not to use 'Lisp' in its name.


I suspect the answer is more simple than you make out. They will not publish what they are sure will not sell.


LISP


FWIW, we didn't go to O'Reilly; they were shopping around for someone to write a Clojure book. So, whatever guidelines they have out there probably shouldn't be taken as actual "policy".


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.


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


I'd still love to see a ClojureScript book that doesn't assume you already know Clojure. Put me in a repl and have me modifying a web-page, as opposed to writing command-line applications.


I think you're looking for this: http://clojurescriptone.com/


Now that you've written a full technical book, what are your thoughts about how technical book publishing is done and how it can both better serve the authors creating the content and be better presented to your readers?


is anyone putting Clojure to good use? i've been reading about it for a while, but still can't find a practical use for it. i know .Net framework in and out, and it just makes everything so easy.. not sure what Clojure could offer me at this stage, even though i love its notation (the little that i know so far).


The truth is, if you're a .NET programmer, you're going to find Clojure slightly painful because you're switching ecosystems. Using it for work will encounter the same problem and ClojureCLR is a second class citizen.

That's not to say it isn't great and useful, it is. I'm noticing a couple of trends in Clojure development: big data and esoteric. Take a look at Storm (twitter's data processing engine) and Overtone.


Why Clojure? What makes it better than anything from the huge range of choice developers already have?


Very quickly: Simplicity, Speed, Power.

Simplicity: it's easier to reason about a Clojure program. Speed: Idiomatic Clojure tends to be as fast as Java when it matters. Power: If an abstraction you need isn't present, you can write your own. Code reuse is insanely high.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: