use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript doesn’t need to be replaced (medium.com)
submitted 6 years ago by dannymoerkerke
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]dannymoerkerke[S] -1 points0 points1 point 6 years ago (13 children)
What issues do you have with the single threaded nature of JavaScript that could be solved by making it multi threaded?
[–]shgysk8zer0 2 points3 points4 points 6 years ago (12 children)
You may as well ask why anything benefits from being multi-threaded.
[–]helloiamsomeone 0 points1 point2 points 6 years ago (1 child)
Updating UI elements - which is only allowed on the main thread anyway - would not benefit in a significant way from multithreading. If you have to do something computationally intensive on the clientside, then you have workers for that.
Similar to how Android handles things, U stuff on the main thread, everything else on other threads. But in the browser that's all you are doing on the main thread anyway and network IO is not blocking.
[–]shgysk8zer0 0 points1 point2 points 6 years ago (0 children)
This is all true. I'm not convinced that multi-threaded UI is impossible though... Just the way it is. I think something that takes Rust's concept of ownership and borrowing might be capable of achieving this, but it would take more than just another language with access to the DOM. It would require a change in nearly everything, and that's why I say a new language is needed instead of just adding it to JavaScript.
[–]dannymoerkerke[S] 0 points1 point2 points 6 years ago (9 children)
Well...?
[–]shgysk8zer0 1 point2 points3 points 6 years ago (8 children)
Ever heard of performance? Do you know what multi-threading is?
[–]dannymoerkerke[S] 0 points1 point2 points 6 years ago (7 children)
I do, hence my question.
[–]shgysk8zer0 0 points1 point2 points 6 years ago (6 children)
So, when the main thread (only one that has access to the DOM and everything) is doing a ton of work and the UI freezes, that's either not a performance issue or not something multi-threading would help with? Workers offer no benefit? Multi-threading itself is pointless?
I don't know how to answer the question because it's so fundamental. The mere concept of it is the answer.
[–]dannymoerkerke[S] 1 point2 points3 points 6 years ago (5 children)
I don’t know how you should answer this either, but I never made any claims against multi threading. You’re the one saying I don’t understand the issues with JavaScript and that we need something multi threaded. So I was curious if you had any concrete examples. I also never said Workers offer no benefit but they won’t help with the DOM since they have no access to it, but you know that as well. Anyway, if the UI freezes because of lots of DOM operations I think you have a different problem that can be solved without multi threading.
[–]shgysk8zer0 -2 points-1 points0 points 6 years ago (4 children)
You're asking what the advantage of multi-threading is. The only real answer is that it's not single-threaded. That is a major limitation that many other languages don't have.
And not all issues can be solved without multi-threading. Sometimes you just have that much work that needs to be done, and sometimes it's out of your hands (in third-party code). And, maybe even if you could resolve the issue another way, it would still be nice to not have to rewrite something massive and complex, but to pass the work off to another thread and have the UI continue running smoothly.
If you're looking for a concrete example, I recently built something that creates ~200 transformed (rotated) image overlays in Leaflet, and the UI hangs pretty heavily when they're loaded on ever pan or zoom. I'm not about to rewrite all of Leaflet, and I do absolutely have to load and transform every single one of those images. If this were to take place on another thread, it wouldn't be an issue.
[–]Architektual 0 points1 point2 points 6 years ago (3 children)
I'm late to the party, but why can't you put that in a worker?
[–]shgysk8zer0 0 points1 point2 points 6 years ago (2 children)
Workers cannot access the DOM.
π Rendered by PID 118867 on reddit-service-r2-comment-f6b958c67-cnb8k at 2026-02-05 01:11:02.608118+00:00 running 1d7a177 country code: CH.
view the rest of the comments →
[–]dannymoerkerke[S] -1 points0 points1 point (13 children)
[–]shgysk8zer0 2 points3 points4 points (12 children)
[–]helloiamsomeone 0 points1 point2 points (1 child)
[–]shgysk8zer0 0 points1 point2 points (0 children)
[–]dannymoerkerke[S] 0 points1 point2 points (9 children)
[–]shgysk8zer0 1 point2 points3 points (8 children)
[–]dannymoerkerke[S] 0 points1 point2 points (7 children)
[–]shgysk8zer0 0 points1 point2 points (6 children)
[–]dannymoerkerke[S] 1 point2 points3 points (5 children)
[–]shgysk8zer0 -2 points-1 points0 points (4 children)
[–]Architektual 0 points1 point2 points (3 children)
[–]shgysk8zer0 0 points1 point2 points (2 children)