On Thursday, March 21, 2013 11:58:43 AM UTC-4, Mario Gutierrez wrote:
I think of module/package as being a library of related things. Instead of having a single "when" dependency, when is many dependencies "when", "when/sequence", "when/parallel", "when/pipeline" ... A namespace is created for every helper function which is unusual.
We agree that modules and packages are indeed the new coarse and fine grained units of organization of Javascript. However, we feel that "one giant file of all functionality" as the primary unit of organization of a library is not the way forward and isn't the direction Javascript is headed. Our design philosophy is that smaller, focused modules are easier to maintain, refactor, and consume. This is supported by looking at the evolution of Javascript. For example, CommonJS packages are, by definition, collections of modules, package.json describes the collection of related modules making up the package. If packages were intended to be a single file, then package.json's "main" property wouldn't really be necessary. Also, TC39 is designing a module system for ES6, and is looking at packages and modules as the primary units of organization.
The when package is a single top-level namespace "when", with submodules that provide functionality. This is in-line with the general direction of CommonJS packages and modules, so feels quite natural to us, and feedback cujo.js users has been very positive on these smaller, focused modules.
FWIW, Javascript objects and functions have been used extensively for namespacing purposes in old school approaches that rely on globals, so I'll argue that something like when.sequence is just as much a namespace as `when/sequence`.
Of course, our fine-grained approach may raise the concern of browser load times in production. That is mitigated by optimization tools like cram.js and r.js, which build packages and modules into an larger unit of organization (we call them "bundles" in cujo.js). For example, you may build your entire application into a single bundle file, and deliver it to the browser in a single http request. Larger applications may be built into several bundles which are loaded on demand or in the background as a user navigates around an application.
I appreciate that not everyone will agree, but we'll stand by our design philosophy that smaller, focused modules are a good thing.