Cross-Platform Language Design

Cross-Platform Language Design

Cross-Platform Language Design THIS IS A TEMPORARY TITLE PAGE It will be replaced for the final print by a version provided by the service academique. Thèse n. 1234 2011 présentée le 11 Juin 2018 à la Faculté Informatique et Communications Laboratoire de Méthodes de Programmation 1 programme doctoral en Informatique et Communications École Polytechnique Fédérale de Lausanne pour l’obtention du grade de Docteur ès Sciences par Sébastien Doeraene acceptée sur proposition du jury: Prof James Larus, président du jury Prof Martin Odersky, directeur de thèse Prof Edouard Bugnion, rapporteur Dr Andreas Rossberg, rapporteur Prof Peter Van Roy, rapporteur Lausanne, EPFL, 2018 It is better to repent a sin than regret the loss of a pleasure. — Oscar Wilde Acknowledgments Although there is only one name written in a large font on the front page, there are many people without which this thesis would never have happened, or would not have been quite the same. Five years is a long time, during which I had the privilege to work, discuss, sing, learn and have fun with many people. I am afraid to make a list, for I am sure I will forget some. Nevertheless, I will try my best. First, I would like to thank my advisor, Martin Odersky, for giving me the opportunity to fulfill a dream, that of being part of the design and development team of my favorite programming language. Many thanks for letting me explore the design of Scala.js in my own way, while at the same time always being there when I needed him. I am grateful to James Larus, Edouard Bugnion, Andreas Rossberg and Peter Van Roy who have accepted to be part of my thesis jury, for the time they have invested in reading my thesis, criticize it, and for the incredible amount of constructive feedback they have given during the defense and afterwards. Special thanks go to Tobias Schlatter, whose contributions to the design and development of Scala.js, and therefore to the contents of this thesis, cannot be overstated. I have had many ideas during my Ph.D., and if today you can read about the good ones, it is because Tobias prevented me from pursuing the bad ones. Tobias, I wish I could have added your name on that front page. Thanks to Nicolas Stucki, for all the work he poured into Scala.js, identifying and ironing out so many details I had left unattended. And for tolerating my Spanish every once in a while. I would like to thank all my other colleagues at LAMP,Scala Center and associates, past and present, for all the discussions, beers and burgers, movie nights, concerts, songs, videos and Spikeball evenings that I had the pleasure to share with. Ingo, Miguel, Chris, Tiark, Alex, Lukas, Hubert, Vlad, Heather, Manohar, Vojin, Nada, Eugene, Felix, Sandro, Denys, Guillaume, Georg, Mia, Fengyun, Paolo, Olivier, Aggelos, Allan, Travis, Julien, Jorge, Ólafur, Guillaume, Martin, Darja, Danielle, Natascha, Sylvie and Fabien. Special thanks to my office mates, Ingo, Vojin, Ólaf and Denys, for the friendly discussions over our respective desks. To Mano and Sandro, for many hours spent drinking at Sat or ELA, singing, making videos, and singing over a drink v Acknowledgments to make videos at Sat or ELA. To Denys, Guillaume, Georg and Mia, for an awesome trip to India. To Danielle, Natascha and Fabien, whose excellent work allowed me to do mine in the best conditions. Before starting a Ph.D., one needs to get a master’s degree, and in my case, even start another Ph.D. that I later dropped. Thanks to the faculty members of INGI at UCL, in particular Peter Van Roy, Olivier Bonaventure and Charles Pecheur, for their support. Scala.js would never have become what it is without the early adopters and leaders in the community. Whether they reported issues, raised usability concerns, gave talks around the world, wrote blog posts, or built inspiring libraries, their involvement was instrumental in the development of Scala.js. For that, I would like to thank Li Haoyi, Otto Chrons, Mark Waks aka Justin du Cœur, David Barri, and many, many others. Pendant une thèse de doctorat, on a bien besoin d’être entouré de personnes qui peuvent vous éloigner du travail de temps en temps. Celles et ceux qui me connaissent savent que je passe beaucoup de temps dans des chœurs et ensembles vocaux. Je ne pourrai jamais assez remercier tou·te·s les choristes avec qui j’ai eu l’occasion de chanter pendant ces cinq années. Un merci tout particulier à mes chef·fe·s de chœur : Christine Donzel, Marie-Hélène Essade, Théo Schmitt, Anne Gallot-Lavallée, Guillaume Rault, et bien sûr Fruzsina Szuromi. Merci également à Małgorzata, Maëlle et Sérgio, ainsi que tou·te·s les membres de l’Ensemble Vocal Évohé, pour toutes les heures passées à chanter ensemble. Si je ne suis pas en train de développer ni de chanter, il ne reste qu’une solution : je tente d’apprendre le japonais. Merci à 裕子先生 pour sa patience et son enthousiasme continus, ainsi qu’à ティモテさん, クロエさん, ソフィアさん et エレンさん pour les heures de japonais et de sushi. Merci à mes ami·e·s éloigné·e·s, qui même après des mois voire des années, m’accueillent toujours comme s’il ne s’était passé qu’un jour : Arnaud dit Arnal, Astrid, Caroline, Claire, Daniel, Delphine, Émile, Hélène, Julie, Małgorzata dite Maggie, Martin, Rebecca dite Becca, Stéphane, Tiphaine. Leur amitié est un don infiniment précieux. Finalement, un tout grand merci à ma famille. À ma sœur Alice, pour son enthousiasme débordant, ses « pouf, quelle journée! » à 9h du matin et ses recommendations de mangas. À ma sœur Sophie, pour les vacances au ski et ses recommendations de séries. À ma belle-sœur Souad, qui s’efforce de m’empêcher de sombrer totalement dans l’asociabilité. À mon frère Antoine, pour les discussions à propos de Scala.js et d’informatique en général. Et à mes parents et grands-parents, qui m’ont donné toutes les chances dont j’avais besoin pour arriver où j’en suis, et pour leur support inconditionnel. Lausanne, July 20, 2018 Sébastien Doeraene vi Abstract Programming languages are increasingly compiled to multiple runtimes, each featuring their own rich structures such as their object model. Furthermore, they need to interact with other languages targeting said runtimes. A language targeting only one runtime can be designed to tailor its semantics to those of that runtime, for easy interoperability with other languages. However, in a language targeting multiple runtimes with differing semantics, it is difficult to cater to each of them while retaining a common behavior across runtimes. We call cross-platform language a language that aims at being both portable across platforms and interoperable with each target platform. Portability is the ability for a program or a library to cross-compile for multiple platforms, and behave the same way on all of them. Interoperability is the ability to communicate with other languages on the same platform. While many cross- compiling languages focus on one of these two properties—only adding support for the other one as an afterthought—, languages that are designed from the ground up to support both are rare. In this thesis, we present the design of Scala.js, the dialect of Scala targeting the JavaScript platform, which turned Scala into a cross-platform language. On the one hand, Scala programs can be cross-compiled for the JVM and JavaScript with portable semantics. On the other hand, whereas Scala/JVM interoperates with Java, Scala.js interoperates with JavaScript, allowing to use any JavaScript library. Along the dissertation, we give insights that can be transferred to the design of other cross-platform languages, although with a bias towards those targeting the JVM and JavaScript. The first and most obvious challenge is to reconcile the static nature of Scala’s object model with JavaScript’s dynamic one. Besides the ability to mutate a class hierarchy at run-time in JavaScript, there are fundamental differences between the two models, in particular the difference between compile-time overloading and run-time overloading. We discuss how such semantic mismatches can live in harmony within the language. The second challenge is to obtain good performance from a language where interoperability with a dynamic and unknown part of the program is pervasive. To that end, we design and specify an intermediate representation (IR) with first-class support for dynamically typed interoperability features in addition to statically typed JVM-style operations. Despite its tight integration with the open world of JavaScript, most of the IR can be considered as a closed vii Acknowledgments world where advanced whole-program optimizations can be performed. The performance of the overall system is evaluated and shown to be competitive with hand-written JavaScript, and even with Scala/JVM in some cases. Keywords: interoperability, portability, language design, cross-platform, performance, Scala, JavaScript. viii Résumé De plus en plus fréquemment, les langages de programmation sont compilés vers plusieurs environnements d’exécutions (runtimes), chacun avec leurs riches structures telles que leur modèle objet. En outre, ils se doivent d’interagir avec les autres langages qui y résident. Un langage visant un unique runtime peut tailler ses sémantiques sur mesure pour celui-ci, de sorte à présenter une interopérabilité aisée avec les autres langages. En revanche, dans un langage qui vise plusieurs runtimes avec des sémantiques divergentes, il est difficile de se spécialiser pour chacune d’elles tout en conservant un comportement commun entre les runtimes. Nous appelons langage transplateforme un langage qui aspire à être à la fois portable à travers plateformes et interopérable avec chacune des plateformes visées.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    184 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us