Cross-Language Interop Poster

Total Page:16

File Type:pdf, Size:1020Kb

Cross-Language Interop Poster Low Cognitive Overhead Bridging "Interoperability isn't just a technical problem, it's also a user interface problem. We have to make it easy to call between languages, so that users can The demo shown at FOSDEM always pick the most appropriate tool for the job at hand." example [ this year showed fully dynamic "This shows how to call a C function from Smalltalk" development spanning C objc_setAssociatedObject: { Objective-C and Smalltalk. The self. 42. developer can inspect the ’fishes’. existing class hierarchy and C enumValue: OBJC_ASSOCIATION_ASSIGN }. the code for any methods "Note how C enumerations can be accessed. When encountering this construct, the Pragmatic Smalltalk compiler will generate exactly the same code as an implemented in Smalltalk. It Objective-C compiler would for this line: is also possible to add, modify, objc_setAssociatedObject(self, 42, @"fishes", OBJC_ASSOCIATION_ASSIGN); or replace methods, add It will get the types for the function by parsing the header and automatically map Smalltalk types to C and Objective-C types. The instance variables and classes Easy Development programmer doesn't need to write any bridging or foreign function interface at run time. Invoking a code." nonexistent class or method (C objc_getAssociatedObject: {self . 42 }) log. ] pops up a dialog asking the user to implement it, all from within a running app. The final version is statically compiled, with no explicit user Cross-Language Interoperability for intervention required. Fast, Easy, and Maintainable Code David Chisnall The World Today: But I wanted to use the But libfoo is C, libbar Frobnicator framework, and it's I have a great idea is C++, and I want to only for Java. And Python is Our approach to cross-language for a new app! use Java! sloooow! interoperability involves compiling You should use libfoo Fine, then you'll need to write a multiple languages down to a shared and libbar! That will You should use Python, load of bridging code. It might be make it really easy! it has bindings to C simpler to just reimplement the binary representation. We currently and C++! bits of libfoo and libbar that you want to use in Java... compile dialects of Smalltalk and Efficient Interoperability JavaScript and an object-oriented parser generator down to the same object model as Objective-C. We can call C directly and use Objective-C as a hybrid language for more complex bridging. Objective-C effectively becomes a domain-specific language for calling C and C++ from high-level languages. The World We're Building: Okay. And I think I'll A single object may have methods I have a great idea use the Frobnicator for a new app! framework too. Why are you still implemented in different languages,. Oh, I finished here? Go and write already. your app. Good have fun! You should use libfoo and libbar! That will make it really easy! The 3 graphics editor uses C++ for high- Message Sending Speed ! 6 performance 3D modelling code the Smalltalk, Objective-C for model 5 descriptions, and Smalltalk for procedural 4 geometry generation and scripting. 3 Real-World Use Real-World 2 Normalised time 1 0 AverageInline Case CachedSpeculativeGCC Inlining RuntimeC++ (nonvirtual) C++Message (virtual)C (directSend call) The Objective-C implementation Part of this work has focussed on optimising developed as part of this work is dynamic languages. The biggest single used in a number of open source performance cost for dynamic languages is and commercial games and the cost of message sending (dynamic applications, with millions of installs, Fibonacci Benchmark Time method invocation). We have significantly including Android ports of iOS apps. 6 improved the performance of this, both in 5 the best and common cases. We added 4 inline caching and speculative inlining to the compiler and improved the lookup code 3 in the runtime, making our average case 2 Time in Seconds twice as fast as GCC and our best case faster 1 than a direct C call. 0 C Objective−CSmalltalk Smalltalk, Overflow−Safe We have shown that it's possible to use late- bound dynamic languages without Fast Implementation sacrificing performance and that mixing Hardware Assistance Memory Management Benchmark Results languages doesn't need to be slow or 12 difficult. Even though the implementation in 10 One unfortunate side effect of mixing languages is that your Smalltalk is noticeably slower than the C code is as safe as the least-safe language you use. This applies 8 version for the Fibonacci benchmark, it even when you use a JVM written in C++. We are currently 6 does have one advantage: it gives the correct answer for any input, whereas the C exploring sinking enforcement of high-level language isolation 4 properties (such as object encapsulation) into the hardware, with Normalised time version silently overflows... the CHERI CPU designed as part of the DARPA-funded CTSRD 2 project. We are already able to enforce object isolation in a 0 AutomaticManual Refcounts RefcountsGNUstep AppleManual Automatic RefcountsApple Manual Refcounts Refcounts dialect of C running on this CPU. This research is sponsored by the Defense Advanced Research Projects Agency (DARPA) and the Air Force Research Laboratory (AFRL), under contract FA8750-10-C-0237. The views, opinions, and/or findings contained in this article/presentation are those of the author/presenter and should not be interpreted as representing the official views or policies, either expressed or implied, of the Defense Advanced Research Projects Agency or the Department of Defense..
Recommended publications
  • The Future: the Story of Squeak, a Practical Smalltalk Written in Itself
    Back to the future: the story of Squeak, a practical Smalltalk written in itself Dan Ingalls, Ted Kaehler, John Maloney, Scott Wallace, and Alan Kay [Also published in OOPSLA ’97: Proc. of the 12th ACM SIGPLAN Conference on Object-oriented Programming, 1997, pp. 318-326.] VPRI Technical Report TR-1997-001 Viewpoints Research Institute, 1209 Grand Central Avenue, Glendale, CA 91201 t: (818) 332-3001 f: (818) 244-9761 Back to the Future The Story of Squeak, A Practical Smalltalk Written in Itself by Dan Ingalls Ted Kaehler John Maloney Scott Wallace Alan Kay at Apple Computer while doing this work, now at Walt Disney Imagineering 1401 Flower Street P.O. Box 25020 Glendale, CA 91221 [email protected] Abstract Squeak is an open, highly-portable Smalltalk implementation whose virtual machine is written entirely in Smalltalk, making it easy to debug, analyze, and change. To achieve practical performance, a translator produces an equivalent C program whose performance is comparable to commercial Smalltalks. Other noteworthy aspects of Squeak include: a compact object format that typically requires only a single word of overhead per object; a simple yet efficient incremental garbage collector for 32-bit direct pointers; efficient bulk- mutation of objects; extensions of BitBlt to handle color of any depth and anti-aliased image rotation and scaling; and real-time sound and music synthesis written entirely in Smalltalk. Overview Squeak is a modern implementation of Smalltalk-80 that is available for free via the Internet, at http://www.research.apple.com/research/proj/learning_concepts/squeak/ and other sites. It includes platform-independent support for color, sound, and image processing.
    [Show full text]
  • Smalltalk's Influence on Modern Programming
    1 Smalltalk’s Influence on Modern Programming Smalltalk’s Influence on Modern Programming Matt Savona. February 1 st , 2008. In September 1972 at Xerox PARC, Alan Kay, Ted Kaeher and Dan Ingalls were discussing programming languages in the hallway of their office building. Ted and Dan had begun to consider how large a language had to be to have “great power.” Alan took a different approach, and “asserted that you could define the "most powerful language in the world" in "a page of code."” Ted and Dan replied, “Put up or shut up” (Kay). And with that, the bet to develop the most powerful language was on. Alan arrived at PARC every morning at 4am for two weeks, and devoted his time from 4am to 8am to the development of the language. That language was Smalltalk. Kay had “originally made the boast because McCarthy's self-describing LISP interpreter was written in itself. It was about "a page", and as far as power goes, LISP was the whole nine- yards for functional languages.” He was sure that he could “do the same for object-oriented languages” and still have a reasonable syntax. By the eighth morning, Kay had a version of Smalltalk developed where “symbols were byte-coded and the receiving of return-values from a send was symmetric” (Kay). Several days later, Dan Ingalls had coded Kay’s scheme in BASIC, added a “token scanner”, “list maker” and many other features. “Over the next ten years he made at least 80 major releases of various flavors of Smalltalk” (Kay).
    [Show full text]
  • Smalltalk Language Mapping Specification
    Smalltalk Language Mapping Specification New Edition: June 1999 Copyright 1995, 1996 BNR Europe Ltd. Copyright 1998, Borland International Copyright 1991, 1992, 1995, 1996 Digital Equipment Corporation Copyright 1995, 1996 Expersoft Corporation Copyright 1996, 1997 FUJITSU LIMITED Copyright 1996 Genesis Development Corporation Copyright 1989, 1990, 1991, 1992, 1995, 1996 Hewlett-Packard Company Copyright 1991, 1992, 1995, 1996 HyperDesk Corporation Copyright 1998 Inprise Corporation Copyright 1996, 1997 International Business Machines Corporation Copyright 1995, 1996 ICL, plc Copyright 1995, 1996 IONA Technologies, Ltd. Copyright 1996, 1997 Micro Focus Limited Copyright 1991, 1992, 1995, 1996 NCR Corporation Copyright 1995, 1996 Novell USG Copyright 1991,1992, 1995, 1996 by Object Design, Inc. Copyright 1991, 1992, 1995, 1996 Object Management Group, Inc. Copyright 1996 Siemens Nixdorf Informationssysteme AG Copyright 1991, 1992, 1995, 1996 Sun Microsystems, Inc. Copyright 1995, 1996 SunSoft, Inc. Copyright 1996 Sybase, Inc. Copyright 1998 Telefónica Investigación y Desarrollo S.A. Unipersonal Copyright 1996 Visual Edge Software, Ltd. The companies listed above have granted to the Object Management Group, Inc. (OMG) a nonexclusive, royalty-free, paid up, worldwide license to copy and distribute this document and to modify this document and distribute copies of the modified ver- sion. Each of the copyright holders listed above has agreed that no person shall be deemed to have infringed the copyright in the included material of any such copyright holder by reason of having used the specification set forth herein or having con- formed any computer software to the specification. PATENT The attention of adopters is directed to the possibility that compliance with or adoption of OMG specifications may require use of an invention covered by patent rights.
    [Show full text]
  • Dynamic Object-Oriented Programming with Smalltalk
    Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Autumn Semester 2009 LECTURE TITLE What is surprising about Smalltalk > Everything is an object > Everything happens by sending messages > All the source code is there all the time > You can't lose code > You can change everything > You can change things without restarting the system > The Debugger is your Friend © Oscar Nierstrasz 2 ST — Introduction Why Smalltalk? > Pure object-oriented language and environment — “Everything is an object” > Origin of many innovations in OO development — RDD, IDE, MVC, XUnit … > Improves on many of its successors — Fully interactive and dynamic © Oscar Nierstrasz 1.3 ST — Introduction What is Smalltalk? > Pure OO language — Single inheritance — Dynamically typed > Language and environment — Guiding principle: “Everything is an Object” — Class browser, debugger, inspector, … — Mature class library and tools > Virtual machine — Objects exist in a persistent image [+ changes] — Incremental compilation © Oscar Nierstrasz 1.4 ST — Introduction Smalltalk vs. C++ vs. Java Smalltalk C++ Java Object model Pure Hybrid Hybrid Garbage collection Automatic Manual Automatic Inheritance Single Multiple Single Types Dynamic Static Static Reflection Fully reflective Introspection Introspection Semaphores, Some libraries Monitors Concurrency Monitors Categories, Namespaces Packages Modules namespaces © Oscar Nierstrasz 1.5 ST — Introduction Smalltalk: a State of Mind > Small and uniform language — Syntax fits on one sheet of paper >
    [Show full text]
  • Smalltalk Reading List
    Smalltalkreading list Smalltalk introduced the world to Object Much of the genesis of Smalltalk is explained Smalltalk was created over the course of a For the history in Silicon Valley leading up to Oriented programming, a way of representing in Alan Kay’s Personal Computer for Children decade starting in 1970 at Xerox’s Palo Alto the inspiration and creation of Smalltalk, see software as a network of interconnected and of All Ages wherein he describes the Research Center (better known as Xerox PARC) John Markoff’s What the Dormouse Said. intercommunicating little computers. It has Dynabook computer. The Dynabook was to be by the company’s Learning Research Group. influenced nearly every programming a personal dynamic computer, with a flat language since, including Objective C, Java, screen and a keyboard (today’s iPads bear a When people think about Smalltalk as a and Swift. striking resemblance). professional programming language it’s almost always Smalltalk-80 (released in This reading list contains books, essays, and The Dynabook’s system software was 1980) they’re thinking about, but in fact videos detailing the time and place from intended to be built and modified by anyone, Smalltalk had dozens of versions and which Smalltalk emerged, the mindsets and for books and music, but more importantly for revisions in the preceding decade. visions of its creators, and the influences understanding complex systems. Smalltalk has had on computer systems and Smalltalk was originally intended as a their programming languages. The Smalltalk software and hardware that medium of expression, and not as a For the history of Xerox PARC in the decade came out of Xerox PARC were in direct pursuit professional developer tool until much later.
    [Show full text]
  • How to Identify Class Comment Types? a Multi-Language Approach for Class Comment Classification
    How to Identify Class Comment Types? A Multi-language Approach for Class Comment Classification Pooja Rania, Sebastiano Panichellab, Manuel Leuenbergera, Andrea Di Sorboc, Oscar Nierstrasza aSoftware Composition Group, University of Bern, Switzerland bZurich University of Applied Science, Switzerland cDepartment of Engineering, University of Sannio, Italy Abstract Most software maintenance and evolution tasks require developers to understand the source code of their software systems. Software developers usually inspect class comments to gain knowledge about program behavior, regardless of the programming language they are using. Unfortunately, (i) different programming languages present language-specific code commenting notations and guidelines; and (ii) the source code of software projects often lacks comments that adequately describe the class behavior, which complicates program comprehension and evolution activities. To handle these challenges, this paper investigates the different language-specific class commenting practices of three program- ming languages: Python, Java, and Smalltalk. In particular, we systematically analyze the similarities and differences of the information types found in class comments of projects developed in these languages. We propose an approach that leverages two techniques — namely Natural Language Processing and Text Analysis — to auto- matically identify class comment types, i.e., the specific types of semantic information found in class comments. To the best of our knowledge, no previous work has provided a comprehensive taxonomy of class comment types for these three programming languages with the help of a common automated approach. Our results confirm that our approach can classify frequent class com- ment information types with high accuracy for the Python, Java, and Smalltalk programming languages. We believe this work can help in monitoring and assessing the quality and evolution of code comments in different programming languages, and thus support maintenance and evolution tasks.
    [Show full text]
  • Objective-C 2.0 Essentials Third Edition
    Objective-C 2.0 Essentials Third Edition i Objective-C 2.0 Essentials – Third Edition ISBN-13: 978-1480262102 © 2012 Neil Smyth. This book is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights reserved. The content of this book is provided for informational purposes only. Neither the publisher nor the author offers any warranties or representation, express or implied, with regard to the accuracy of information contained in this book, nor do they accept any liability for any loss or damage arising from any errors or omissions. This book contains trademarked terms that are used solely for editorial purposes and to the benefit of the respective trademark owner. The terms used within this book are not intended as infringement of any trademarks. Find more eBooks online at http://www.eBookFrenzy.com. Rev. 3.0 ii Table of Contents 1. About Objective-C Essentials ...................................................................................................... 1 1.1 Why are you reading this? .................................................................................................... 1 1.2 Supported Platforms ............................................................................................................. 2 2. The History of Objective-C .......................................................................................................... 3 2.1 The C Programming Language .............................................................................................
    [Show full text]
  • How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time an Experience Report of Using the Rpython Toolchain
    RSqueak on IWST 2016 How to Build a High-Performance VM for Squeak/Smalltalk in Your Spare Time An Experience Report of Using the RPython Toolchain Tim Felgentreff Tobias Pape Patrick Rein Robert Hirschfeld Hasso Plattner Institute {firstname.lastname}@hpi.de Abstract In this report we share our development experience In this paper we present our experience in letting students with RSqueak/VM. In particular, we believe that the way develop RSqueak/VM, a fast virtual machine for executing RSqueak/VM is implemented makes it possible to achieve Squeak/Smalltalk, over the course of multiple introductory good performance even though development almost exclu- VM courses and projects. Our experience indicates that the sively takes place during part-time student projects and in way RSqueak/VM is constructed makes it easy for develop- introductory VM courses. Furthermore, most of the students VM ers with little or no prior exposure to VM development to that develop RSqueak/VM have never taken courses be- construct a Squeak runtime that is very nearly competitive fore, have no prior experience with Squeak VM development, to the professional grade Cog VM, which is used by Squeak and have little knowledge of Squeak internals besides using and other flavors of Smalltalk. In this experience report we the Squeak development tools. We see this in contrast to discuss the benefits and drawbacks of RSqueak/VM as a re- the Cog VM that is being developed by full-time developers search vehicle for developing and evaluating Smalltalk lan- and that requires a good knowledge of the Squeak object guage extensions without having to learn the deep secrets of format, its garbage collector, its meta-programming facilities, VM development.
    [Show full text]
  • Smalltalk-Style Development for Python and Ruby
    When a Mouse Eats a Python Smalltalk-style Runtime Development for Python and Ruby Tim Felgentreff Fabio Niephaus Tobias Pape Robert Hirschfeld Hasso Plattner Institute, University of Potsdam Potsdam, Germany ffi[email protected] 1. Debug Mode is the Only Mode general fashion for Smalltalk-style development, as well as Debuggers in interactive programming environments are pow- the practical overhead of such an integration. erful tools to explore and develop systems at runtime. The core features of our prototype are: However, among users of scripting languages such as • A combination of multiple RPython interpreters in the Python or Ruby, a debugger is sometimes viewed as a rarely same, cooperatively scheduled execution environment, used “development time” tool. As Seaton, Van De Vanter, and • Smalltalk-style unhandled exception and edit-and-continue Haupt have observed [5], debugging support is assumed to debugging for Ruby and Python. come with compromises: there surely must be a performance impact; in order to minimize the impact when debugging is 2. Implementation Sketch not needed, the functionality surely must be limited; the com- plexity of debugging couples debuggers closely to just one Our implementation is based on the approach to interpreter language; and in order to actually use debugging facilities, composition in RPython proposed by Barrett, Bolz, and one surely must accept the inconvenience of having to run Tratt [2]. Since we use RPython as our implementation the program in a special “debug” mode. language, we can use its meta-programming and object- Due to the inconvenience involved in using debuggers in oriented model to generically adapt the different interpreters.
    [Show full text]
  • Introduction to Perl Programming
    Introduction to Perl Programming Presentation for LX865 Gregory Garretson December 6, 2004 Originally a presentation for the Perl Learning Group (CL@BU: clabu.bu.edu) Overview I. A few introductory notes II. About Perl and programming III. Perl basics IV. Variables V. Conditionals and loops VI. Exercises VII. More stuff Introduction to Perl Programming (presentation by Gregory Garretson, 12-06-04) Slide 2 I. A few introductory notes Introduction to Perl Programming (presentation by Gregory Garretson, 12-06-04) Slide 3 Caveats ● I'm a linguist. I have no formal background in computer science. If you have difficult questions about computer science, ask Paul. ● I do know how to program quite well in Perl, but I am not an expert. There are many, many things you can do with Perl, and I have learned only a small subset of these. ● Having said that, feel free to ask me things if you think I can help with your exercises. Introduction to Perl Programming (presentation by Gregory Garretson, 12-06-04) Slide 4 Nomenclature ● Here are some terms that are used pretty much interchangeably in this presentation. Don't let this confuse you. ● script = program ● coding = programming ● execute = run ● evaluate = test Introduction to Perl Programming (presentation by Gregory Garretson, 12-06-04) Slide 5 Formatting ● Normal expository text is in this font. ● Text that represents what you type is shown like so: perl myprogram.pl ● Text that represents computer output on the screen is shown like so: File not found. C:\> ● Things written in angle brackets should be replaced with the appropriate text: perl <your program> -w Introduction to Perl Programming (presentation by Gregory Garretson, 12-06-04) Slide 6 II.
    [Show full text]
  • Comparing LISP and Object-Oriented Programming Languages
    Wang 1 Pengfei Wang Professor Christopher A. Healy Computer Science 475 11 April 2016 Compare LISP with Object-Oriented Programming Languages Introduction LISP, which stands for List Processor, is a family of functional programming languages, invented by John McCarthy in MIT based on Lambda Calculus in 1958. It is the second-oldest high-level programming language and it was originally designed for Artificial Intelligence, but it is a good general-purpose language as well. This paper is going to discuss the differences between LISP and Object-Oriented Languages, focusing mainly on LISP. This paper is going to firstly introduce functional programming language and LISP. Then, advantages and disadvantages of LISP comparing to object-oriented languages will be discussed, and finally a specific case study will be done. Functional Programming Languages and List Processor Typically, programming languages are divided into two general types, imperative languages and declarative languages. The computer program written in imperative languages consists of statements, instructions, which indicate how (and in what order) a computation should be done. Imperative languages include all of the object-oriented languages. On the other hand, declarative languages define functions, formulas or relationships. Declarative languages do not specify how the functions are performed step-by-step in program. Functional Wang 2 programming language is one type of the declarative languages. ;; Example: Written in Common LISP (format t “Result: ~A.~%” (* 2 (+ 2 3))) ; functions /* Example: Written in C*/ int a = 2 + 3; /*statement*/ int b = a * 2; /*statement*/ printf("Result: %d.\n", b); /*statement*/ Function languages employ a computational model based on the recursive definition of functions.
    [Show full text]
  • Object-Oriented Programming Lisp Flavors and Their Application to a Fire Effects Information System
    University of Montana ScholarWorks at University of Montana Graduate Student Theses, Dissertations, & Professional Papers Graduate School 1986 Object-oriented programming Lisp Flavors and their application to a fire effects information system James A. Mitchell The University of Montana Follow this and additional works at: https://scholarworks.umt.edu/etd Let us know how access to this document benefits ou.y Recommended Citation Mitchell, James A., "Object-oriented programming Lisp Flavors and their application to a fire effects information system" (1986). Graduate Student Theses, Dissertations, & Professional Papers. 5113. https://scholarworks.umt.edu/etd/5113 This Thesis is brought to you for free and open access by the Graduate School at ScholarWorks at University of Montana. It has been accepted for inclusion in Graduate Student Theses, Dissertations, & Professional Papers by an authorized administrator of ScholarWorks at University of Montana. For more information, please contact [email protected]. COPYRIGHT ACT OF 1976 T h i s i s a n unpublished m a n u s c r ip t i n w h ic h c o p y r ig h t s u b ­ s i s t s . A n y f u r t h e r r e p r i n t i n g o f i t s c o n t e n t s m u s t b e a p p r o v e d BY THE AUTHOR. Ma n s f i e l d L ib r a r y U n i v e r s i t y o f Mo n t a n a D a t e : 1 9 S 8 ________ Object-Oriented Programming, Lisp Flavors and Their Application to a Fire Effects Information System by James A.
    [Show full text]