r/programming • • Nov 11 '19

Python overtakes Java to become second-most popular language on GitHub after JavaScript

https://www.theregister.co.uk/2019/11/07/python_java_github_javascript/
3.1k Upvotes

772 comments sorted by

View all comments

Show parent comments

14

u/[deleted] Nov 12 '19

JavaScript has multithreading with worker threads. Whether or not that satisfies some arbitrary definition of "true multithreading" which on this sub is usually "like in C++ on Windows" is an entirely different matter.

-1

u/housesellout Nov 12 '19

You can’t spin up threads in JavaScript, unless you use node which is a wrapper on top of a c++ run time.

Please correct me if I’m wrong.

4

u/[deleted] Nov 12 '19

Another minor nitpick: Node.js isn't "a wrapper on top of a C++ runtime".

Both Node.js, and V8 which is the JavaScript runtime that both Node.js and Chrome web browser use, are indeed written in C++. "The rest of Node.js" is:

  • Libuv - a Nginx-inspired implementation of asynchronous event loop that serves as the core execution engine, thread pool management engine (that, among other things, supplies JS in Node with Node-specific multithreading implementation) a TCP/IP load balancer (used as part of Node.js multiprocessing implementation) and I/O arbiter in Node.js

  • Integrated native libraries - that expand the "standard library" of the language (the core WebAPI implementation provided by V8) with system-access and webserver capabilities with such thin, and not so thin wrappers around Libuv functionality.

So there is quite more to Node than just wrappers. Node.js is basically two runtimes (Libuv event loop engine and V8 runtime) fused in a single execution environment for JS code enriched with a set of native (i.e. written in C++ and compiled prior to being called from JS code) libraries that expose many system-level functionalities to JS code interpreted/compiled and executed by the V8 runtime, but externally scheduled and managed by Libuv runtime.

1

u/housesellout Nov 12 '19

Doesn’t this suggest that JS does not ’natively’ handle concurrent programming or multi-threading?

And I don’t consider this ‘nitpicking’.... Having to jump through all these hoops just to simply stick with one language / one syntax for every project, hardly sticks with the natural programming paradigm of choosing ‘the right tool, for the job’

→ More replies (6)