Understand ClojureScript

Web Development with Clojure, Third Edition — by Dmitri Sotnikov, Scot Brown (26 / 107)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Chapter 4 Introducing ClojureScript | TOC | Add ClojureScript Support 👉

If you’ve worked with JavaScript, you’ve probably noticed that it has a few shortcomings. Still, JavaScript does have the advantage of being a standard programmable environment for all of the modern browsers. JavaScript has become an essential part of front-end development as the demand for rich client-side applications continues to grow.

It would be nice to leverage this platform with a robust programming language like Clojure, wouldn’t it? This is precisely where ClojureScript comes into play. Much like its cousin Clojure, ClojureScript embraces its hosting platform and allows seamless interoperability with JavaScript. We can continue leveraging mature JavaScript libraries while enjoying the benefits of Clojure language semantics.

And if you’re using Clojure on the server, then it’s possible to share code between the server and the client. One example where this is useful is validation logic that can now be written in a single place.

You should be aware of a few details when using ClojureScript. Since ClojureScript runs in the browser, you can’t leverage any code that relies on interfacing with Java. The syntax for interop with JavaScript is also slightly different from that for interacting with Java. Keep those facts in mind, though, and you’ll…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.