Hacker News new | ask | show | jobs
by jdlshore 1187 days ago
Threads are a function of the environment, and are available in TS and other compiles-to-JS languages:

Node.js: https://nodejs.org/api/worker_threads.html

Browser: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...

However, threads are very rarely needed. The common use case in other languages is I/O, and JS environments handle that with async I/O—a superior choice, IMO.

1 comments

Neither of those are proper threads, and they have various limitations placed on them.

And the language and the VM has been, and will be for any foreseeable future, single-threaded.

Deno supports vastly superior threading model (such as green threads). Again depending on what you are coding, threading may not be the best model. Look at Ngnix vs Apache (event driven vs threading).
> Deno supports vastly superior threading model (such as green threads)

Whatever it supports, Javascript-the-language has no concept of threads. And workers are basically external processes with a somewhat awkward event-based communication and certain limitations.

Whatever Deno uses internally to implement them has no bearing.

JFYI, apache httpd has had a similar event-driven request processing module for about 10 years, maybe more.

https://httpd.apache.org/docs/2.4/mod/event.html