In short, it doesn't. And I think the fact that Clojure is as fast as it is
is testament to how little of an impact many of these optimizations have.

But also, don't assume that Clojure doesn't get many of these optimizations
for free from the JVM. Auto-caching is a weird one,  I think most people
just don't compute the same thing twice. But out-of-order execution is an
optimization performed by both the JVM and x86 CPUs. If a given line of
code doesn't call a native (non-JVM) function and if a given bit of code
doesn't depend on another bit of code, those two bits may be reordered or
executed in a different way. And modern CPUs may actually execute those
bits in parallel if given conditions are met.

So it's true, the Clojure compiler isn't that sophisticated, but combined
with the JVM it's optimizations are actually quite powerful.

Timothy

On Thu, Feb 19, 2015 at 5:11 AM, Ashish Negi <thisismyidash...@gmail.com>
wrote:

> I tried to find old threads for my question but could not find any
> suitable answer.
>
> My question is that unlike haskell, which separates I/O side effect code
> from pure code, and hence can easily do other optimizations
> like auto-caching results, out of flow execution etc, what is the clojure
> way of doing these optimizations ?
>
> I ponder over that since one can call side-effecting-functions any where
> in clojure code, How is it possible to do all those optimizations that we
> talk
> about in case of FP ?
>
> Thanks
>
> --
> 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/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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/d/optout.

Reply via email to