Introducing safe unknown types in Java-like languages

  • Authors:
  • G. Lagorio;E. Zucca

  • Affiliations:
  • Università di Genova, Genova, Italy;Università di Genova, Genova, Italy

  • Venue:
  • Proceedings of the 2006 ACM symposium on Applied computing
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Most mainstream object-oriented languages, like C++, Java and C#, are statically typed. In recent years, untyped languages, in particular scripting languages for the web, have gained a lot of popularity notwithstanding the fact that the advantages of static typing, such as earlier detection of errors, are widely accepted. We think that one of the main reasons for their widespread adoption is that, in many situations, the ability of ignoring types can be handy to write simpler and more readable code.We propose an extension of Java-like languages which allows developers to forget about typing in strategic places of their programs without losing type-safety. That is, we allow programmers to write simpler code without sacrificing the advantages of static typing. This is achieved by means of inferred type constraints. These constraints describe the implicit requirements on untyped code to be correctly invoked.This flexibility comes at a cost: field accesses and method invocations on objects of unknown types are less efficient than regular field accesses and method invocations. Also, our type system is currently more restrictive than it should be; its extension is the subject of ongoing work. However, the novel approach presented here is quite interesting on its own, as it supports separate compilation and there is zero runtime overhead on code which does not take advantage of the new features.