O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required