Chapter 13. Why ClojureScript?
This chapter covers
- Protocols underlying everything
- Stages of ClojureScript compilation
- Web Audio
- Advanced Google Closure compilation
- Google Closure externs files
- Differences between compile and runtime
ClojureScript is a redesign and reimplementation of Clojure and its compiler, written in a combination of Clojure and ClojureScript itself. Although the original purpose of the ClojureScript compiler was primarily to generate JavaScript to target runtimes and devices supporting it, in the long term this may be the least important feature of its design. After all, Clojure’s own compiler, which currently generates JVM bytecode, could have been altered to produce JavaScript as well.
In this chapter, we’ll examine the major design differences between Clojure and ClojureScript, and explore the implications of these differences. Even though ClojureScript is newer and designed with all the knowledge gleaned from the development of Clojure, Clojure is by no means abandoned. Instead, ClojureScript is an alternative implementation of Clojure that targets any platform that runs JavaScript. ClojureScript cleverly reuses parts of Clojure such as the reader and macroexpansion machinery. This implies ClojureScript’s design isn’t superior to Clojure’s in every context, so we’ll discuss that as well.