Abstract
The JavaScript programming language, originally developed as a simple scripting language, is now the language of choice for web applications. All the top 100 sites on the web use JavaScript and its use outside web pages is rapidly growing. However, JavaScript is not yet ready for programming in the large: it does not support a module system. Lack of namespaces introduces module patterns, and makes it difficult to use multiple JavaScript frameworks together.
In this paper, we propose a formal specification of a JavaScript module system. A module system for JavaScript will allow safe and incremental development of JavaScript web applications. While the next version of the JavaScript standard proposes a module system, it informally describes its design in prose. We formally specify a module system as an extension to the existing JavaScript language, and rigorously describe its semantics via desugaring to LambdaJS, a prior core calculus for JavaScript. We implement the desugaring process and show its faithfulness using real-world test suites. Finally, we define a set of properties for valid JavaScript programs using modules and formally prove that the proposed module system satisfies the validity properties.
- HTML5: A vocabulary and associated APIs for HTML and XHTML. http://www.w3.org/TR/html5/.Google Scholar
- JavaScript. http://en.wikipedia.org/wiki/JavaScript.Google Scholar
- Alexa the Web Information Company. http://www.alexa.com/, 2011.Google Scholar
- Ericsson AB. Erlang Reference Manual User's Guide. http://www.erlang.org/doc/reference_manual/users_guide.html.Google Scholar
- Gilad Bracha, Guy Steele, Bill Joy, and James Gosling. Java#8482; Language Specification, The 3rd Edition (Java Series). Addison-Wesley Professional, July 2005. Google Scholar
Digital Library
- CommonJS contributors. Modules. http://wiki.commonjs.org/wiki/Modules.Google Scholar
- Douglas Crockford. ADsafe: Making JavaScript safe for advertising. http://www.adsafe.org, 2008.Google Scholar
- Dave Herman and Sam Tobin-Hochstadt. Harmony Proposals -- Modules. ECMAScript Wiki, http://wiki.ecmascript.org/doku.php?id=harmony:modules.Google Scholar
- Dave Herman and Sam Tobin-Hochstadt. Module Loaders, Harmony Proposals. ECMAScript Wiki, http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders.Google Scholar
- ECMA. ECMA-262: ECMAScript Language Specification. 5th edition, December 2009.Google Scholar
- Brendan Eich. http://brendaneich.com/2011/05/my-jsconf-us-presentation/, 2011.Google Scholar
- ES4 working group. Proposed ECMAScript 4th Edition -- Language Overview. http://www.ecmascript.org/es4/spec/overview.pdf, October 2007.Google Scholar
- David Flanagan. JavaScript: The Definitive Guide. O'Reilly, 5th edition, 2009. Google Scholar
Digital Library
- Matthew Flatt. Composable and compilable macros:: you want it when? In Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming, 2002. Google Scholar
Digital Library
- Matthew Flatt and PLT. The Racket Reference. http://docs.racket-lang.org/reference/index.html.Google Scholar
- Python Software Foundation. The Python Language Reference. http://docs.python.org/py3k/reference/index.html.Google Scholar
- Philippa Gardner, Sergio Maffeis, and Gareth Smith. A program logic for JavaScript. In Proceedings of the 39th ACM Symposium on Principles of Programming Languages, 2012. Google Scholar
Digital Library
- Danny Goodman. Dynamic HTML: The Definitive Reference. O'Reilly Media, 1998. Google Scholar
Digital Library
- Arjun Guha. lambda_JS 1.0. https://github.com/brownplt/LambdaJS, 2011.Google Scholar
- Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. The Essence of Javascript. In Proceedings of the 24th European Conference on Object-Oriented Programming, 2010. Google Scholar
Digital Library
- David Herman and Sam Tobin-Hochstadt. Modules for JavaScript. Preprint, April 2011.Google Scholar
- jQuery Team. jQuery. http://jquery.com/.Google Scholar
- Seonghoon Kang and Sukyoung Ryu. lambdajs with modules. Technical report, KAIST, 2011.Google Scholar
- Sergio Maffeis, John C. Mitchell, and Ankur Taly. An Operational Semantics for JavaScript. In Proceedings of the 6th Asian Symposium on Programming Languages and Systems, 2008. Google Scholar
Digital Library
- Sergio Maffeis, John C. Mitchell, and Ankur Taly. Object Capabilities and Isolation of Untrusted Web Applications. In Proceedings of IEEE Security & Privacy, 2010. Google Scholar
Digital Library
- Sergio Maffeis and Ankur Taly. Language-Based Isolation of Untrusted JavaScript. In Proceedings of the 22nd IEEE Computer Security Foundations Symposium, 2009. Google Scholar
Digital Library
- Eric Miraglia. A JavaScript Module Pattern. Yahoo! User Interface Blog, http://yuiblog.com/blog/2007/06/12/module-pattern/, June 2007.Google Scholar
- Mozilla Developer Network. Harmony modules. https://bugzilla.mozilla.org/show_bug.cgi?id=568953.Google Scholar
- Mozilla Developer Network. JavaScript code modules. https://developer.mozilla.org/en/JavaScript_modules.Google Scholar
- Tim O'Reilly. What Is Web 2.0. http://oreilly.com/web2/archive/what-is-web-20.html.Google Scholar
- PLT. DrRacket language levels. http://docs.racket-lang.org/unstable/DrRacket_Language_Levels.html.Google Scholar
- Joe Politz and Matt Carroll. lambda_JS semantics for ecmascript 5.0 (work in progress). https://github.com/brownplt/LambdaS5, 2011.Google Scholar
- Joe Gibbs Politz, Spiridon Aristides Eliopoulos, Arjun Guha, and Shriram Krishnamurthi. Adsafety: Type-based verification of javascript sandboxing. In USENIX Security, 2011. Google Scholar
Digital Library
- Ankur Taly, Ulfar Erlingsson, Mark S. Miller, John C. Mitchell, and Jasvir Nagra. Automated analysis of security-critical JavaScript APIs. In Proceedings of IEEE Security & Privacy, 2011. Google Scholar
Digital Library
- Google Caja Team. Google-Caja: A Source-to-source translator for securing JavaScript-based web content. http://code.google.com/p/google-caja/.Google Scholar
- The Facebook Team. FBJS (Facebook JavaScript). http://developers.facebook.com/docs/fbjs/.Google Scholar
- Sam Tobin-Hochstadt and Dave Herman. Modules for JavaScript, 2011.Google Scholar
Index Terms
Formal specification of a JavaScript module system
Recommendations
Formal specification of a JavaScript module system
OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsThe JavaScript programming language, originally developed as a simple scripting language, is now the language of choice for web applications. All the top 100 sites on the web use JavaScript and its use outside web pages is rapidly growing. However, ...
JavaScript module system: exploring the design space
MODULARITY '14: Proceedings of the 13th international conference on ModularityWhile JavaScript is one of the most widely used programming languages not only for web applications but also for large projects, it does not provide a language-level module system. JavaScript developers have used the module pattern to avoid name ...
Rewriting javascript module system
AOSD '13 Companion: Proceedings of the 12th annual international conference companion on Aspect-oriented software developmentAlthough JavaScript is one of the major languages used for web and other general applications, it does not have a language-level module system. Lack of module system causes name conflicts when programmer uses libraries. We introduce a JavaScript module ...







Comments