5 ms·
Clojure is slower than Java.
by glibgil 13y ago
Clojure is slower than Java.
- simias 13y agoBut is it slower than the equivalent functional code ported to Java?
- glibgil 13y agoYes, of course it is. Nothing in Clojure is faster than Java, not even functional programming.
- chongli 13y agoNothing in Clojure is faster than Java, not even functional programming. Right, but that's completely ignoring programmer efficiency (or sanity). Trying to do the things that Clojure was designed for in Java is a recipe for pain.
- glibgil 13y agoNo, it works fine. If you are doing FP then things stay well organized no matter the language.
- chongli 13y agoNo, I'm talking about the things which Clojure is really good at. Macros, embedded domain-specific languages etc. Try doing something like core.logic in pure Java.
- glibgil 13y agocore.logic can be done cleanly in Java, no problem. For example, here is an FP library in pure Java. Nice clean code. Easy to use. https://code.google.com/p/totallylazy/ https://code.google.com/p/totallylazy/
- Tuna-Fish 13y agoIf you are using Clojure's built-in types to do fp vs Java's built-in types, Clojure will win by an absurd margin.
- glibgil 13y agoYou don't need Java's built-in types when you are doing FP in Java. In fact, it is not really FP if you do. Java FP is faster than Clojure in everything.
- simias 13y agoUh, I didn't expect that. How come? Does it mean that writing a Clojure-to-Java transpiler would yield better results than using the "native" Clojure implementation? It seems backwards to me that an implementation designed specifically for functional programming fails to beat the more "generic" (or arguably OOP-oriented) language on its own turf.
- chii 13y ago> Does it mean that writing a Clojure-to-Java transpiler would yield better results than using the "native" Clojure implementation? yea, it does sound weird, because if a closure-to-java compiler yields better results, then why not just use that as the closure compiler? I agree that hand writing a piece of code in java that did the exact same thing as a piece of closure code would be faster in java than closure, because the programmer could make shortcuts where he knows he could.