5 ms·
I haven't used clojure/clojurescript since more than 3-4 years. How far the performance of CLJS [:optimization :advanced] has come close to writing core js code
by truth_seeker 5y ago
I haven't used clojure/clojurescript since more than 3-4 years. How far the performance of CLJS [:optimization :advanced] has come close to writing core js code ?
I still remember good old memories of using CLJS (around 2017-18), we were rewriting the android app for one of our clients ethanol selling company in Africa/kenya (which took roughly more than 6 months to write, test and deliver, still was crappy) in cordova/phonegap hybrid mobile app using CLJS, reagent and materialize.css. We did it in only 2 and half weeks with extensive test coverage. In my team only i knew clojure and played little bit with cljs and reagent while creating a to-do list app.
We never used to test the app after creating an android build, we were relying all the time chrome dev tools by hosting it as SPA app, writing test cases and fixing css & functionality issues if any. We were so confident that it will work as expected after exporting to .apk after simple codova/phonegap build process. More than 95% of the time, it always did.
I had to teach my other 2 teammates the basics of cljs and whole project development handling. It was the most challenging as well as productive 2 and half weeks of entire career. I never could imagine we could it develop it so fast with completely new language onboard. I had to play many tricks to allure my upper management to invest in a lisp dialect. I promised them to rewrite in under 6 weeks and ship to production. From 6 weeks commitment to 2 and half, we were on cloud 9. We also worked on weekends almost full time during that release.
Unfortunately due to some restrictions of supporting older android versions than 4.4 in kenya region we had to abandon the idea of hybrid app using cordova/phonegap after 3 months as more clients demanded.
- raspasov 5y agoI don’t have exact numbers but I recall some stats from years ago where it was 10-30% slower. TLDR Almost identical performance.
- slver 5y agoWhy is a script compiled to another script up to 30% slower than its target?
- capableweb 5y agoEverything is something compiled to something else and eventually machine code, but some do run faster/slower than others. Usually it's mostly about that generated code is more bloated to manually crafted code. Compare generated assembly with manually crafted assembly and you'll see what I mean.
- slver 5y agoThe irony is that for modern processors, generated assembly tends to be faster, because the required optimization is so specific, manually crafting it can almost never match an optimizing compiler. But I get the spirit of what you said.
- capableweb 5y ago> The irony is that for modern processors, generated assembly tends to be faster, because the required optimization is so specific, manually crafting it can almost never match an optimizing compiler. That's interesting, haven't heard of that before. You happen to know of any comparisons that show the difference? Or some other resource on the subject. > But I get the spirit of what you said. Thanks for not being overtly anal about it, which tends to be the norm :)
- fulafel 5y agoThe language wasn't mentioned but often the alternative to assembler is C. C compilers beating hand written assembly comes up in pretty much every discussion of the subject. You can still beat the compiler in many cases if you iterate and analyze enough, but that won't be the case in the first-pass code you'd write. There are some exceptions in areas where compilers have weaknesses, like SIMD code. The thread context is ClojureScript and JavaScript, I think people don't compare JSVM JIT code to hand written assembly that often (tip: node --print-opt-code --print-opt-code-filter=myfunction).
- raspasov 5y agoAs with all benchmarks, a lot of caveats apply. ClojureScript gives you a lot of power, and a lot of tools to easily reason about your code in many asynchronous scenarios. I believe that you if you wrote JavaScript that gives you the same amount of power and immutability guarantees that ClojureScript provides, it will also be slower than a simplistic benchmark that mutates everything all over the place.