Book Image

Clojure High Performance Programming, Second Edition - Second Edition

By : Shantanu Kumar
Book Image

Clojure High Performance Programming, Second Edition - Second Edition

By: Shantanu Kumar

Overview of this book

Table of Contents (15 chapters)
Clojure High Performance Programming Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Performance miscellanea


Besides the major abstractions we saw earlier in the chapter, there are other smaller, but nevertheless very performance-critical, parts of Clojure that we will see in this section.

Disabling assertions in production

Assertions are very useful to catch logical errors in the code during development, but they impose a runtime overhead that you may like to avoid in the production environment. Since assert is a compile time variable, the assertions can be silenced either by binding assert to false or by using alter-var-root before the code is loaded. Unfortunately, both the techniques are cumbersome to use. Paul Stadig's library called assertions (https://github.com/pjstadig/assertions) helps with this exact use-case by enabling or disabling assertions via the command-line argument -ea to the Java runtime.

To use it, you must include it in your Leiningen project.clj file as a dependency:

:dependencies [;; other dependencies…
                            [pjstadig/assertions...