Skip to Content
Professional Clojure
book

Professional Clojure

by Jeremy Anderson, Michael Gaare, Justin Holguín, Nick Bailey, Timothy Pratley
June 2016
Intermediate to advanced
264 pages
7h 28m
English
Wrox
Content preview from Professional Clojure

Chapter 7Performance

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.

—Donald Knuth

In this chapter you will implement tools and techniques to make code execute faster. How fast can a dynamic, lazy, functional, immutable language be, you ask. Pretty fast. You can expect Clojure code to take around 2–5 times the amount of CPU of equivalent Java code. With a little work you can tweak it to be as fast as Java code. In turn, you can expect Java code to perform at around 1.2 times C. This is amazing considering the high-level abstractions you get to leverage from Clojure. Compared to dynamic languages like Ruby, Clojure is blazingly fast.

So, how does Clojure achieve such great performance? The answer is the JVM. Clojure embraces its host platform and relies on its mature byte code optimization. The same holds true for ClojureScript (relies on the Closure Compiler) and ClojureCLR (embraces the .NET runtime). There is an intentional tradeoff made to embrace the underlying platform and not completely abstract it away. The benefit is performance and interoperability. The downside is you have to live with some unsightly details of the underlying ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Clojure Recipes

Clojure Recipes

Julian Gamble
Living Clojure

Living Clojure

Carin Meier
Clojure: High Performance JVM Programming

Clojure: High Performance JVM Programming

Eduardo Díaz, Shantanu Kumar, Akhil Wali

Publisher Resources

ISBN: 9781119267270Purchase book