DEV Community

Discussion on: Javascript under the hood

Collapse
 
leob profile image
leob

Interestingly, this reminds me of the old discussion about preemptive multitasking versus cooperative multitasking in operating systems. The old versions of Windows (up to Windows 95) were "cooperative" and used an event loop, from Windows XP onwards this was replaced by "preemptive" multitasking with threads (same goes for all other modern operating systems: Linux, OSX and so on).

Javascript's event loop architecture is "cooperative multi-tasking", in contrast to languages like Java which support native threads.

Now I wonder, was this a deliberate choice in the basic design of the Javascript language, is it even mandated in the ECMASCRIPT standard, and if so what was the motivation? I can guess at the reasons, but I haven't ever seen them articulated anywhere.

(hint: native threads, although powerful, come with their own set of drawbacks and fundamental issues, and I think the designer(s) of Javascript and of Javascript engines like V8 felt that because of these drawbacks supporting threads was not a viable option)