4 ms·
Did the speedup of script execution have other costs? One would imagine that using Clojurescript would incur some other costs somewhere. This feels like a free
by zackzackzack 13y ago
Did the speedup of script execution have other costs? One would imagine that using Clojurescript would incur some other costs somewhere. This feels like a free lunch somehow.
- aria 13y agoClojureScript generates a little more ephemeral garbage than native JavaScript and the Clojure data structures are slower, but in reality, the bottlenecks tend to be things which cross the DOM barrier and macros can make those bits much more efficiently. So it's not a free lunch, but it's very very cheap and tasty.
- bjourne 13y agoIt's incompatible with standard Javascript libraries, which is why you would use Dommy because you can't use jQuery. The ClojureScript compiler is also fairly slow (due to google closure compiler I think) so even with a running jvm it takes several seconds to compile small example files. To slow for me so I switched back to CoffeScript which is lightning fast.
- rads 13y ago"It's incompatible with standard Javascript libraries, which is why you would use Dommy because you can't use jQuery." Not true. (def $ js/jQuery) (.append ($ "body") "hello world") The reasons you'd use Dommy over jQuery are outlined in the original post.
- bjourne 13y agoNot quite. The following shows what doesn't work: (def $ js/jQuery) (.each ($ "body") (fn [idx, val] (.write js/document "In a lambda"))) The Google Closure Compiler munges names of functions so that any function declared in ClojureScript cannot be called from jQuery which means that no jQuery function that takes a callback can be used. And you really want to use GCC because without its dead code removal a simple helloworld.js file takes more than 700kb.
- swannodette 13y agoYou just need to compile your ClojureScript with the popular jQuery externs file.
- jwhitlark 13y agoYou can mark things so that their names aren't mudged via ^:export.