Types play an important role in programming languages, by encoding contracts and invariants that enable modular programming and efficient code generation. Unfortunately, types can sometimes get in the way of rapid prototyping and code patching, which is why several popular languages for scripting are dynamically typed. These languages seem willing to trade the benefits of types for expressiveness and flexibility. Fortunately, type inference can restore most of the lost benefits to such languages, thereby letting programmers “have the cake and eat it too.”
In this talk I will describe two type inference techniques—one static and the other dynamic—for dynamically-typed languages. One technique is designed to improve the performance of dynamically-typed code without changing its behavior. The other technique is designed to unravel information on dynamically-typed code that is hard to analyze statically. I will conclude with some open questions on how to combine these techniques for pushing the state-of-the-art in compiling dynamically-typed languages.