News for hackers. Stuff that matters.
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.

There are no comments on this comment yet.