Abstract
JavaScript is a popular language for client-side web scripting. It has a dubious reputation among programmers for two reasons. First, many JavaScript programs are written against a rapidly evolving API whose implementations are sometimes contradictory and idiosyncratic. Second, the language is only weakly typed and comes virtually without development tools.
The present work is a first attempt to address the second point. It does so by defining a type system that tracks the possible traits of an object and flags suspicious type conversions. Because JavaScript is a classless, object-based language with first-class functions, the type system must include singleton types, subtyping, and first class record labels. The type system covers a representative subset of the language and there is a type soundness proof with respect to an operational semantics.
Chapter PDF
Similar content being viewed by others
References
Abadi, M., Cardelli, L.: A Theory of Objects. Springer, Heidelberg (1996)
Armstrong, J., Virding, R., Williams, M.: Concurrent Programming in Erlang. Prentice-Hall, NY (1993)
Cartwright, R., Fagan, M.: Soft typing. In: Proc. Conference on Programming Language Design and Implementation 1991, Toronto, Canada, June 1991, pp. 278–292. ACM Press, New York (1991)
ECMAScript Language Specification. ECMA International, ECMA-262, 3rd edn. (December 1999), http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
Gaster, B.R., Jones, M.P.: A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, Dept. of Computer Science, University of Nottingham (November 1996)
Henglein, F.: Dynamic typing: Syntax and proof theory. Science of Computer Programming 22, 197–230 (1994)
Henglein, F., Rehof, J.: Safe polymorphic type inference for a dynamically typed language: Translating Scheme to ML. In: Jones, S.P. (ed.) Proc. Functional Programming Languages and Computer Architecture 1995, La Jolla, CA, June 1995. ACM Press, New York (1995)
Marlow, S., Wadler, P.: A practical subtyping system for erlang. In: Proceedings of the second ACM SIGPLAN international conference on Functional programming, pp. 136–149. ACM Press, New York (1997)
Nishimura, S.: Static typing for dynamic messages. In: Cardelli, L. (ed.) Proc. 25th Annual ACM Symposium on Principles of Programming Languages, San Diego, CA, USA, January 1998, pp. 266–278. ACM Press, New York (1998)
Nyström, S.-O.: A soft-typing system for erlang. In: Proceedings of the 2003 ACM SIGPLAN workshop on Erlang, pp. 56–71. ACM Press, New York (2003)
The Mozilla Organization. Rhino: JavaScript for Java (September 2004), http://www.mozilla.org/rhino/
Pessaux, F., Leroy, X.: Type-based analysis of uncaught exceptions. In: Proceedings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 276–290. ACM Press, New York (1999)
Rémy, D.: Type inference for records in a natural extension of ML. In: Gunter, C.A., Mitchell, J.C. (eds.) Theoretical Aspects of Object-Oriented Programming: Types, Semantics, and Language Design. The MIT Press, Cambridge (1994)
Ungar, D., Smith, R.B.: SELF: The power of simplicity. Lisp and Symbolic Computation 4(3), 187–206 (1991)
Wright, A.K., Cartwright, R.: A practical soft type system for Scheme. ACM Transactions on Programming Languages and Systems 19(1), 87–152 (1997)
Yi, K.: An abstract interpretation for estimating uncaught exceptions in standard ML programs. Science of Computer Programming 31(1), 147–173 (1998)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Thiemann, P. (2005). Towards a Type System for Analyzing JavaScript Programs. In: Sagiv, M. (eds) Programming Languages and Systems. ESOP 2005. Lecture Notes in Computer Science, vol 3444. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-31987-0_28
Download citation
DOI: https://doi.org/10.1007/978-3-540-31987-0_28
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-25435-5
Online ISBN: 978-3-540-31987-0
eBook Packages: Computer ScienceComputer Science (R0)