The true is that browser have single tread not JavaScript. But this is also not true because you have web workers.
In any language when you create while(true) {} loop you will block the tread, unless you will spawn another tread, with Web Worker you can do the same what you can do with Java. while(true){} will not block the web worker.
Hey Jakub!
You're absolutely right about referring to the environment being Single-Threaded and not the language. The environment dictates the threading model and the language utilises it. However I thought it best for beginners to understand JS as a single-threaded language because afaik , there are no environments for JS that support multi-threading. Workers are a browser feature and it's not directly related to JS.
Hey, NodeJS is not JavaScript, it is environment to run javascript, and JS is single threaded because it runs in a single thread provided by this env.
And the not single threaded part of Nodejs is C++ part
You're right Vlad. The underlying C++ part is multi-threaded. The NodeJS part is single-threaded and I think the intention is for NodeJS developers to write code in a single-threaded manner.
For anybody , who wants to understand these concepts in detail , I used Stephen Grider's Advanced NodeJS course on Udemy.
You're not correct, JavaScript is not single threaded, the environment is single threaded. The way the language is implemented. The same way JavaScript is not asynchronous that is provided by environment (browser or NodeJS). Environment is not part of the language.
It's worth reading, NodeJS is JavaScript and it's not single threaded at all.
Node.js is not single threaded
The true is that browser have single tread not JavaScript. But this is also not true because you have web workers.
In any language when you create
while(true) {}
loop you will block the tread, unless you will spawn another tread, with Web Worker you can do the same what you can do with Java.while(true){}
will not block the web worker.Hey Jakub!
You're absolutely right about referring to the environment being Single-Threaded and not the language. The environment dictates the threading model and the language utilises it. However I thought it best for beginners to understand JS as a single-threaded language because afaik , there are no environments for JS that support multi-threading. Workers are a browser feature and it's not directly related to JS.
Hey, NodeJS is not JavaScript, it is environment to run javascript, and JS is single threaded because it runs in a single thread provided by this env.
And the not single threaded part of Nodejs is C++ part
You're right Vlad. The underlying C++ part is multi-threaded. The NodeJS part is single-threaded and I think the intention is for NodeJS developers to write code in a single-threaded manner.
For anybody , who wants to understand these concepts in detail , I used Stephen Grider's Advanced NodeJS course on Udemy.
udemy.com/course/advanced-node-for...
You're not correct, JavaScript is not single threaded, the environment is single threaded. The way the language is implemented. The same way JavaScript is not asynchronous that is provided by environment (browser or NodeJS). Environment is not part of the language.
In addition to that NodeJS is just a referable variables to the C++ modules and functions.