(Semi) first look at Clojure
OK, it's time for Clojure (again). Let's look at the (now famous :) Fibonacci function:
It took ~9 seconds which's not so good as would be (however, I'm not very frustrated about that :)
What about the language itself, it feels very 'tired' - it has little build-in constructs and, I believe, it's extremely flexible. Time will tell if I'm right... :)
However, there's one annoying thing - lazy sequences, which I almost hate in C# (IEnumerable) because they must not be mixed with any side effects, which is rather hard to achieve in such a primarily imperative language as C#. So, I have a believe that laziness is very much nicer in Clojure :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn fib [n] | |
(if (< n 2) | |
n | |
(+ (fib (- n 1)) | |
(fib (- n 2))))) | |
(time | |
(doseq [n (range 40)] | |
(prn (format "Fib(%s) = %s" n (fib n))))) |
It took ~9 seconds which's not so good as would be (however, I'm not very frustrated about that :)
What about the language itself, it feels very 'tired' - it has little build-in constructs and, I believe, it's extremely flexible. Time will tell if I'm right... :)
However, there's one annoying thing - lazy sequences, which I almost hate in C# (IEnumerable
Comments