Sujoy Choudhury wrote:As I read, that, the Clojure program will convert into Java Byte Code and then will be executed inside JVM.
So, will that be a bit slower than Java?
Java works the exact same way: Java source code is compiled to Java bytecode and executed inside the JVM. Since the Clojure language is much smaller / simpler than the Java language, the Clojure compiler is much faster than the Java compiler. But I don't think you're really meaning that part of the process
Performance is a question that comes up quite often on the Clojure mailing list and folks usually jump in to show how to create an idiomatic version of the code that runs at "native" speed compared to the (closest) equivalent Java. It's easy to write slow Clojure code tho' because naive implementations are often doing a lot more work than they need to, but in general, there's no real reason why any particular Clojure program should be slower than some Java equivalent.
The way I integrate Clojure with Java is via the clojure.lang.RT (runtime) class. I actually load the Clojure source code files at application startup which contain the public API to my Clojure codebase (the Model in my MVC web application). Clojure then compiles those .clj on demand to bytecode and as the application runs the hotspot compiler in the JVM will further optimize the bytecode and replace parts with native code. For my use case, the compilation hit is small enough not to matter and the benefit is that I can re-run my loader method at any time to pick up changes in my Clojure codebase without needing to stop the application or recompile anything. If I was feeling really adventurous, I could incorporate the REPL into my application and then we could actually connect into the live, running application from any machine and inspect the Clojure model directly (and even hot swap code for critical fixes etc).
How will you scale a big enterprise model using Clojure? Any coding guidelines?
One useful thing is (set! *warn-on-reflection* true) so that you can identify - and fix - any situations in your code where Java reflection is being used. Otherwise, just regular profiling like you'd do in Java if you think you have a performance problem... People are already processing massive data sets very successfully in Clojure (according to what's being posted on the Clojure mailing list).
If you're more concerned with structural scaling of the code, from an organizational point of view, Clojure has namespaces which allow code to be organized into packages, much like Java code usually is. The more compact nature of Clojure tends to lead to simpler namespace structures than the "equivalent" package structures you'd typically see in Java (in my opinion).