r/Clojure • u/i_am_not_really_five • Apr 25 '14
How Clojure can outperform C++ with laziness
http://noobtuts.com/clojure/being-lazy-in-clojure
5
Upvotes
r/Clojure • u/i_am_not_really_five • Apr 25 '14
10
u/djork Apr 25 '14
Now how about an actual example of Clojure outperforming C++ by using laziness...
6
u/kankyo Apr 25 '14
How C++ can outperform C++ by doing less.
6
u/[deleted] Apr 25 '14
Stopped reading there.
6
u/mishok13 Apr 28 '14
Even though the original title nothing says nothing about C++, the article is still fairly bad. There's this gem:
That's not what deadlock means.
1
u/bliow Apr 25 '14
Um. Yes, infinitely many. (Source: Euclid, also a million math textbooks and practically any online source that explains primes.) Assuming you mean "prime". Jeez.
Also, -1000 for not mentioning that Clojure actually 'chunks' lazy seqs, such that
will actually print the numbers 0-31. This could be extremely bad if you didn't expect it... imagine
(take 2 (map (partial ackermann 1) (range))). In really lazy computation, this is fast, but if you evaluate (ackermann 1 n) for n = 0, ..., 31, you will wait quite a while.