News for hackers. Stuff that matters.
Re:Performance Showdown: Rust vs Javascript (2020) by OneAlias1 on Friday February 12, 2021 @07:20AM (#26112888)
'After spending some weeks playing with Rust,'... he is new to Rust and keeps using String, accepting `&String` as args etc this is not tuning. This would be caught by linters like clippy telling you to double check it. I can show you naive Rust vs Naive Node.js and like his follow up article x10 performance over Node.js is not abnormal.
Re:Performance Showdown: Rust vs Javascript (2020) by josephg on Friday February 12, 2021 @08:55AM (#26113638)
Yep. 8x is the right ballpark I usually see comparing decent C/Rust to javascript.

I saw a 10x slowdown porting the Chipmunk2d physics engine to javascript. (Which dropped to 5x or something after a few weeks of JS optimizations). Porting operational transform heuristics from JS to C got me a ~40x speedup. The code in question used heterogeneous data types which V8 hates (causing both heap thrashing and code deopt). In C I handed it with a tagged union and the code needed 0 allocations in the hot path.

Generally the rule is, if your code has complex data types, heterogeneous data types or a lot objects being created and destroyed it be much slower in javascript compared to C/Rust. A lot of that benefit goes away if the native code does sloppy allocations everywhere.

And on the other hand, if your code is Math heavy, operating on simple data types, V8 will do great work.

Re:Performance Showdown: Rust vs Javascript (2020) by rattray on Friday February 12, 2021 @09:00AM (#26113683)
There area lot of JS developers who are considering moving code to Rust for performance, but will start out as naive.