News for hackers. Stuff that matters.
Re:JavaScript Modularity Shaming by lomnakkus on Wednesday January 07, 2015 @04:04PM (#8853292)
You can sort-of already do that with CDNs.

Browser still has to parse+run all of that JS though. Because JS-in-browsers is antimodular in that all previous JS on a given page influences all subsequently loaded JS, even if using just script tags with a URL. In a way this is very similar to the pains experienced by the C++ community for many years now.

Re:JavaScript Modularity Shaming by jffry on Wednesday January 07, 2015 @05:03PM (#8853612)
FYI you can add an async attribute [1] to a <script> tag to allow it to load and run asynchronously without blocking the rest of the page

[1]: http://caniuse.com/#feat=script-async

Re:JavaScript Modularity Shaming by lomnakkus on Sunday January 11, 2015 @02:20PM (#8870922)
Good point. Should've mentioned that. Unfortunately, it's often hard to know if "async" or "defer" will work reliably.
Re:JavaScript Modularity Shaming by amelius on Wednesday January 07, 2015 @04:09PM (#8853321)
Could you elaborate on the C++ part?
Re:JavaScript Modularity Shaming by DiThi on Wednesday January 07, 2015 @05:14PM (#8853679)
C++ doesn't have a "load this module" statement. I does have an "include all the contents of X file here", and file X has to deal with possible duplication and cyclic dependencies, usually with something like

#ifndef _SOME_FILE_H #define _SOME_FILE_H // code goes here #endif

Also any "module" can define any global variable, so name clashes (esp. with C libraries) are possible. Most languages with proper modules the "global" variables are module-wide.

An equally nasty issue happens with JS, where many libraries must be loaded in the proper order and not duplicated. There are a bunch of module systems but none is part of the spec. The good thing is that module systems are easy to make thanks to closures.

Re:JavaScript Modularity Shaming by lomnakkus on Wednesday January 07, 2015 @04:33PM (#8853455)
The short answer is that "it's complicated". The most accessible long answer I'm aware of for non-C++'ers is at [1] (video). If you prefer text, the standardese version is at [2]. Unfortunately I cannot find a concise text version for laymen except perhaps [3].

[1]: https://www.youtube.com/watch?v=4Xo9iH5VLQ0

[2]: http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n404...

[3]: http://clang.llvm.org/docs/Modules.html