3 ms·
True that. This conforms with my understanding as to why Clojure is slowish. That being said, I don't really understand why Haskell is seen as fast and Clojur
by jgalt212 11y ago
True that.
This conforms with my understanding as to why Clojure is slowish. That being said, I don't really understand why Haskell is seen as fast and Clojure is seen as slow (I am ignoring JVM warm-up times here).
Do they use fundamentally different algorithms under the covers?
- arohner 11y agoClojure isn't very slow. It's possible to write Clojure with identical performance of java (though this isn't idiomatic, and avoids some of Clojure's nicer features). Clojure's immutable datastructures are ~25% slower than standard java, but also eliminate entire classes of bugs. I'm not familiar with Haskell's immutable data structures, but I'd be very surprised if there's an optimization that hasn't been adopted by Clojure. Rich Hickey put a lot of work into optimizing them.
- tel 11y agoHaskell's GHC is a super clever optimizing compiler with a garbage collector built around the sort of memory pressure that arises when you've got tons of immutable data. Some of GHC's brand of speed comes from the super optimization bits where GHC automatically intuits out a mutating, low level, primitive loop out of your high level description. Some comes from loads and loads of tuning. Clojure cannot benefit from the latter because JVMs are tuned differently and cannot benefit from the first because it has less good transformation semantics.