Exploring Type Inference Techniques of Dynamically Typed Languages

C M Khaled Saifullah, Muhammad Asaduzzaman, Chanchal K. Roy


Abstract
Developers often prefer dynamically typed programming languages, such as JavaScript, because such languages do not require explicit type declarations. However, such a feature hinders software engineering tasks, such as code completion, type related bug fixes and so on. Deep learning-based techniques are proposed in the literature to infer the types of code elements in JavaScript snippets. These techniques are computationally expensive. While several type inference techniques have been developed to detect types in code snippets written in statically typed languages, it is not clear how effective those techniques are for inferring types in dynamically typed languages, such as JavaScript. In this paper, we investigate the type inference techniques of JavaScript to understand the above two issues further. While doing that we propose a new technique that considers the locally specific code tokens as the context to infer the types of code elements. The evaluation result shows that the proposed technique is 20-47% more accurate than the statically typed language-based techniques and 5–14 times faster than the deep learning techniques without sacrificing accuracy. Our analysis of sensitivity, overlapping of predicted types and the number of training examples justify the importance of our technique.
Cite:
C M Khaled Saifullah, Muhammad Asaduzzaman, and Chanchal K. Roy. 2020. Exploring Type Inference Techniques of Dynamically Typed Languages. 2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER).
Copy Citation: