I have to wonder a bit about the ability to optimize.  Everything
boils down to one of the seven or so basic forms.  That's a lot of
function calls to do even small things, like adding numbers. You might
think that simple math would be optimized and inlined, but it isn't:

Clojure
user=> (doc +)
-------------------------
clojure.core/+
([] [x] [x y] [x y & more])
  Returns the sum of nums. (+) returns 0.
nil
user=> (ns clojure.core)
#<Namespace clojure.core>
clojure.core=> (defn + [x y] (* x y))
#'clojure.core/+
clojure.core=> (+ 3 5)
15
clojure.core=>

This implies, to me, that Clojure is doing a full functional call,
with dynamic lookup via the namespace, even for +.  To me, this means
that Clojure will never be as fast as Java code *when implementing the
same algorithm*.  Clojure will be faster when taking advantage of
laziness and concurrency and that's fine by me.

I would bet Clojure is top tier, perhaps even fastest, among dynamic
languages for the JVM because of the superior Java  interop,
especially when you help it out by defining symbol types (so it can
generate type appropriate method calls, rather than using reflective
access).


On Thu, Mar 12, 2009 at 12:00 PM, Mark Addleman
<mark_addle...@bigfoot.com> wrote:
>
>
>
> On Mar 12, 10:56 am, Stuart Sierra <the.stuart.sie...@gmail.com>
> wrote:
>> On Mar 12, 4:46 am, Joshua Fox <joshuat...@gmail.com> wrote:
>>
>> > wondering: Does Clojure's pure-functional design enhance VM-level bytecode
>> > optimization by simplifying escape analysis?
>>
>> Functional design doesn't necessarily make bytecode easy to optimize.
>> But Rich Hickey works hard on making Clojure generate bytecode that
>> the JVM will optimize.
>
> Agreed, but in the particular case of Escape Analysis, a functional
> language has better than a fighting chance of generating easily
> optimized bytecode.  The real problem is that JVMs do not yet allocate
> non-escaping objects on the stack.
> >
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to