skip to main content
10.1145/2384616.2384659acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Dependent types for JavaScript

Authors Info & Claims
Published:19 October 2012Publication History

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

  1. M. Abadi and L. Cardelli. A Theory of Objects. Springer-Verlag, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Ahmed, M. Fluet, and G. Morrisett. L3: A Linear Language with Locations. Fundamenta Informaticae, 77(4), June 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. Aiken, J. Kodumal, J. S. Foster, and T. Terauchi. Checking and Inferring Local Non-Aliasing. In PLDI, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. Anderson, S. Drossopoulou, and P. Giannini. Towards Type Inference for JavaScript. In ECOOP, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. G. M. Bierman, A. D. Gordon, C. Hritcu, and D. E. Langworthy. Semantic Subtyping with an SMT Solver. In ICFP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. V. Bono and K. Fisher. An Imperative, First-Order Calculus with Object Extension. In ECOOP, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. R. Chugh, D. Herman, and R. Jhala. Dependent Types for JavaScript -- Appendix. arxiv.org/abs/1112.4106.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Chugh, P. M. Rondon, and R. Jhala. Nested Refinements: A Logic for Duck Typing. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. D. Crockford. JavaScript: The Good Parts. Yahoo! Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. L. de Moura and N. Bjørner. Z3: An Efficient SMT solver. In TACAS, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. R. DeLine and M. Fahndrich. Enforcing High-level Protocols in Low-level Software. In PLDI, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. ECMA. TC-39 Committee. www.ecmascript.org/community.php.Google ScholarGoogle Scholar
  14. M. Fahndrich and R. DeLine. Adoption and Focus: Practical Linear Types for Imperative Programming. In PLDI, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Foster, T. Terauchi, and A. Aiken. Flow-sensitive Type Qualifiers. In PLDI, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Furr, J. hoon (David) An, J. S. Foster, and M. W. Hicks. Static type inference for ruby. In SAC, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. P. Gardner, S. Maffeis, and G. D. Smith. Towards a Program Logic for JavaScript. In POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. P. D. Gianantonio, F. Honsell, and L. Liquori. A Lambda Calculus of Objects with Self-Inflicted Extension. In OOPSLA, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Google. Closure library. https://developers.google.com/closure/library.Google ScholarGoogle Scholar
  20. Google. V8 benchmark. http://v8.googlecode.com/svn/data/benchmarks/.Google ScholarGoogle Scholar
  21. A. Guha, C. Saftoiu, and S. Krishnamurthi. The Essence of JavaScript. In ECOOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Guha, C. Softoiu, and S. Krishnamurthi. Typing Local Control and State Using Flow Analysis. In ESOP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. P. Heidegger and P. Thiemann. Recency Types for Analyzing Scripting Languages. In ECOOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. E. International. ECMAScript Language Specification, ECMA-262, 3rd ed. 1999.Google ScholarGoogle Scholar
  25. K. W. Knowles and C. Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In PLPV, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. S. Maffeis, J. Mitchell, and A. Taly. An operational semantics for JavaScript. In APLAS, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. McCarthy. Towards a Mathematical Science of Computation. In IFIP, 1962.Google ScholarGoogle Scholar
  28. B. C. Pierce. Types and Programming Languages. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. B. C. Pierce and D. N. Turner. Local Type Inference. In POPL, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. G. Politz, S. A. Eliopoulos, A. Guha, and S. Krishnamurthi. Adsafety: Type-based Verification of JavaScript Sandboxing. In USENIX Security, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. P. Rondon, M. Kawaguchi, and R. Jhala. Low-Level Liquid Types. In POPL, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. F. Smith, D. Walker, and G. Morrisett. Alias Types. In ESOP, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. J. Sunshine, K. Naden, S. Stork, J. Aldrich, and E. Tanter. First-class State Change in Plaid. In OOPSLA, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. SunSpider. Javascript benchmark. http://www.webkit.org/perf/sunspider/sunspider.html.Google ScholarGoogle Scholar
  35. P. Thiemann. Towards a Type System for Analyzing JavaScript Programs. In ESOP, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. S. Tobin-Hochstadt and M. Felleisen. Logical Types for Untyped Languages. In ICFP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. D. Walker and G. Morrisett. Alias Types for Recursive Data Structures. In TIC. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. S. yu Guo and B. Hackett. Fast and Precise Hybrid Type Inference for JavaScript. In PLDI, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. T. Zhao. Polymorphic Type Inference for Scripting Languages with Object Extensions. In DLS, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Dependent types for JavaScript

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in
          • Published in

            cover image ACM Conferences
            OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applications
            October 2012
            1052 pages
            ISBN:9781450315616
            DOI:10.1145/2384616
            • cover image ACM SIGPLAN Notices
              ACM SIGPLAN Notices  Volume 47, Issue 10
              OOPSLA '12
              October 2012
              1011 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/2398857
              Issue’s Table of Contents

            Copyright © 2012 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 19 October 2012

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article

            Acceptance Rates

            Overall Acceptance Rate268of1,244submissions,22%

            Upcoming Conference

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader