Short answer, English is not my strong point ;-)
A keyword: modularization
Instead of populate the global environment, each module exposes the functions that needed to be consumed, without worrying of name conflicts with other modules.
And there are more benefits:
- Each module tries to cover a single domain of problem, module trends to be small in node.js ecosystem (except if it is a framework)
- The internal representation is in the module, only the top of the iceberg is exposed via module.exports
- Notably, you will see few classes exposes. Instead of "new mymodule.MyClass()" you will see "mymodule.createObject(...)", factory methods, that encapsulates the real implementation
Don't forget the NPM and versioning system: each module can consume exactly the required version of other module. Then, A could consume B...@0.1.0, and C could consume B...@0.1.1, without problem. If B module populated the global environment, such separation could not be possible. NPM is the "secret weapon" in Node.js ecosystem.
Paraphrasing David Hilbert: "No one will drive us from the paradise which Node.js modules created for us"
Angel "Java" Lopez
@ajlopez