Posts Tagged ‘performance’

Clojure performs exceptionally well considering it is a dynamic language.

My rule of thumb is:

  • It’s 5-10x slower than optimised Java if you write idiomatic Clojure (with liberal use of higher order functions, lazy sequences and all that goodness)
  • It’s about the same speed as Java if you really optimise hard – you can basically generate approximately the same JVM bytecode.

This StackOverflow question prompted me to write a quicksort implementation in Clojure, which I’ve included here to demonstrate that matching Java speed is entirely possible within Clojure.

Warning against premature optimisation:┬áthis is not pretty code. You shouldn’t be writing code like this unless you have profiled your code and identified a real performance issue.

(more…)

It’s always good practise to define named constants rather than embedding “magic numbers” in your code.

If you are going to do this, then there are some important tricks to make sure that you get the best possible performance out of your constants.

(more…)