Chapter 5. Exploring Clojure and Java interop

 

This chapter covers

  • Introducing Clojure’s Java interop functionality
  • Calling Java from Clojure
  • Compiling Clojure down to bytecode
  • Calling Clojure from Java

Java is the new COBOL. This pronouncement has been made year after year for a few years now, but it hasn’t quite come to pass. Java was originally designed in the early 1990s, was officially released in the mid-1990s, and went on to become one of the most significant technologies of its time. Today, the Java stack is one of the most popular in the industry. It isn’t going away anytime soon.

With the sheer amount of Java code in production (and more being written every day), no modern programming language can hope to succeed without being able to interoperate with it. Rich Hickey chose well when he picked the Java virtual machine (JVM) to host the Clojure language. Not only does Clojure benefit from the state-of-the-art technology (raw performance, HotSpot, just-in-time compilation, adaptive optimization, garbage collection, and more), but it also makes the goal of seamless Java interoperability easier to achieve. The result is that Java interop with Clojure is both elegant and easy to use. We’ll explore this facility in this chapter.

5.1. Calling Java from Clojure

5.2. Compiling Clojure code to Java bytecode

5.3. Calling Clojure from Java

5.4. Summary

sitemap