Learning Clojure coming from Lisp [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this questionI'm thinking seriously of making Clojure my new hacking language since I love Lisp but have some problems with CL and Scheme. I've never worked in the Java environment before and my lisp experience is limited to working through "SICP" and "The Little Schemer."
What do I need to know? Are there any good resources on "The Clojure way?" Any resources on Clojure style? I've found Mark Volkmann's excellent page, but the books I've looked through seem a little spare.
Also, what do I need to know about Java? I'd rather not learn Java just to learn Clojure, but I imagine I'll have to know at least a little. Also, what is the workflow like? My experience is limited to dynamic languages, so I have no idea what I'd have to do to distribute an application without source on the JVM.
I've googled this obviously, but there's a large amount of information and not ve开发者_开发知识库ry much "clojure specific" stuff.
I guess I'm looking for some sensible suggestions on the kind of literature I should read in some sort of logical sequence.
You can't go wrong watching as many of the Clojure videos on Blip.tv as you can handle, especially those by Rich Hickey himself. These really help drive home the conceptual points and aspects unique to Clojure.
If you are sufficiently familiar with Lisp concepts, you may want to initially focus on learning how Clojure "maps" to the Lisps you've played with. Watch the videos by Rich Hickey on "Clojure for Lisp Programmers."
You do need to have some familiarity with Java, because Clojure doesn't shy away from using it. It's not somehow un-Clojurey (as far as I can tell) to use Java where it's smart. I'd at least skim through the API docs for the java.lang
and java.io
packages, because java.lang
is automatically available within your Clojure programs and java.io
is used frequently.
With my Clojure-to-Lisp dictionary in my head and my Java basics behind me, I'd pick a small project to work on. Keep the Clojure and Clojure-contrib API docs handy (either on the web or use the (doc) command from the REPL), and peruse the many, many Clojure blogs out there. Two of my favorites are http://nakkaya.com/ and http://stuartsierra.com/. If you use Diigo, a whole slew of blogs have been bookmarked to the clojure group.
NOTE: don't get hung up on your dev environment. There are a multitude of options listed on the Getting Started wiki page. For learning Clojure and your first small projects, I'd just pick your plain text editor of choice, learn and use the basics of Leiningen to get a nice project directory setup with all your paths and dependencies taken care of, then use the command "lein repl" to startup a REPL with all of your dependencies loaded and available. In assuming you use Emacs (based on your previous Lisp experience), you can describe-variable
your inferior-lisp-program
to be lein repl
, and just start Emacs from the root of your example project for everything to work automagically.
There are books you can read, notably The Joy of Clojure, Programming Clojure and Practical Clojure. The latter two are more "practical" than the first, which is more "philosophical" (excuse the gross generalizations). Practical Clojure is up-to-date with Clojure 1.2, whereas Programming Clojure is a little bit older.
Finally, get on the #clojure IRC channel and use the Clojure Google group, because there's a bunch of smart, friendly folk who enjoy helping others.
Just a quick perspective from someone who came to Clojure from the other direction (Java -> Clojure)
- I actually found the Lispy parts of Clojure easy to learn once I got my around the syntax and common idioms. I expect that will be even easier for you.
- You don't really need much knowledge of Java to do most things - you can do pretty much everything in pure Clojure if you want to.
- It's probably only when you start wanting to use Java libraries that you will need to dive into Java interop. Fortunately, the interop is very simple - it's more LISP-style than Java style, so the only thing you will need to figure out is how to understand Java interfaces and make the appropriate call from the Clojure side.
For my environment, I use Eclipse + Counterclockwise. This works exceptionally well if you like IDEs and/or think you may ultimately want to do some work in Java as well. It requires no further dependencies, gives you an excellent debugger, has a full REPL (an embedded nREPL I believe), does all the project file management (Git, SVN etc.) and automatically handles things like the Java classpath setup for you (which can be a major obstacle for newcomers to Java!). I'd recommend checking it out if you think that might suit your style, I've also heard good things about Enclojure as well.
If you're not into IDEs, then you're probably best with your favourite text editor and command line tools as semperos suggests in his excellent answer.
精彩评论