Composable Compilers: Evolution Toward a Practical Reality

Total Page:16

File Type:pdf, Size:1020Kb

Composable Compilers: Evolution Toward a Practical Reality COMPOSABLE COMPILERS: EVOLUTION TOWARD A PRACTICAL REALITY A Dissertation Presented to the Faculty of the Graduate School of Cornell University in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy by Chinawat Isradisaikul August 2017 c 2017 Chinawat Isradisaikul COMPOSABLE COMPILERS: EVOLUTION TOWARD A PRACTICAL REALITY Chinawat Isradisaikul, Ph.D. Cornell University 2017 The ability to add new features to programming languages is essential for language design experimentation and domain-specific developments, but implementing and maintaining small language extensions in traditional compilers remain a challenge. General-purpose programming languages do not have desired mechanisms to integrate small, indepen- dently developed extensions into a working programming language. At the same time, domain-specific languages that support such integration struggle to gain popularity in the programming language community. More language mechanisms and tools are needed as a middle ground so that a broader range of programmers can implement, maintain, and combine compilers for individual language features more easily. At the heart of compiler construction, new design patterns are proposed to allow compilers to be extended in a modular way and to be merged with little effort. These design patterns, implementable in a mainstream programming language, encode dynamic relationships between node types in abstract syntax trees (ASTs) so that inheritance in object-oriented programming still works over the course of language evolution. A new AST representation lets a single AST be viewed as different programs for different languages. Compiler passes are language-neutral, making translations reusable and composable. At the front end, engineering language syntax can be a painstaking process, espe- cially when individual language syntaxes start to interact. Automatic parser generators, albeit a powerful tool to parse complex grammars, are unhelpful when grammars are faulty, as reports of parsing conflicts do not explain these faults. To improve debugging experience, a semi-decision procedure is added to an LALR parser generator to give compact counterexamples illustrating why the grammar in question is ambiguous. For unambiguous grammars that cause parsing conflicts, a different kind of counterexample is constructed to aid removal of conflicts. At the back end, translation passes in compilers require extracting components of AST nodes. Pattern matching, an important feature in functional languages, is a prime candidate for this task. However, data abstraction and extensibility, two concepts central to object-oriented languages, are in conflict with pattern matching. A new language design based on modal abstraction reconciles static, modular reasoning about exhaustiveness in pattern matching with data abstraction. BIOGRAPHICAL SKETCH Chinawat (Chin) Isradisaikul [tCh¯in.n¯a.w´at `it.s¯a.r¯a:.d`i.sˇaj.k¯un] was born on the Day of Vesak 1985 (Visakha Bucha) in Phitsanulok [ph´it.s¯a.n´u.lˆo:k], Thailand. His first encounter with a computer was in the fifth grade, when he learned CU Writer, a Thai document processing program on DOS, in his lower school’s new computer lab. Although Chin did not own a computer until the tenth grade, his interactions with computers were continuous, thanks to opportunities in his middle school. Installing Windows 95 on dozens of desktop, connecting them to LAN, breaking a few of them, and developing the school’s website were part of his ninth-grade routine. BASIC was Chin’s first programming language which he learned upon graduat- ing from middle school and moving to Bangkok to attend Triam Udom Suksa School [tr¯ia:m.`u.d¯om.s`Wk.sˇa:]. During his first semester break, he attended a programming camp to learn C, which became his primary programming language throughout high school. Chin wrote an ASCII variant of Who Wants to Be a Millionaire? as his first C application for his friends and family to enjoy. The programming camp would be first of several camps that prepared Chin for representing Thailand in the International Olympiad in Informatics. Even if he missed the cut in the end, that was enough to qualify him for a Royal Thai Government scholarship to study abroad. He attended Westtown School in West Chester, Pennsylvania in 2004 as part of the college preparation program. There, he learned Java in his AP Computer Science class. Upon graduating from Westtown, Chin attended the University of Pennsylvania in Philadelphia, double majoring in computer science and mathematics. At Penn, his first CS course in discrete math introduced him to inference rules, which sparked his interest in logic and formal proofs. Chin’s interests in compilers grew out of the Introduction to Compilers course he took in his senior year, in which he learned his first functional programming language, OCaml, and implemented his first compiler without getting iii register allocation to work. He then moved to Ithaca, New York, to pursue a Ph.D. in computer science at Cornell University. Apart from research, Chin appreciates teaching and interacting with students, which in turn helped him become a better researcher. His dedication in teaching earned him the Yahoo! Outstanding Graduate Teaching Award in 2010. For most of his time in the United States, Chin has contributed academically to the Thai Scholar Program from helping new students adjust to American culture in the summer to proofreading their college applications every Christmas. In 2009, he implemented the Thai Scholar College Information System to streamline the college application process for Thai Scholars. The system has been in use since then, minimizing mundane tasks for both students and program staff. Outside academics, Chin loves nature, enjoys traveling, and practices photography. In 2012, he received training from the National Weather Service in Binghamton to become a SKYWARN spotter volunteer for Tompkins County. He served as the Cornell CS Photo Czar from 2013 to 2017, taking photos of incoming Ph.D. students. Chin is an avid skier, despite getting started after his A exam at Cornell. iv To my family, near and far. ACKNOWLEDGMENTS This dissertation would not be possible without help and advice from Andrew Myers, my advisor, who knows when to pull me ahead and when to push me from behind. Andrew, you showed me there is always a research problem to solve, whether easy or hard, whether decidable or undecidable. Whenever I seemed to run out of ideas, your suggestions usually gave me a way forward. You taught me how to give a good conference talk, restored my faith that constructive criticisms do exist, and warned me that it is possible to spend countless hours hacking TEX. For that, I am grateful. My Ph.D. career at Cornell would be less enjoyable without insightful and fun gradu- ate courses taught by Dexter Kozen and Bob Constable, my special committee members. Your courses kept my thoughts organized, kept my reasoning sound, and instilled in me the value of teaching and its connections with research. Your encouragements in our conversations propelled me through the finish line. For that, I am grateful. Past and present members of the Applied Programming Languages group—Steve Zdancewic, Nate Nystrom, Steve Chong, Jed Liu, Mike George, Krishnaprasad Vikram, Danfeng Zhang, Owen Arden, Tom Magrino, Yizhou Zhang, Isaac Sheff, Matthew Milano, and Ethan Cecchetti—contributed to my success as an undergraduate (Steve in this case) and a graduate student, whether academically, mentally, or morally. Countless interactions, countless hours, and countless comments you gave me made my scattered research ideas solid, made my convoluted paper drafts distinguished, and made my overambitious practice talks appreciated. For that, I am grateful. Ross Tate, Adrian Sampson, Aslan Askarov, Robert Soule,´ Abhishek Anand, Mark Reitblatt, Andrew Hirsch, Fabian Muehlboeck, and Harry Terkelsen are among other members of the programming languages field at Cornell CS who gave me invaluable suggestions and comments on my research papers. For that, I am thankful. vi Conveying research ideas would be less effective if communication skills were not kept practiced. I appreciate the opportunities in teaching from the Department of Computer Science, both at the University of Pennsylvania and at Cornell University, that allowed me to reinforce these skills. Val Tannen, Sampath Kannan, Daisy Fan, Andrew Myers, and Adrian Sampson were my role models who set a high expectation in structuring, managing, and running CS courses, small or large, undergrad or grad. They are excellent instructors who bring high-quality students to their courses for which I was on staff. In turn, these students propelled me to maintain a high standard as a teaching assistant. For that, I am thankful. Becky Stewart, Assistant Director of the Ph.D. Program, deals with everything from processing forms to answering hundreds of questions I had about keeping the department running and keeping my Ph.D. career going, or simply by being there just to chat. Becky, you helped me with bureaucrazy from the beginning to the end. For that, I am thankful. The Thai students and staff at Cornell not only form a tight-knit community that lets me wind down outside my research time, but also give me support when I need the most. Special thanks go to Apikanya (M) McCarty, Pakawat (Kun) Phalitnonkiat, Chayanee (Namtip) Chawanote, Raksit (A) Pattanapitoon, Kullachate (Oath) Muang- napoh, Tanapong (Nont) Jiarathanakul, Pimbucha (Pim) Rusmevichientong, Bunyarit (Pao) Meksiriporn, Sunsiree (Wahn) Kosindesha, Siraphat (Fay) Taesuwan, Chalermpat (Nong) Pariya-Ekkasut, Visarute (Earth) Pinrod, Ithipong (Billy) Assaranurak, Thapakorn (Hize) Jaroentomeechai, Kittkun (Ob) Songsomboon, Fikri (Fik) Pitsuwan, Pidchapon (Fai) Niruthisard, and Ravi (Note) Laohasurayodhin, who helped me with practice talks, tortured me with checkmate moves in the Settlers of Catan and Dominion, planned road trips, cooked good food, and went to snowy mountains with me. Guys, you kept me alive, kept me lively, and kept me in check during all these years. We are the force that will make Thailand an even better place.
Recommended publications
  • Structuring Languages As Object-Oriented Libraries
    Structuring Languages as Object-Oriented Libraries Structuring Languages as Object-Oriented Libraries ACADEMISCH PROEFSCHRIFT ter verkrijging van de graad van doctor aan de Universiteit van Amsterdam op gezag van de Rector Magnificus prof. dr. ir. K. I. J. Maex ten overstaan van een door het College voor Promoties ingestelde commissie, in het openbaar te verdedigen in de Agnietenkapel op donderdag november , te . uur door Pablo Antonio Inostroza Valdera geboren te Concepción, Chili Promotiecommissie Promotores: Prof. Dr. P. Klint Universiteit van Amsterdam Prof. Dr. T. van der Storm Rijksuniversiteit Groningen Overige leden: Prof. Dr. J.A. Bergstra Universiteit van Amsterdam Prof. Dr. B. Combemale University of Toulouse Dr. C. Grelck Universiteit van Amsterdam Prof. Dr. P.D. Mosses Swansea University Dr. B.C.d.S. Oliveira The University of Hong Kong Prof. Dr. M. de Rijke Universiteit van Amsterdam Faculteit der Natuurwetenschappen, Wiskunde en Informatica The work in this thesis has been carried out at Centrum Wiskunde & Informatica (CWI) under the auspices of the research school IPA (Institute for Programming research and Algorith- mics) and has been supported by NWO, in the context of Jacquard Project .. “Next Generation Auditing: Data-Assurance as a Service”. Contents Introduction .Language Libraries . .Object Algebras . .Language Libraries with Object Algebras . .Origins of the Chapters . .Software Artifacts . .Dissertation Structure . Recaf: Java Dialects as Libraries .Introduction . .Overview.................................... .Statement Virtualization . .Full Virtualization . .Implementation of Recaf . .Case Studies . .Discussion . .Related Work . .Conclusion . Tracing Program Transformations with String Origins .Introduction . .String Origins . .Applications of String Origins . .Implementation . .Related Work . .Conclusion . Modular Interpreters with Implicit Context Propagation .Introduction . .Background . v Contents .Implicit Context Propagation .
    [Show full text]
  • A History of Clojure
    A History of Clojure RICH HICKEY, Cognitect, Inc., USA Shepherd: Mira Mezini, Technische Universität Darmstadt, Germany Clojure was designed to be a general-purpose, practical functional language, suitable for use by professionals wherever its host language, e.g., Java, would be. Initially designed in 2005 and released in 2007, Clojure is a dialect of Lisp, but is not a direct descendant of any prior Lisp. It complements programming with pure functions of immutable data with concurrency-safe state management constructs that support writing correct multithreaded programs without the complexity of mutex locks. Clojure is intentionally hosted, in that it compiles to and runs on the runtime of another language, such as the JVM. This is more than an implementation strategy; numerous features ensure that programs written in Clojure can leverage and interoperate with the libraries of the host language directly and efficiently. In spite of combining two (at the time) rather unpopular ideas, functional programming and Lisp, Clojure has since seen adoption in industries as diverse as finance, climate science, retail, databases, analytics, publishing, healthcare, advertising and genomics, and by consultancies and startups worldwide, much to the career-altering surprise of its author. Most of the ideas in Clojure were not novel, but their combination puts Clojure in a unique spot in language design (functional, hosted, Lisp). This paper recounts the motivation behind the initial development of Clojure and the rationale for various design decisions and language constructs. It then covers its evolution subsequent to release and adoption. CCS Concepts: • Software and its engineering ! General programming languages; • Social and pro- fessional topics ! History of programming languages.
    [Show full text]
  • Good Advice for Type-Directed Programming
    Good Advice for Type-directed Programming Aspect-oriented Programming and Extensible Generic Functions Geoffrey Washburn Stephanie Weirich University of Pennsylvania {geoffw,sweirich}@cis.upenn.edu ABSTRACT of type-directed combinators to “scrap” this boilerplate. For Type-directed programming is an important idiom for soft- example, L¨ammeland Peyton Jones’s Haskell library pro- ware design. In type-directed programming the behavior of vides a combinator called gmapQ that maps a query over programs is guided by the type structure of data. It makes an arbitrary value’s children returning a list of the results. it possible to implement many sorts of operations, such as Using gmapQ it becomes trivial to implement a type-directed serialization, traversals, and queries, only once and without function, gsize, to compute the size of an arbitrary value. needing to continually revise their implementation as new gsize :: Data a => a -> Int data types are defined. gsize x = 1 + sum (gmapQ gsize x) Type-directed programming is the basis for recent research into “scrapping” tedious boilerplate code that arises in func- However, this line of research focused on closed type- tional programming with algebraic data types. This research directed functions. Closed type-directed functions require has primarily focused on writing type-directed functions that that all cases be defined in advance. Consequently, if the are closed to extension. However, L¨ammel and Peyton Jones programmer wanted gsize to behave in a specialized fashion recently developed a technique for writing openly extensible for one of their data types, they would need to edit the type-directed functions in Haskell by making clever use of definition of gmapQ.
    [Show full text]
  • Functional Programming Patterns in Scala and Clojure Write Lean Programs for the JVM
    Early Praise for Functional Programming Patterns This book is an absolute gem and should be required reading for anybody looking to transition from OO to FP. It is an extremely well-built safety rope for those crossing the bridge between two very different worlds. Consider this mandatory reading. ➤ Colin Yates, technical team leader at QFI Consulting, LLP This book sticks to the meat and potatoes of what functional programming can do for the object-oriented JVM programmer. The functional patterns are sectioned in the back of the book separate from the functional replacements of the object-oriented patterns, making the book handy reference material. As a Scala programmer, I even picked up some new tricks along the read. ➤ Justin James, developer with Full Stack Apps This book is good for those who have dabbled a bit in Clojure or Scala but are not really comfortable with it; the ideal audience is seasoned OO programmers looking to adopt a functional style, as it gives those programmers a guide for transitioning away from the patterns they are comfortable with. ➤ Rod Hilton, Java developer and PhD candidate at the University of Colorado Functional Programming Patterns in Scala and Clojure Write Lean Programs for the JVM Michael Bevilacqua-Linn The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals.
    [Show full text]
  • Extensibility for the Masses Practical Extensibility with Object Algebras
    Extensibility for the Masses Practical Extensibility with Object Algebras Bruno C. d. S. Oliveira1 and William R. Cook2 1 Seoul National University [email protected] 2 University of Texas, Austin [email protected] Abstract. This paper presents a new solution to the expression problem (EP) that works in OO languages with simple generics (including Java or C#). A key novelty of this solution is that advanced typing features, including F-bounded quantification, wildcards and variance annotations, are not needed. The solution is based on object algebras, which are an abstraction closely related to algebraic datatypes and Church encodings. Object algebras also have much in common with the traditional forms of the Visitor pattern, but without many of its drawbacks: they are extensible, remove the need for accept methods, and do not compromise encapsulation. We show applications of object algebras that go beyond toy examples usually presented in solutions for the expression problem. In the paper we develop an increasingly more complex set of features for a mini-imperative language, and we discuss a real-world application of object algebras in an implementation of remote batches. We believe that object algebras bring extensibility to the masses: object algebras work in mainstream OO languages, and they significantly reduce the conceptual overhead by using only features that are used by everyday programmers. 1 Introduction The “expression problem” (EP) [37,10,45] is now a classical problem in program- ming languages. It refers to the difficulty of writing data abstractions that can be easily extended with both new operations and new data variants.
    [Show full text]
  • The Joy of Clojure by Michael Fogus and Chris Houser
    Michael Fogus Chris Houser FOREWORD BY STEVE YEGGE MANNING The Joy of Clojure by Michael Fogus and Chris Houser Chapter 1 Copyright 2011 Manning Publications brief contents PART 1 FOUNDATIONS ......................................................................1 1 ■ Clojure philosophy 3 2 ■ Drinking from the Clojure firehose 20 3 ■ Dipping our toes in the pool 43 PART 2 DATA TYPES ........................................................................59 4 ■ On scalars 61 5 ■ Composite data types 76 PART 3 FUNCTIONAL PROGRAMMING............................................. 105 6 ■ Being lazy and set in your ways 107 7 ■ Functional programming 125 PART 4 LARGE-SCALE DESIGN ........................................................ 155 8 ■ Macros 157 9 ■ Combining data and code 177 10 ■ Java.next 207 11 ■ Mutation 234 PART 5 TANGENTIAL CONSIDERATIONS.......................................... 275 12 ■ Performance 277 13 ■ Clojure changes the way you think 292 vii Clojure philosophy This chapter covers The Clojure way Why a(nother) Lisp? Functional programming Why Clojure isn’t especially object-oriented Learning a new language generally requires significant investment of thought and effort, and it is only fair that programmers expect each language they consider learning to justify that investment. Clojure was born out of creator Rich Hickey’s desire to avoid many of the complications, both inherent and incidental, of manag- ing state using traditional object-oriented techniques. Thanks to a thoughtful design based in rigorous programming language research, coupled with a fervent look toward practicality, Clojure has blossomed into an important programming language playing an undeniably important role in the current state of the art in lan- guage design. On one side of the equation, Clojure utilizes Software Transactional Memory (STM), agents, a clear distinction between identity and value types, arbi- trary polymorphism, and functional programming to provide an environment con- ducive to making sense of state in general, and especially in the face of concurrency.
    [Show full text]
  • CS 251: Programming Languages Fall 2015 Ruby/OOP Summary, Part 2
    CS 251: Programming Languages Fall 2015 Ruby/OOP Summary, Part 2 These notes are adapted from CSE 341 at the University of Washington, by Dan Grossman. Contents OOP Versus Functional Decomposition ................................ 1 Extending the Code With New Operations or Variants ...................... 4 Binary Methods With Functional Decomposition .......................... 6 Binary Methods in OOP: Double Dispatch .............................. 7 Multimethods ................................................ 11 Multiple Inheritance ............................................ 11 Mixins ..................................................... 13 Java/C#-Style Interfaces ......................................... 16 Abstract Methods .............................................. 16 Introduction to Subtyping ........................................ 17 A Made-Up Language of Records .................................... 18 Wanting Subtyping ............................................. 19 The Subtyping Relation .......................................... 19 Depth Subtyping: A Bad Idea With Mutation ........................... 20 The Problem With Java/C# Array Subtyping ........................... 21 Function Subtyping ............................................. 22 Subtyping for OOP ............................................. 25 Covariant self/this ............................................. 26 Generics Versus Subtyping ........................................ 26 Bounded Polymorphism .......................................... 29 Optional:
    [Show full text]
  • Feature-Oriented Programming with Object Algebras
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by CWI's Institutional Repository Feature-Oriented Programming with Object Algebras Bruno C.d.S. Oliveira1, Tijs van der Storm2, Alex Loh3, William R. Cook3 1National University of Singapore ([email protected]) 2Centrum Wiskunde & Informatica (CWI) ([email protected]) 3 University of Texas, Austin ({wcook,alexloh}@cs.utexas.edu) Abstract. Object algebras are a new programming technique that en- ables a simple solution to basic extensibility and modularity issues in programming languages. While object algebras excel at defining modu- lar features, the composition mechanisms for object algebras (and fea- tures) are still cumbersome and limited in expressiveness. In this paper we leverage two well-studied type system features, intersection types and type-constructor polymorphism, to provide object algebras with expres- sive and practical composition mechanisms. Intersection types are used for defining expressive run-time composition operators (combinators) that produce objects with multiple (feature) interfaces. Type-constructor polymorphism enables generic interfaces for the various object algebra combinators. Such generic interfaces can be used as a type-safe front end for a generic implementation of the combinators based on reflection. Ad- ditionally, we also provide a modular mechanism to allow different forms of self -references in the presence of delegation-based combinators. The result is an expressive, type-safe, dynamic, delegation-based composition technique for object algebras, implemented in Scala, which effectively enables a form of Feature-Oriented Programming using object algebras. 1 Introduction Feature-oriented programming (FOP) is a vision of programming in which in- dividual features can be defined separately and then composed to build a wide variety of particular products [5,21,43].
    [Show full text]
  • Clojerl: the Expressive Power of Clojure on the BEAM
    Clojerl: The Expressive Power of Clojure on the BEAM Juan Facorro Natalia Chechina Stockholm, Sweden Bournemouth University [email protected] Bournemouth, United Kindgdom [email protected] Abstract 1 Introduction The development of new features and approaches in pro- In the past couple of decades platforms built around virtual gramming languages is a continuous and never-ending task, machines and language engines, such as the Java Virtual as languages are ultimately tools for expressing and solving Machine (JVM), the Erlang VM (BEAM), .NET’s Common problems. The past decade has seen a surge in languages Language Runtime (CLR), and Javascript’s V8 Engine, have implemented for the BEAM as part of a search to combine grown and matured into ecosystems of tools and libraries. the fault-tolerance and scalability of the BEAM with a set of These platforms have also enabled and encouraged the imple- desired language features. mentation of programming languages other than the official In this paper we present Clojerl, an implementation of the group supported by each platform. As a result, people look- Clojure language with a rich set of data processing capabil- ing to take the best from the two worlds, combining their ities and the expressive power of Lisp for the BEAM. The language of choice with the power of a specific platform, main design principles of Clojerl are to provide (1) seam- have created new language implementations. less interoperability with the BEAM to enable frictionless A programming language is ultimately just a tool for solv- interaction with other BEAM languages and (2) portability ing problems.
    [Show full text]
  • Reliably Composable Language Extensions
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by University of Minnesota Digital Conservancy Reliably composable language extensions A Dissertation SUBMITTED TO THE FACULTY OF THE UNIVERSITY OF MINNESOTA BY Ted Kaminski IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY Eric Van Wyk May, 2017 Copyright © 2017 Ted Kaminski. Acknowledgments I am unlikely to do justice to everyone I should thank here. I should begin by thanking my advisor, Eric Van Wyk, who has been a been a better mentor than I had even expected going in, and I had pretty optimistic expectations. I would also like to thank my thesis committee members: Gopalan Nadathur, Mike Whalen, and Tim Hunter. All of them helped provide valuable feedback in polishing this thesis. I also want to thank my ex-committee member, Wayne Richter, who retired before I finished this thing off. I’d like to thank other students in this department, without whom grad school would hardly have been as excellent as it was: Nate Bird, Morten Warncke-Wang, Aaron Halfaker, Michael Ekstrand, Sarah McRoberts, Andy Exley, Hannah Miller, Sean Landman, Dane Coffey, Fedor Korsakov, and you know, tag yourselves. Sorry Reid. I’d also like to thank the colleagues I’ve had a chance to talk shop with, especially Tony Sloane and Jurgen Vinju. I’d like to thank math friends, Shelley Kandola and Maggie Ewing, who provided some welcome diversions into things that aren’t a part of this thesis, unfortunately. As for Minneapolis in general, best place on Earth, there are too many people to name, but Eli Cizewski-Robinson must appear here.
    [Show full text]
  • Typed First-Class Traits
    Typed First-Class Traits Xuan Bi The University of Hong Kong, Hong Kong, China [email protected] Bruno C. d. S. Oliveira The University of Hong Kong, Hong Kong, China [email protected] Abstract Many dynamically-typed languages (including JavaScript, Ruby, Python or Racket) support first-class classes, or related concepts such as first-class traits and/or mixins. In those languages classes are first-class values and, like any other values, they can be passed as an argument, or returned from a function. Furthermore first-class classes support dynamic inheritance: i.e. they can inherit from other classes at runtime, enabling programmers to abstract over the inheritance hierarchy. In contrast, type system limitations prevent most statically-typed languages from having first-class classes and dynamic inheritance. This paper shows the design of SEDEL: a polymorphic statically-typed language with first- class traits, supporting dynamic inheritance as well as conventional OO features such as dynamic dispatching and abstract methods. To address the challenges of type-checking first-class traits, SEDEL employs a type system based on the recent work on disjoint intersection types and dis- joint polymorphism. The novelty of SEDEL over core disjoint intersection calculi are source level features for practical OO programming, including first-class traits with dynamic inherit- ance, dynamic dispatching and abstract methods. Inspired by Cook and Palsberg’s work on the denotational semantics for inheritance, we show how to design a source language that can be elaborated into Alpuim et al.’s Fi (a core polymorphic calculus with records supporting disjoint polymorphism). We illustrate the applicability of SEDEL with several example uses for first- class traits, and a case study that modularizes programming language interpreters using a highly modular form of visitors.
    [Show full text]
  • Concepts in Programming Languages
    Concepts in Programming Languages Alan Mycroft1 Computer Laboratory University of Cambridge CST Paper 7: 2017–2018 (Easter Term) www.cl.cam.ac.uk/teaching/1718/ConceptsPL/ 1Acknowledgement: various slides are based on Marcelo Fiore’s 2013/14 course. 1 / 240 Practicalities I Course web page: www.cl.cam.ac.uk/teaching/1718/ConceptsPL/ with lecture slides, exercise sheet and reading material. These slides play two roles – both “lecture notes" and “presentation material”; not every slide will be lectured in detail. I There are various code examples (particularly for JavaScript and Java applets) on the ‘materials’ tab of the course web page. I One exam question. I The syllabus and course has changed somewhat from that of 2015/16. I would be grateful for comments on any remaining ‘rough edges’, and for views on material which is either over- or under-represented. 2 / 240 Main books I J. C. Mitchell. Concepts in programming languages. Cambridge University Press, 2003. I T.W. Pratt and M. V.Zelkowitz. Programming Languages: Design and implementation (3RD EDITION). Prentice Hall, 1999. ? M. L. Scott. Programming language pragmatics (4TH EDITION). Elsevier, 2016. I R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013. 3 / 240 Context: so many programming languages Peter J. Landin: “The Next 700 Programming Languages”, CACM (published in 1966!). Some programming-language ‘family trees’ (too big for slide): http://www.oreilly.com/go/languageposter http://www.levenez.com/lang/ http://rigaux.org/language-study/diagram.html http://www.rackspace.com/blog/ infographic-evolution-of-computer-languages/ Plan of this course: pick out interesting programming-language concepts and major evolutionary trends.
    [Show full text]