Using Reader Conditionals, compile to Clojure, and ClojureScript

Codes in Clojure and ClojureScript are almost the same but there are few differences. For instance, libraries provided by Java and JavaScript are quite different. Host environments between JVM and JavaScript runtimes are also different.

Before the version 1.7, we use the cljx plugin to keep compatibility between them. However, it requires a tooling and the style is not clean.

For such a situation, Clojure 1.7 introduced Reader Conditionals are introduced. Reader Conditionals have richer semantics than cljx, such as default expressions and form splicing and no prepossessing.

Using Reader Conditionals, we can share source code among Clojure, ClojureScript, and ClojureCLR. In this recipe, ...

Get Clojure Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.