r/programming • • Apr 13 '14

Puppet Labs move to Clojure

http://puppetlabs.com/blog/new-era-application-services-puppet-labs
101 Upvotes

30 comments sorted by

View all comments

16

u/strattonbrazil Apr 13 '14

I wish they mentioned performance a bit more. From my personal experiences and almost every benchmark I've ever seen clojure struggles and seems laborious to optimize unless you have a lot of experience with it. I guess it might be comparable to ruby, so it didn't affect them. In my brief use of clojure, the language was very simple and the docs were very easy to use.

9

u/yogthos Apr 13 '14

Could you elaborate on what benchmarks these are exactly. Clojure seems to do pretty well in both the benchmarks game and in the web framework benchmarks.

I'm also not sure what makes Clojure laborious to optimize. Most optimizations tend to revolve around having reflection and Clojure will warn you about functions that are causing reflection when you set the *warn-on-reflection* flag. On top of that the JVM comes bundled with jvisualvm that can be used to easily profile your application and see what actually needs optimizing.

While, without optimizations, the performance is not going to match Java, it's certainly a lot better than Ruby or Python out of the box.

13

u/sdfsfsklfjslk Apr 13 '14 edited Apr 13 '14

Clojure does well on the web frameworks benchmark because there's not actually that much Clojure involved. http-kit and most of the libraries in the compojure example are just tiny wrappers around big Java libraries.

The Clojure benchmarks game entries have also been heavily optimized, and they're still slower, more verbose, and use more memory than the Java equivalents. Clojure might be nice, but idiomatic Clojure is definitely not that fast or memory efficient.

5

u/Tekmo Apr 14 '14

To be fair, that trick is true for a lot of languages in those benchmarks, which have standard libraries that wrap C code.

2

u/igouy Apr 14 '14

That "trick" is true for a lot of languages.

"Lua is a tiny and simple language, partly because it does not try to do
 what C is already good for, such as sheer performance, low-level operations,
 or interface with third-party software. Lua relies on C for those tasks."

4

u/joequin Apr 13 '14 edited Apr 14 '14

You can say idiomatic Clojure isn't fast, but that doesn't mean anything without telling it's what it's slower than. It's still significantly faster than ruby. If you're comparing to java, then it sounds like java isn't even in their consideration when you take into account that they usually use ruby.

Then there's one of Clojure's main benefits. It's often trivial to multithread and as a result you'll multithread things that might not have been worth your time to multithread in other languages including scala.

7

u/yogthos Apr 13 '14

Clojure does well on the web frameworks benchmark because there's not actually that much Clojure involved. http-kit and most of the libraries in the compojure example are just tiny wrappers around big Java libraries.

That's part of the advantage of being hosted on the JVM. You can wrap Java libraries when you need to and get decent performance. The actual application code can be written using idiomatic Clojure and the overall performance will still be plenty fast.

The Clojure benchmarks game entries have also been heavily optimized, and they're still slower, more verbose, and use more memory than the Java equivalents. Clojure might be nice, but idiomatic Clojure is definitely not that fast or memory efficient.

Idiomatic Clojure certainly isn't as fast or memory efficient as Java, but nobody is arguing that. However, when you compare it to other dynamic languages like Ruby or Python there's a big difference to be seen.

For the vast majority of the code in any application raw performance is not all that interesting in any case. The portions of the code that are actually the bottleneck can be optimized or even written in Java if necessary. However, during the 3 years that I've been developing Clojure professionally I haven't had a reason to do any such optimizations yet.

2

u/igouy Apr 14 '14

Have the "Java equivalents" been "heavily optimized'?