5 ms·
> JavaScript isn't really that big of a problem or a performance killer. The DOM is. I'm using QML, which is JS without DOM. JS is absolutely a performance kil
by _pmf_ 7y ago
> JavaScript isn't really that big of a problem or a performance killer. The DOM is.
I'm using QML, which is JS without DOM. JS is absolutely a performance killer. Migrating stuff from JS to C++ in a dumb way (no architectural change) makes things 20x - 200x faster.
- untog 7y agoI don't doubt C++ is faster than JS, but JS in modern browsers is more than "fast enough" no matter how much faster C++ may be. If you're doing the kind of things most web pages do (render some UI, information and inputs, adjust UI, take responses from those inputs, validate and send) then JS is very, very rarely a bottleneck in performance. What JS engine does QML use? Because if it's a relatively modern one (V8, JavaScriptCore etc) and you're experiencing huge slowdowns just creating and modifying UI components then I'd seriously question the JS code you're running.
- nwienert 7y agoI’ve got to be honest I thought this was the right take but I doubt it now. At least with React. Ive been doing performance on a large app now for months and JS is very often the problem. If you’re re-rendering anything that’s more than a few components wide and a few deep, say 20-40 in total, you’re already over your frame (16ms) budget. To me that’s insane. You can’t render more than 20 components at a time? And this is using a really fast computer. I almost can’t believe it. But often just the logic for a single component that’s a few levels deep takes 4ms. I really do feel that should be about 10x faster but for some reason it isn’t.
- around_here 7y agoYou probably need to learn how do either design a better app, or write better react if you’ve got that much of the DOM updating at once.
- nwienert 7y agoA computer shouldn't struggle updating 30 smaller components. It's not DOM I'm talking about it's React, so not sure you even understood me. I've written more React than most people, and am very intimately familiar with the internals, optimization and more. With enough effort you can usually mitigate most of it, but I'm going as far as doing static compilation optimizations just to get it to feel good.
- TheLegace 7y agoJust curious are you referring to this? https://doc.qt.io/qt-5/qtwebchannel-index.html# https://doc.qt.io/qt-5/qtwebchannel-index.html# Is it possible to get any benchmarks or comparisons.
- _pmf_ 7y agoNo, just using plain QML. Basically, it's a C++ application with application logic written in JS (using a rather bad JIT), and where we went wrong was writing a lot of application logic in JS rather than just writing the UI specific application logic in JS and the remaining part of the application logic in C++. OTOH, we already had huge parts of the system in C++ and the JS access was mainly small data transformations, but even this turned out to be too slow.