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

TeJaS: retrofitting type systems for JavaScript

Published: 28 October 2013 Publication History

Abstract

JavaScript programs vary widely in functionality, complexity, and use, and analyses of these programs must accommodate such variations. Type-based analyses are typically the simplest such analyses, but due to the language's subtle idioms and many application-specific needs---such as ensuring general-purpose type correctness, security properties, or proper library usage---we have found that a single type system does not suffice for all purposes. However, these varied uses still share many reusable common elements.
In this paper we present TeJaS, a framework for building type systems for JavaScript. TeJaS has been engineered modularly to encourage experimentation. Its initial type environment is reified, to admit easy modeling of the various execution contexts of JavaScript programs, and its type language and typing rules are extensible, to enable variations of the type system to be constructed easily.
The paper presents the base TeJaS type system, which performs traditional type-checking for JavaScript. Because JavaScript demands complex types, we explain several design decisions to improve user ergonomics. We then describe TeJaS's modular structure, and illustrate it by reconstructing the essence of a very different type system for JavaScript. Systems built from TeJaS have been applied to several real-world, third-party JavaScript programs.

References

[1]
A. H. Borning and D. H. H. Ingalls. A type declaration and inference system for Smalltalk. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1982.
[2]
Chugh, Herman, and Jhala}Chugh2012R. Chugh, D. Herman, and R. Jhala. Dependent types for JavaScript. In ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2012.
[3]
R. Chugh, P. M. Rondon, and R. Jhala. Nested refinements: a logic for duck typing. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2012.
[4]
D. Crockford. JavaScript: The Good Parts. O'Reilly Media, Inc., 2008.
[5]
B. Delaware, B. C. de Oliveira, and T. Schrijvers. Meta-theory à la carte. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2013.
[6]
A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In European Conference on Object-Oriented Programming (ECOOP), 2010.
[7]
A. Guha, C. Saftoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In European Symposium on Programming Languages and Systems (ESOP), 2011.
[8]
B. S. Lerner, L. Elberty, J. Li, and S. Krishnamurthi. Combining form and function: Static types for JQuery programs. In European Conference on Object-Oriented Programming (ECOOP), 2013.
[9]
B. S. Lerner, L. Elberty, N. Poole, and S. Krishnamurthi. Verifying web browser extensions' compliance with private-browsing mode. In European Symposium on Research in Computer Security (ESORICS), Sept. 2013.
[10]
M. Y. Levin and B. C. Pierce. TinkerType: a language for playing with formal systems. Journal of Functional Programming (JFP), 13 (2): 295--316, 2003.
[11]
J. H. Morris. Lambda-calculus Models of Programming Languages. PhD thesis, Massacheusetts Institute of Technology, 1968.
[12]
N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: an extensible compiler framework for Java. In International Conference on Compiler Construction (CC), 2003.
[13]
B. C. Pierce. Bounded quantification is undecidable. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1992.
[14]
B. C. Pierce and D. N. Turner. Local type inference. ACM Transactions on Programming Languages and Systems (TOPLAS), 22 (1): 1--44, 2000.
[15]
J. G. Politz, S. A. Eliopoulos, A. Guha, and S. Krishnamurthi. ADsafety: type-based verification of JavaScript sandboxing. In USENIX Security Symposium, Aug. 2011.
[16]
Politz, de la Vallee, and Krishnamurthi}Politz2012bJ. G. Politz, H. Q. de la Vallee, and S. Krishnamurthi. Progressive types. In ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!), 2012.
[17]
Politz, Guha, and Krishnamurthi}Politz2012J. G. Politz, A. Guha, and S. Krishnamurthi. Semantics and types for objects with first-class member names. In Workshop on Foundations of Object-Oriented Languages (FOOL), 2012.
[18]
C. Saftoiu. JSTrace: Run-time type discovery for JavaScript. Technical Report CS-10-05, Brown University, 2010.
[19]
C. Schwaab and J. G. Siek. Modular type-safety proofs in Agda. In Programming Languages meets Program Verification (PLPV), 2013.
[20]
V. Simonet and F. Pottier. A constraint-based approach to guarded algebraic data types. ACM Transactions on Programming Languages and Systems (TOPLAS), 29 (1): 1--56, 2007.
[21]
V. St-Amour, S. Tobin-Hochstadt, M. Flatt, and M. Felleisen. Typing the numeric tower. In Practical Aspects of Declarative Languages (PADL), 2012.
[22]
N. Suzuki. Inferring types in smalltalk. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 1982.
[23]
S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2008.
[24]
W3C. Web IDL. Written Apr. 2012. http://www.w3.org/TR/WebIDL/.
[25]
A. K. Wright and R. Cartwright. A practical soft type system for Scheme. In ACM conference on LISP and functional programming (LFP), 1994.
[26]
C. Zenger. Indexed types. Theoretical Computer Science, 187 (1--2): 147--165, 1997.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
DLS '13: Proceedings of the 9th symposium on Dynamic languages
October 2013
118 pages
ISBN:9781450324335
DOI:10.1145/2508168
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 28 October 2013

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. javascript
  2. type systems

Qualifiers

  • Research-article

Conference

SPLASH '13
Sponsor:

Acceptance Rates

DLS '13 Paper Acceptance Rate 9 of 22 submissions, 41%;
Overall Acceptance Rate 32 of 77 submissions, 42%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)21
  • Downloads (Last 6 weeks)2
Reflects downloads up to 06 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media