my understanding is that JavaScript remains single-threaded
This is true for 99% of JavaScript programmers. Though there are many projects out there that allow you to create multi-threaded applications with JavaScript.
http://gpu.rocks/ is an example that lets you write and “Perform massively parallel GPGPU computations using WebGL.”
The new version of Node also comes with Cluster. Which will allow you to fork processes and run them against multiple cpu’s.
You are right about the differences between const and immutability. While I did not touch on this subject in this article, immutability in JavaScript can be achieved in a couple different ways, some of them being Object.freeze() or Immutable.js. You could also just enforce a “don’t mutate state” policy in your codebase where through best practices you do not mutate the state.
The benefits of immutability go beyond eliminating state mutation bugs. Immutability allows you to create pure functions, which then allows you to use function composition. Without immutability, you cannot reason about the effects of your compositions.
Immutability in Functional programming is not about designing a completely immutable application. State must be kept and mutated somewhere even in functional languages. Functional Design is about managing mutations.
The greatest and worst thing about JavaScript are the same thing, JavaScript’s flexibility. JavaScript can be anything you want it to be and it will be sure to give you just enough rope to hang yourself with.
Cheers!
