4 ms·
a basic question - why there is no multi threaded browser ?
by rammy1234 5y ago
a basic question - why there is no multi threaded browser ?
- pg_bot 5y agoFlow is attempting to do just that. https://www.ekioh.com/flow-browser/ https://www.ekioh.com/flow-browser/
- rammy1234 5y agoNice ! thanks that's an interesting read. All this javascript is single threaded in browser is all so limiting.
- livre 5y agoSaying that JavaScript is single threaded isn't accurate anymore. Even the article we just read mentions that you can run multiple threads with WebWorkers. The problem with JavaScript is that the main thread may* block the UI. * Why may? The older APIs such as document.write and synchronous XHR do but modern browsers already warn against that. And the modern APIs don't block the UI because they are asynchronous and work with callbacks or promises. Bad JavaScript code can make the UI sluggish though, people should be performing complex tasks on a WebWorker but that's not as easy or as obvious as the default of performing them on the UI thread. The same problems can happen in native Windows programming for the same reason, the UI thread being the main thread. This is a bad design decision from decades ago that will likely haunt us for many more decades in the desktop OS and on the web.
- dmitriid 5y ago> Saying that JavaScript is single threaded isn't accurate anymore. Even the article we just read mentions that you can run multiple threads with WebWorkers This doesn't make Javascript multithreaded. It means you run single-threaded programs in separate containers and pass messages between them.
- tobyhinloopen 5y agoWho cares about the details - you can create multiple workers, running on different threads. That’s multithreading.
- dmitriid 5y ago> Who cares about the details People who actually care about multithreading > you can create multiple workers, running on different threads. That’s multithreading. It's not.
- kevincox 5y agoDoes the presence of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... fit your definition of multithreading?
- dmitriid 5y agoLiterally on that page, emphasis mine: === start quote === To share memory using SharedArrayBuffer objects from one agent in the cluster to another (an agent is either the web page’s main program or one of its web workers), postMessage and structured cloning is used. === end quote === And, of course, they are almost exclusively used with Web Workers because it makes zero sense to use them in the context of a single page. They are basically memory-mapped files, but for the browser, and their presence doesn't make Javascript and its runtime multithreaded. There's also a good overview on the history of concurrency and parallelism in JS here: https://exploringjs.com/es2016-es2017/ch_shared-array-buffer.html https://exploringjs.com/es2016-es2017/ch_shared-array-buffer... IIRC Javascript can't even be made multithreaded because there are places in the spec that can't work in a multithreaded environment, but don't quote me on that.
- kevincox 5y agoI think you are missing the key point there. > However, the shared data block referenced by the two SharedArrayBuffer objects is the same data block, and a side effect to the block in one agent will eventually become visible in the other agent. This gives you shared memory between two threads. Sure the entire address space isn't shared but I find it hard to deny that this is threading.
- tobyhinloopen 5y agoWdym, all browsers use some kind of multithreading.