deposit_your_work

Compiling dynamic languages via statically typed functional languages

Files in this item

Files Size Format View
3362128.PDF 3.045Mb application/pdf Thumbnail

Show full item record

Item Metadata

Title: Compiling dynamic languages via statically typed functional languages
Author: Bandyopadhyay, Rajarshi
Advisor: Taha, Walid
Degree: Doctor of Philosophy thesis
Abstract: Dynamic languages enable rapid prototyping, but are generally not viewed as providing the best performance. As a result, software developers generally build a prototype in a dynamic language and then rewrite the application in C or Fortran for high performance. This costly rewriting step can be avoided by improving the performance of dynamic languages. Dynamic languages are usually interpreted for easier implementation. The traditional approach to improve their performance is to build an optimizing compiler. However, building a compiler from scratch is much more time-consuming than implementing an interpreter. Our thesis is that we can build effective compilers for dynamic languages by translating them into statically typed functional languages which have good compilers and automatic memory management. In particular, we believe that modern statically typed languages provide precise control over data representations, and come with runtime systems that have competitive performance. To investigate the viability of this approach, we have built a compiler for the dynamic language Python by translating it into the statically typed functional language OCaml. An interesting practical advantage of using modern statically typed functional languages is that they use Hindley-Milner type systems, which means that there is no need for the translation to construct type terms. We compare the performance of our implementation, Monty, with that of CPython, the reference Python implementation, and with Jython, a Java implementation of Python, using a suite of 370 benchmarks. Our experiments show that some programs compiled using our approach run up to 4.6 times faster than CPython. However, due to a number of engineering reasons, some programs also run significantly slower than CPython. We pinpoint the specific causes of performance degradation and assess the potential for removing these causes in future work. Our implementation is significantly faster than Jython, up to a factor of 100 in some cases. A by product of our research is a proposal for an improved array copying implementation in OCaml.
Citation: Bandyopadhyay, Rajarshi. (2009) "Compiling dynamic languages via statically typed functional languages." Doctoral Thesis, Rice University. http://hdl.handle.net/1911/61785.
URI: http://hdl.handle.net/1911/61785
Date: 2009

This item appears in the following Collection(s)