For Clojure at least, it is a combination of things, including:
- The quality of the optimisations that the JVM itself does during JIT 
compilation. Virtual method calls for example are crazily fast.
- The JVM garbage collector - which is seriously good.
- The ability to use type hints and primitive types (effectively allowing 
some static typing for performance in focused areas)
- Use of Java for much of the underlying infrastructure (e.g. Clojure's 
collections are written in Java)
- A certain amount of type inference (e.g. for numerical primitive 
expressions)
- Intelligent use of the host capabilities (for example, most of Clojure 
"dynamic" feel is achieved through clever use of Java interfaces, which is 
much faster than the map-based method lookup in many other dynamic 
languages). 
- A fairly decent compiler (Clojure is almost always compiled, rather than 
interpreted). The bytecode generated is generally quite good, though there 
is still room for improvements :-)
- Macros can do clever things at compile time to reduce runtime overhead

Some of these are just about good implementation (either within the JVM or 
Clojure itself). 

Other advantages are perhaps more intrinsic to Lisp. I think that macros 
are the best example here.

Apart from that, other dynamic languages probably make things hard for 
themselves. In particular, I think it would be hard to get Lisp-like 
performance in any dynamic language that makes pervasive use of runtime 
monkey-patching - simply because the runtime overhead of implementation 
lookup would always be a performance killer.

On Wednesday, 19 February 2014 10:59:16 UTC+8, Andy C wrote:
>
> Hi,
>
> There are many performance benchmarks showing that compiled CLISP is 
> almost as fast as C++ or Clojure as Java.
>
> Being a dynamically typed language though, I wonder how it is possible. Is 
> it because the compiler is able to sort out actually used types and 
> assemble appropriate byte code or the cost of calling virtual methods is 
> negligible.
>
> I probably should check out generated JVM byte code to see the answer 
> firsthand but still would appreciate a higher level answer.
>
> Thanks in advance,
> Andy
>
>

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

Reply via email to