On Wednesday, February 27, 2013 5:19:20 AM UTC+1, Isaac Gouy wrote: > > If idiomatic Clojure was used... >> > > The problem, of course, is that: the code one-person considers to be > idiomatic; another person considers to be idiotic, naïve. > Not really. Take Stuart Halloway's opening example in the section entitled *Why Clojure?*
(defn blank? [s] (every? #(Character/isWhitespace %) s)) Have you ever wondered about its performance? Here you go: user> (time (dotimes [_ 10000] (blank? " "))) "Elapsed time: 3887.578 msecs" Now imagine Stuart's first concern was demonstrating *performant* Clojure: (defn blank? [^String s] (if (or (nil? s) (= (.length s) 0)) true (loop [i 0] (if (< i (.length s)) (if (Character/isWhitespace (.charAt s i)) (recur (inc i)) false) true)))) user> (time (dotimes [_ 10000] (blank2? " "))) "Elapsed time: 4.884 msecs" Yes, it's *eight hundred times *faster. But, would anyone care for that? Why bother learning yet another JVM language, with open parens awkwardly transposed and an inconvenient *loop-recur* construct? This is clearly *not* idiomatic Clojure and that is not a subjective appraisal. -Marko -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.