There are a couple of drawbacks, though:
1. It really only works for read-only data. Generating a new lookup-fn is a pretty expensive operation. I don't think I could use this for data that changed at all.
2. Compiled code uses permgen space and isn't garbage collected as easily. If you make extensive use of this technique, especially with large maps, it'd be really easy to blow your permgen space.
That said, in reality, JVM bytecode is tied pretty closely with Java. The bulk of a program: method calls, types, loops, etc all map pretty much 1:1 with what Java emits - there's not a whole lot of room for improvement. And if there were, it would probably be through MORE static typing and compile-time analysis, not less.
I expect that for any arbitrary Clojure program you give me, I can write a Java program that will execute as fast or faster. Of course, it might take me ten times as long to write and have ten times the amount of source code.
Clojure doesn't compile to Java, it compiles to JVM bytecode, and I think (although I don't know) that that's supposed to be very fast.
In this post:
http://www.learningclojure.com/2010/09/clojure-faster-than-m...
I compiled a (lookup into a map (potentially constructed at run time)) into a series of nested if statements, which then ran very fast indeed.
I shouldn't think I've achieved anything like the holy grail here, it all goes wrong at the end anyway, and I think that clojure 1.3 might actually have broken the optimization techniques I used.
But I think there's a case for saying that an immutable lisp on the JVM might one day be the fastest language in the world, because you can do those sorts of tricks in lisp in a way that you can't feasibly do in assembler, and the JVM does optimization dependent on run-time behaviour, as well as on static analysis.
I don't have the data. I'm not asserting this.
But I am asserting that Java speed is not a strict upper bound on JVM language speed, (unless every JVM bytecode program is also a Java program, which I can't imagine is the case!).