Building

Applications With

Toby Crawley

EclipseCon 2014

What is Clojure?

  • A functional lisp for the JVM
  • Consistent syntax
  • Dynamic, strong typing
  • (Almost) Everything is immutable
  • Compiles to bytecode and JS (ClojureScript)

Collections

  • List: (1 2 false)
  • Vector: ["ham biscuit" 7 (1 2 3)]
  • Map: {"key" "value", 1 true}

Collections as values

  • List: (1 2 false)
  • Vector: ["ham biscuit" 7 (1 2 3)]
  • Map: {"key" "value", 1 true}

Code is data

(println "Hello friends!")
(doseq [technology ["Vert.x" "Netty"]]
  (println technology "is the bomb."))

Java Interop

(import '[java.util.concurrent CountDownLatch TimeUnit])

(let [latch (CountDownLatch. 1)
      thread (Thread.
               (fn []
                 (println "Thread started")
                 (.countDown latch)))]
  (.start thread)
  (.await latch 10 TimeUnit/SECONDS))

Drawbacks

  • Static runtime

Examples

Takeaways

Resources

Questions?

hands.jpg

Credits