The Holy Java

Building the right thing, building it right, fast


Clojure-related resources and notes.

Why Clojure?

Clojure(Script) is simpler yet more expressive (than Java(Script))
– paraphrase of David Nolan in ClojureScript Next

Nate Wildermuth: ClojureScript and the Blub Paradox

(highlights and [insertions] mine)

That makes the important advantages of ClojureScript hard to perceive, as the essential difference [from JS] belongs in new patterns of problem solving rather than new syntax and grammar.

ClojureScript does the opposite. Instead of seeking to avoid the danger of using one bug-prone function, it provides three types of switch statements, each suited to different kinds of control flow. These options not only allow one to engage in high-level forms of abstraction, but actually encourage this kind of thinking. Moreover, the entire pattern of thought begins at a much higher level, seeking to recognize patterns even before fully understanding the solution. [The same applies for Clojure and Concurrency, having cca 4 ways to manage state instead of Java’s one -makes you think about what/why/how, which is a Good Thing (TM)]

ClojureScript, like JavaScript, doesn’t come with pattern matching. This would be a problem, except that ClojureScript comes with something better: macros.

Some languages run close to the “metal” — […]. Other languages take the opposite approach, running close to the “human metal” — our minds. The closer that a language can express (or in the case of macros, be modified to express) human thoughts, the closer we get to a program that we can understand natively. We no longer need to change our thoughts to fit the language. Instead, we change our language to fit the thoughts.




Convenience libraries – the missing “features” of clojure.core etc.

  • ztellman / potemkin – “a collection of facades and workarounds for things that are more difficult than they should be” – f.ex. import-vars so that we can expose a single namespace with everything to users while having the code split in multiple files, def-map-type so that we only need to implement the 4 essential functions, def-derived-map – as a view on another object, f.ex. JavaBean, definterface+ – same syntax as defprotocol but creating an interface with its memory/performance benefits => easy to switch, fast-memoize and more
  • cloojure/tupelo (and cloojure/tupelo-datomic) – convenience features “missing” from clojure.core – e.g. the awesome (spy[x[x]]) for logging the expression [+type] going through a threading macro or a fn, …)
  • marick/suchwow – Functions and behaviors not present in Clojure core. Support for creating and using your own “favorite functions” namespace. Better docstrings for clojure.core functions. More expansive versions of clojure.core functions.
  • plumatic/plumbing – Prismatic’s Clojure(Script) utility belt (including Graph – a simple and declarative way to specify a structured computation)
  • weavejester/medley – A lightweight library of useful Clojure(Script) functions (a tighter focus than useful and plumbing, and limits itself to a small set of general-purpose functions.)
  • flatland/useful


Development in general



  • Chestnut (10/2014) – A Leiningen template for a Clojure/ClojureScript app based on Om, featuring a great dev setup, and easy deployment. Highlight: well-functioning browser-connected REPL, see a demo by D. Nolen who labels it “one of the coolest bits of ClojureScript tech I’ve encountered in a very long time.” The REPL is “always ready to go even if you kill the web server, refresh the web page, or have a JS exception on the page.” and there is live reload upon file change without corrupting the app state.
  • lein-figwheel – Figwheel builds your ClojureScript code and hots loads it into the browser as you are coding – live code and CSS reloading
  • weasel – WebSocket-connected REPL environment for ClojureScript – especially useful if the standard REPL doesn’t work because the page does not allow for iframes and/or does not use http://
  • clj-devtools – Better presentation of ClojureScript values in Chrome DevTools


  • juxt iota – simplify running multiple checks on a (complex) data structure



  • clojure/tools.trace – trace calls, f.ex. run (trace-ns my.ns) to print call with params and return value of each function
  • Schmetterling – Debug running clojure processes from the browser! – upon an exception, the process will pause and S. will show the stack, which you can navigate and see locals and run code in the context of any stack frame; you can also trigger it from your code. It can be used nicely also in pre/post-conditions.


  • lein-ancient – analyzes your project.clj and lets you know which dependencies are out of date.
  • lein-try – start a REPL with various dependencies without needing a project. Great for exploring new libraries!
  • Eastwood – a lint tool for Clojure.

Lib catalog

From Clojure to Java

  • UncleJim (“Unmodifiable Collections for Java™ Immutability”)  is a very interesting looking library, with these main features:
    • Type-safe versions of Clojure’s immutable collections, implementing the generic java.util collection interfaces.
    • A simplified immutable alternative to Java 8 Streams, wrapping checked exceptions and avoiding primitives.
    • A tiny, type-safe data definition language of brief helper functions: vec(), set(), map(), and tup(), (like Clojure’s vector [], set #{}, and map {}).
    • Extend Tuples to make your own immutable Java classes (with correct equals(), hashCode(), and toString() implementations) almost as easily as writing case classes in Scala.


Cljs: 23kB

(-> (dom/getElement “app”)
(dom/setTextContent (join “, ” [“Hello” “World!”])))

jQuery: 29kB (+ 45kB Immutable.js)

[“Hello”, “World”].join(“, “));

Source: SeatleJS – ClojureScript for Skeptics by @derekslager


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: