Clojure

Like many other clojurians, my clojure journey started with this presentation by Rich Hickey: Simple Made Easy.

Get started

most easy way is using Leiningen, after installed lein

  1. lein new hello
  2. cd hello
  3. lein repl

first thing to learn is how to get help:

  • (pprint (loaded-libs)) to get currently loaded namespaces
  • use dir to get list of available functions, for example (dir clojure.string), ns-publics to get the mapping
  • use doc to get more info, (doc clojure.string/replace)
  • use source to show source code, (source clojure.string/replace)
  • use find-doc to search, accepts a regexp, (find-doc #"javadoc")

(above functions are under clojure.repl namespace)

to show methods of an java object:

(map str (vec (.getMethods (.getClass theJavaObject))))

Style Guide

check this repo for clojure style guide: bbatsov/clojure-style-guide · GitHub

you can also find best practices for the very confusing ns form: :require, :import, :use, :refer

Editor

emacs with cider of course.

for quick start Light Table is great.

IDE style may try IntelliJ with JetBrains/la-clojure.

My reading notes

Snippets

run any class inside a jar

java -cp my-standalone.jar clojure.main -m my.class

Resources

quick reference

documentation

library directory

news

exercise

books

Clojure for the brave and true is a good place to start with.

some other free books, from vhf/free-programming-books · GitHub:

Search Blog: