News for hackers. Stuff that matters.
Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by flohofwoe on Wednesday March 01, 2023 @09:12AM (#34982582)
From my experience with asm.js vs wasm vs native code, I bet it's not Javascript being slow, but specifically Slack.

Properly written Javascript running on V8 can be in the same ballpark as WASM and native code as long as you don't torture the GC.

Native code may give you more "optimization headroom" of course, especially with non-standard compiler extensions, but it's not "automatically" drastically faster than JS or WASM (without putting manual effort into optimization, but many of those optimizations would also benefit JS or WASM).

Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by MrJohz on Wednesday March 01, 2023 @10:21AM (#34983315)
A good example here is looking at some of the framework benchmarks for frontend frameworks (e.g. https://krausest.github.io/js-framework-benchmark/current.ht...)

I find useful comparison points are usually React, Preact, and SolidJS: React is fairly slow, but it can do pretty much everything, Preact is React with a lot of parts ripped out to provide a more efficient, slimline version, and SolidJS completely changes the rendering model and is probably the upper limit on how efficient a front-end written in Javascript can be.

It's very interesting to compare those with Rust-based frameworks. The big noticeable difference is that all the Rust-based frameworks require significantly more memory, even than React, and ship a lot more total code. However, in terms of performance, they are ringed by Javascript frameworks: SolidJS is by far the fastest framework (although Dioxus is catching up in most areas), and React is by far the slowest.

Obviously a lot of this is to do with how they interact with the DOM. Javascript gets that for free, but Rust and other WASM-based frameworks have to go through a process boundary in order to read or write DOM values. When direct DOM access eventually comes, I suspect we'll see some pretty big changes in these results. But for now, it's pretty clear that the most important thing for optimisation purposes is your application's architecture, rather than the choice of language.

Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by nicoburns on Wednesday March 01, 2023 @03:42PM (#34988040)
I think these results point to something frontend developers have known for years: JS is rarely the bottleneck. It's DOM/layout/paint that tends to be slow when something is slow. And that layer isn't changed by using Rust.
Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by pictur on Wednesday March 01, 2023 @11:54AM (#34984635)
Slack cache mechanism is pretty weird. They keep a few GB of data as cache. I wonder if they've been using this persistently for years instead of creating a better caching mechanism.
Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by explaininjs on Wednesday March 01, 2023 @11:59AM (#34984731)
Javascript is plenty fast if you are running a reasonable amount of it, as in: just enough to do what the user wanted. It's slow when you use the popular "DevEx" frameworks that recreate the entire world at the slightest change so that the developers don't need to think too hard.

Consider VS Code, software generally considered to be fast enough: every single interaction is handled by a dedicated, hand written, event handler which wherever possible directly modifies existing DOM nodes with the smallest amount of change possible.

This is miles from React. It's what SolidJS aims to do, but the state of the art here seems to be about equivalent to ASM vs Compiled C in 1980: an expert can get miles better performance by dropping down as far as possible in the stack themselves. Not to mention SolidJS forces you into their "lens" of JS, where variables are functions and functions are auto-invoked at the compilers will. And don't even think about refactoring an expression inside JSX to be outside of it or else you'll break all of reactivity. Unless you wrap it in another function, of course.

Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by nicoburns on Wednesday March 01, 2023 @03:44PM (#34988065)
Even React, despite being much slower than SolidJS, etc is rarely the bottleneck. Slow JS apps tend to be doing stupid things like blocking UI updates on network requests or updating state in such a way that triggers repeated re-renders when only one is required.
Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by explaininjs on Wednesday March 01, 2023 @04:47PM (#34988803)
> updating state in such a way that triggers repeated re-renders when only one is required

OTOH I read that and say it's precisely a React issue/bottleneck :)

Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by nicoburns on Thursday March 02, 2023 @06:31AM (#34994536)
I mean, I think that's kind of fair. It is an issue with React that this can happen. On the other hand, it's pretty much always possible to work around it within React without switching to another framework. So IMO if a team is shipping a React app with performance issues then that's on them.
Re:Tauri Mobile – Develop Mobile Apps with JavaScript and Rust by TJSomething on Wednesday March 01, 2023 @12:22PM (#34985123)
I feel like lower level languages like Rust make it more obvious when you're doing something that isn't great for performance and often have a standard library that helps abstract away the details of doing things in a performant way.