Abstract
We present Dependent JavaScript (DJS), a statically typed dialect of the imperative, object-oriented, dynamic language. DJS supports the particularly challenging features such as run-time type-tests, higher-order functions, extensible objects, prototype inheritance, and arrays through a combination of nested refinement types, strong updates to the heap, and heap unrolling to precisely track prototype hierarchies. With our implementation of DJS, we demonstrate that the type system is expressive enough to reason about a variety of tricky idioms found in small examples drawn from several sources, including the popular book JavaScript: The Good Parts and the SunSpider benchmark suite.
References
- M. Abadi and L. Cardelli. A Theory of Objects. Springer-Verlag, 1996. Google Scholar
Digital Library
- A. Ahmed, M. Fluet, and G. Morrisett. L3: A Linear Language with Locations. Fundamenta Informaticae, 77(4), June 2007. Google Scholar
Digital Library
- A. Aiken, J. Kodumal, J. S. Foster, and T. Terauchi. Checking and Inferring Local Non-Aliasing. In PLDI, 2003. Google Scholar
Digital Library
- C. Anderson, S. Drossopoulou, and P. Giannini. Towards Type Inference for JavaScript. In ECOOP, 2005. Google Scholar
Digital Library
- G. M. Bierman, A. D. Gordon, C. Hritcu, and D. E. Langworthy. Semantic Subtyping with an SMT Solver. In ICFP, 2010. Google Scholar
Digital Library
- V. Bono and K. Fisher. An Imperative, First-Order Calculus with Object Extension. In ECOOP, 1998. Google Scholar
Digital Library
- R. Chugh, D. Herman, and R. Jhala. Dependent Types for JavaScript -- Appendix. arxiv.org/abs/1112.4106.Google Scholar
- R. Chugh, J. A. Meister, R. Jhala, and S. Lerner. Staged Information Flow for JavaScript. In Proceedings of PLDI 2009, pages 50--62, 2009. Google Scholar
Digital Library
- R. Chugh, P. M. Rondon, and R. Jhala. Nested Refinements: A Logic for Duck Typing. In POPL, 2012. Google Scholar
Digital Library
- D. Crockford. JavaScript: The Good Parts. Yahoo! Press, 2008. Google Scholar
Digital Library
- L. de Moura and N. Bjørner. Z3: An Efficient SMT solver. In TACAS, 2008. Google Scholar
Digital Library
- R. DeLine and M. Fahndrich. Enforcing High-level Protocols in Low-level Software. In PLDI, 2001. Google Scholar
Digital Library
- ECMA. TC-39 Committee. www.ecmascript.org/community.php.Google Scholar
- M. Fahndrich and R. DeLine. Adoption and Focus: Practical Linear Types for Imperative Programming. In PLDI, 2002. Google Scholar
Digital Library
- J. Foster, T. Terauchi, and A. Aiken. Flow-sensitive Type Qualifiers. In PLDI, 2002. Google Scholar
Digital Library
- M. Furr, J. hoon (David) An, J. S. Foster, and M. W. Hicks. Static type inference for ruby. In SAC, 2009. Google Scholar
Digital Library
- P. Gardner, S. Maffeis, and G. D. Smith. Towards a Program Logic for JavaScript. In POPL, 2012. Google Scholar
Digital Library
- P. D. Gianantonio, F. Honsell, and L. Liquori. A Lambda Calculus of Objects with Self-Inflicted Extension. In OOPSLA, 1998. Google Scholar
Digital Library
- Google. Closure library. https://developers.google.com/closure/library.Google Scholar
- Google. V8 benchmark. http://v8.googlecode.com/svn/data/benchmarks/.Google Scholar
- A. Guha, C. Saftoiu, and S. Krishnamurthi. The Essence of JavaScript. In ECOOP, 2010. Google Scholar
Digital Library
- A. Guha, C. Softoiu, and S. Krishnamurthi. Typing Local Control and State Using Flow Analysis. In ESOP, 2011. Google Scholar
Digital Library
- P. Heidegger and P. Thiemann. Recency Types for Analyzing Scripting Languages. In ECOOP, 2010. Google Scholar
Digital Library
- E. International. ECMAScript Language Specification, ECMA-262, 3rd ed. 1999.Google Scholar
- K. W. Knowles and C. Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In PLPV, 2009. Google Scholar
Digital Library
- S. Maffeis, J. Mitchell, and A. Taly. An operational semantics for JavaScript. In APLAS, 2008. Google Scholar
Digital Library
- J. McCarthy. Towards a Mathematical Science of Computation. In IFIP, 1962.Google Scholar
- B. C. Pierce. Types and Programming Languages. 2002. Google Scholar
Digital Library
- B. C. Pierce and D. N. Turner. Local Type Inference. In POPL, 1998. Google Scholar
Digital Library
- J. G. Politz, S. A. Eliopoulos, A. Guha, and S. Krishnamurthi. Adsafety: Type-based Verification of JavaScript Sandboxing. In USENIX Security, 2011. Google Scholar
Digital Library
- P. Rondon, M. Kawaguchi, and R. Jhala. Low-Level Liquid Types. In POPL, 2010. Google Scholar
Digital Library
- F. Smith, D. Walker, and G. Morrisett. Alias Types. In ESOP, 2000. Google Scholar
Digital Library
- J. Sunshine, K. Naden, S. Stork, J. Aldrich, and E. Tanter. First-class State Change in Plaid. In OOPSLA, 2011. Google Scholar
Digital Library
- SunSpider. Javascript benchmark. http://www.webkit.org/perf/sunspider/sunspider.html.Google Scholar
- P. Thiemann. Towards a Type System for Analyzing JavaScript Programs. In ESOP, 2005. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. Logical Types for Untyped Languages. In ICFP, 2010. Google Scholar
Digital Library
- D. Walker and G. Morrisett. Alias Types for Recursive Data Structures. In TIC. 2000. Google Scholar
Digital Library
- S. yu Guo and B. Hackett. Fast and Precise Hybrid Type Inference for JavaScript. In PLDI, 2012. Google Scholar
Digital Library
- T. Zhao. Polymorphic Type Inference for Scripting Languages with Object Extensions. In DLS, 2011. Google Scholar
Digital Library
Index Terms
Dependent types for JavaScript






Comments