A new high-level language has to overcome a period of skepticism from those who are already comfortable programming in the lower-level representation. A young compiler struggles to produce code as efficient as that hand-optimized by an expert. But compilers tend to get better over time, and some smart folks are working hard on making ClojureScript fast. ClojureScript applications can get the benefit of improvements in the compiler without changing their source code, just as Clojure applications benefit from years of JVM optimizations.
To address Huard’s other points in order:
1. Compiled ClojureScript code is hard to read, therefore hard to debug.
2. ClojureScript forces the inclusion of the Google Closure Library.
This is mitigated by the Google Closure Compiler‘s dead-code elimination and aggressive space optimizations. You only pay, in download size, for what you use. For example, jQuery 1.7.2 is 33K, minified and gzipped. Caching doesn’t always save you. “Hello World” in ClojureScript, optimized and gzipped, is 18K.
3. Hand-tuning performance is harder in a higher-level language.
4. Cross-browser compatibility is hard.
* * *
4 Replies to “Why I’m Using ClojureScript”
“jQuery 1.7.2 is 33K, minified and gzipped. Caching doesn’t always save you. “Hello Worldâ€ in ClojureScript, optimized and gzipped, is 18K”
I’m confused by this point. Are you comparing the file size of “Hello world” and jQuery?
If you are that does not seem like a very fair comparison, jQuery has a little more functionality than ‘hello world’. Comparing a ClojureScript file mirroring the functionality of jQuery and comparing would be a fairer comparison.
The “Hello World” program in ClojureScript contains a lot of code besides just “Hello World,” mostly because the ClojureScript compiler is emitting that code in such a way that the Google Closure Compiler has trouble optimizing it. So right now, the smallest ClojureScript program compiles to about 18K. I am hopeful that the ClojureScript compiler will improve to take better advantage of the Google Closure Compiler’s optimizations, thereby shrinking the size of the average compiled ClojureScript program.
Comments are closed.