Idiomatic Clojure without sacrificing performance
The biggest performance issue Clojure has, which isn&#x27;t mentioned in the article and is fundamentally unsolvable, is that it misses the CPU cache - a lot.<p>The data structure that drives the immutable variables, the Hash-Array Mapped Trie, is efficient in terms of time- and space- complexity, but it&#x27;s incredibly CPU cache-unfriendly because by nature it&#x27;s fragmented - it&#x27;s not contiguous in RAM. Any operation on a HAMT will be steeped in cache misses, which slows you down by a factor of hundreds to thousands. The longer the trie has been around, the more fragmented it is likely to become. Looping over a HAMT is slower than looping over an array by two or three orders of magnitude.<p>I don&#x27;t think there is really a solution to that. It&#x27;s inherent. Clojure will always be slow, because it&#x27;s not cache friendly. The architecture of your computer means you physically can&#x27;t speed it up without sacrificing immutability.