I’ll admit that there is a whiff of pedanticism in what I’m about to say. Because (as you will see) this becomes an argument about definitions, yo

Javascript is not single-threaded

submited by
Style Pass
2024-04-20 15:00:08

I’ll admit that there is a whiff of pedanticism in what I’m about to say. Because (as you will see) this becomes an argument about definitions, you can only either be pedantically correct or incorrect. But you are being pedantic nonetheless.

# Fact 1: V8 is multi-threaded It’s no secret that LibUV is the heartbeat of the V8 engine, it is where the event loop happens, and it is doing all the async stuff.

LibUV maintains a theadpoool so your lovely async IO operations can run in a non-blocking way on threads, albeit pretty far removed from the code that you wrote.

In Node, UV_THREADPOOL_SIZE can be configured. Yes, thats right you can configure the number of threads in your supposedly single-threaded language. # Fact 2: V8 is/provides the Javascript runtime environment Let’s ignore the word engine for now, as it is not well defined. I think the word was selected because an engine makes a car go fast and V8 is fast. V8 provides the runtime environment to Javascript. This is not in question, its written on the V8 website.

Or to put it better: programming languages include their common implementations. They are more than just their implementation, but they include it.

Leave a Comment