License
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2015.519
URN: urn:nbn:de:0030-drops-52367
URL: http://drops.dagstuhl.de/opus/volltexte/2015/5236/
Go to the corresponding LIPIcs Volume Portal


Pradel, Michael ; Sen, Koushik

The Good, the Bad, and the Ugly: An Empirical Study of Implicit Type Conversions in JavaScript

pdf-format:
26.pdf (0.5 MB)


Abstract

Most popular programming languages support situations where a value of one type is converted into a value of another type without any explicit cast. Such implicit type conversions, or type coercions, are a highly controversial language feature. Proponents argue that type coercions enable writing concise code. Opponents argue that type coercions are error-prone and that they reduce the understandability of programs. This paper studies the use of type coercions in JavaScript, a language notorious for its widespread use of coercions. We dynamically analyze hundreds of programs, including real-world web applications and popular benchmark programs. We find that coercions are widely used (in 80.42% of all function executions) and that most coercions are likely to be harmless (98.85%). Furthermore, we identify a set of rarely occurring and potentially harmful coercions that safer subsets of JavaScript or future language designs may want to disallow. Our results suggest that type coercions are significantly less evil than commonly assumed and that analyses targeted at real-world JavaScript programs must consider coercions.

BibTeX - Entry

@InProceedings{pradel_et_al:LIPIcs:2015:5236,
  author =	{Michael Pradel and Koushik Sen},
  title =	{{The Good, the Bad, and the Ugly: An Empirical Study of Implicit Type Conversions in JavaScript}},
  booktitle =	{29th European Conference on Object-Oriented Programming (ECOOP 2015)},
  pages =	{519--541},
  series =	{Leibniz International Proceedings in Informatics (LIPIcs)},
  ISBN =	{978-3-939897-86-6},
  ISSN =	{1868-8969},
  year =	{2015},
  volume =	{37},
  editor =	{John Tang Boyland},
  publisher =	{Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik},
  address =	{Dagstuhl, Germany},
  URL =		{http://drops.dagstuhl.de/opus/volltexte/2015/5236},
  URN =		{urn:nbn:de:0030-drops-52367},
  doi =		{10.4230/LIPIcs.ECOOP.2015.519},
  annote =	{Keywords: Types, Type coercions, JavaScript, Dynamically typed languages}
}

Keywords: Types, Type coercions, JavaScript, Dynamically typed languages
Seminar: 29th European Conference on Object-Oriented Programming (ECOOP 2015)
Issue Date: 2015
Date of publication: 26.06.2015


DROPS-Home | Fulltext Search | Imprint Published by LZI