4 ms·
More like, know when to apply Clojure and when to apply Rust. Having written a ClojureScript app with a Rust/WASM component, for me it's very clear that they h
by fnordsensei 5y ago
More like, know when to apply Clojure and when to apply Rust.
Having written a ClojureScript app with a Rust/WASM component, for me it's very clear that they have different strengths that can be complementary.
That the author dropped CLJS along with React is fair enough, in my opinion. The CLJS ecosystem is pretty React-centric.
- unnouinceput 5y agoListen, Clojure isn't born yesterday, it's around for quite some time and it's a mature product. And when you have mature products that are still in development and people behind it do evolve it then you also get all kind of optimizations. I would expect the system maybe to be slower like 20 to maximum 50% (as in Rust to be maximum 2 times faster) but 50 times faster?. That's already brain in the chair mistake.
- fnordsensei 5y agoIf we were talking about Clojure, I would agree that 50x would indicate that something is off. But since we're talking ClojureSCRIPT, it doesn't surprise me. Although, fair enough, it's a rewrite, and the author has the benefit of experience with the first implementation when writing this one. A second implementation in ClojureScript would likely have been faster than the first one. But 50x faster? Unlikely. > Is WebAssembly faster than Javascript? > Yes - about 50 times faster in my experience. https://www.quora.com/Is-WebAssembly-faster-than-Javascript https://www.quora.com/Is-WebAssembly-faster-than-Javascript Just as a data point that the author isn't the only one to see this type of performance increase. I expect that it isn't 50x across the board over JS, but that it would vary wildly across the board, including being slower if you're doing something trivial and end up paying more in serialisation to and from WASM than you gain in speed.
- sickill 5y ago> But 50x faster? Unlikely. And yet it is. The biggest factor here is that CLJS is interpreted, GC-ed with immutable data structures while Rust is lower level with highly optimized WASM bytecode, that's optimized by Rust/LLVM compiler ahead of time. So, when there's a lot of terminal activity (high speed colorful animation), the terminal emulator in CLJS implementation allocates and GCs millions of data structures every second. In Rust implementation there's very little allocation because most code operates on already pre-allocated buffers, and just mutates then. Both approaches are standard to their language. I could have tried all sorts of tricks (in fact I tried some) in CLJS to make this implementation faster but it would very quickly make the code non-idiomatic, and not fun to work with. But let's say I could make the CLJS impl be on par with a theoretical plain JS impl - this would likely still be many times slower than a basic Rust impl. Modern JS engines are amazing but they just can't beat WASM. Maybe some day :)
- fnordsensei 5y agoRead my comment again, I'm not saying what you think I'm saying.