Chapter 10Java Interop

Clojure’s Java support is both powerful and lean. It’s powerful, in that it brings the expressiveness of Lisp syntax, plus some syntactic sugar tailored to Java. It’s lean, in that it compiles to bytecode without a translation layer and can thus achieve Java-level performance in nearly every case.

Clojure embraces Java and its libraries. Idiomatic Clojure code calls Java libraries directly and doesn’t try to wrap everything under the sun to look like Lisp. This surprises many new Clojure developers but is very pragmatic. Where Java isn’t broken, Clojure doesn’t fix it. In this chapter, you’ll see how Clojure’s access to Java is convenient, elegant, and fast. In addition, you’ll see how to flip the script and call Clojure ...

Get Programming Clojure, 3rd Edition 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.