Mastering Python High Performance

Total Page:16

File Type:pdf, Size:1020Kb

Mastering Python High Performance [ 1 ] www.allitebooks.com Mastering Python High Performance Measure, optimize, and improve the performance of your Python code with this easy-to-follow guide Fernando Doglio BIRMINGHAM - MUMBAI www.allitebooks.com Mastering Python High Performance Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: September 2015 Production reference: 1030915 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78398-930-0 www.packtpub.com www.allitebooks.com Credits Author Project Coordinator Fernando Doglio Milton Dsouza Reviewers Proofreader Erik Allik Safis Editing Mike Driscoll Enrique Escribano Indexer Mariammal Chettiyar Mosudi Isiaka Graphics Commissioning Editor Sheetal Aute Kunal Parikh Production Coordinator Acquisition Editors Arvindkumar Gupta Vivek Anantharaman Richard Brookes-Bland Cover Work Arvindkumar Gupta Content Development Editors Akashdeep Kundu Rashmi Suvarna Technical Editor Vijin Boricha Copy Editors Relin Hedly Karuna Narayanan www.allitebooks.com About the Author Fernando Doglio has been working as a web developer for the past 10 years. During that time, he shifted his focus to the Web and grabbed the opportunity of working with most of the leading technologies, such as PHP, Ruby on Rails, MySQL, Python, Node.js, AngularJS, AJAX, REST APIs, and so on. In his spare time, Fernando likes to tinker and learn new things. This is why his GitHub account keeps getting new repos every month. He's also a big open source supporter and tries to win the support of new people with the help of his website, lookingforpullrequests.com. You can reach him on Twitter at @deleteman123. When he is not programming, he spends time with his family. I'd like to thank my lovely wife for putting up with me and the long hours I spent writing this book; this book would not have been possible without her continued support. I would also like to thank my two sons. Without them, this book would've been finished months earlier. Finally, I'd like to thank the reviewers and editors. They helped me get this book in shape and achieve the quality level that you deserve. www.allitebooks.com About the Reviewers Erik Allik is a self-taught multilingual, multiparadigm full-stack software engineer. He started programming at the age of 14. Since then, Erik has been working with many programming languages (both imperative and functional) and various web and non-web-related technologies. He has worked primarily with Python, Scala, and JavaScript. Erik is currently focusing on applying Haskell and other innovative functional programming techniques in various industries and leveraging the power of a mathematical approach and formalism in the wild. www.allitebooks.com Mike Driscoll has been programming in Python since 2006. He enjoys writing about Python on his blog at http://www.blog.pythonlibrary.org/. Mike has coauthored Core Python refcard for DZone. He recently authored Python 101 and was a technical reviewer for the following books by Packt Publishing: • Python 3 Object-Oriented Programming • Python 2.6 Graphics Cookbook • Tkinter GUI Application Development Hotshot I would like to thank my beautiful wife, Evangeline, for supporting me throughout. I would also like to thank my friends and family for all their help. Also, thank you Jesus Christ for taking good care of me. www.allitebooks.com Enrique Escribano lives in Chicago and is working as a software engineer at Nokia. Although he is just 23 years old, he holds a master's of computer science degree from IIT (Chicago) and a master's of science degree in telecommunication engineering from ETSIT-UPM (Madrid). Enrique has also worked as a software engineer at KeepCoding and as a developer intern at Telefonica, SA, the most important Spanish tech company. He is an expert in Java and Python and is proficient in using C/C++. Most of his projects involve working with cloud-based technologies, such as AWS, GAE, Hadoop, and so on. Enrique is also working on an open source research project based on security with software-defined networking (SDN) with professor Dong Jin at IIT Security Lab. You can find more information about Enrique on his personal website at enriquescribano.com. You can also reach him on LinkedIn at linkedin.com/in/enriqueescribano. I would like to thank my parents, Lucio and Carmen, for all the unconditional support they have provided me with over the years. They allowed me to be as ambitious as I wanted. Without them, I may never have gotten to where I am today. I would like to thank my siblings, Francisco and Marta. Being the eldest brother is challenging, but you both keep inspiring me everyday. Lastly, I would also like to thank Paula for always being my main inspiration and motivation since the very first day. I am so fortunate to have her in my life. www.allitebooks.com Mosudi Isiaka is a graduate in electrical and computer engineering from the Federal University of Technology Minna, Niger State, Nigeria. He demonstrates excellent skills in numerous aspects of information and communication technology. From a simple network to a mid-level complex network scenario of no less than one thousand workstations (Microsoft Windows 7, Microsoft Windows Vista, and Microsoft Windows XP), along with a Microsoft Windows 2008 Server R2 Active Directory domain controller deployed in more than a single location, Mosudi has extensive experience in implementing and managing a local area network. He has successfully set up a data center infrastructure, VPN, WAN link optimization, firewall and intrusion detection system, web/e-mail hosting control panel, OpenNMS network management application, and so on. Mosudi has the ability to use open source software and applications to achieve enterprise-level network management solutions in scenarios that cover a virtual private network (VPN), IP PBX, cloud computing, clustering, virtualization, routing, high availability, customized firewall with advanced web filtering, network load balancing, failover and link aggregation for multiple Internet access solutions, traffic engineering, collaboration suits, network-attached storage (NAS), Linux systems administration, virtual networking and computing. He is currently employed as a data center manager at One Network Ltd., Nigeria. Mosudi also works with ServerAfrica(http://www.serverafrica.com) as a managing consultant (technicals). You can find more information about him at http://www.mioemi.com. You can also reach him at http://ng.linkedin.com/pub/isiaka-mosudi/1b/7a2/936/. I would like to thank my amiable wife, Mosudi Efundayo Coker, for her moral support. Also, many thanks to my colleague, Oyebode Micheal Tosin, for his timely reminders and technical suggestions during the reviewing process. www.allitebooks.com www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books. Why subscribe? • Fully searchable across every book published by Packt • Copy and paste, print, and bookmark content • On demand and accessible via a web browser Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access. www.allitebooks.com Table of Contents Preface v Chapter 1: Profiling 101 1 What is profiling? 2 Event-based profiling 2 Statistical profiling 5 The importance of profiling 6 What can we profile? 8 Execution time 8 Where are the bottlenecks? 10 Memory consumption and memory leaks 11 The risk of premature optimization 15 Running time complexity 15 Constant time – O(1) 16 Linear time – O(n) 16 Logarithmic time – O(log n) 17 Linearithmic time – O(nlog n) 18 Factorial time – O(n!) 18 Quadratic time – O(n^) 19 Profiling best practices 22 Build a regression-test suite 22 Mind your code 22 Be patient 22 Gather as much data as you can 23 Preprocess
Recommended publications
  • Avaliação De Performance De Interpretadores Ruby
    Universidade Federal de Santa Catarina Centro Tecnológico Curso de Sistemas de Informação Wilson de Almeida Avaliação de Performance de Interpretadores Ruby Florianópolis 2010 Wilson de Almeida Avaliação de Performance de Interpretadores Ruby Monograa apresentada ao Curso de Sistemas de Informação da UFSC, como requisito para a obten- ção parcial do grau de BACHAREL em Sistemas de Informação. Orientador: Lúcia Helena Martins Pacheco Doutora em Engenharia Florianópolis 2010 Almeida, Wilson Avaliação de Performance de Interpretadores Ruby / Wilson Al- meida - 2010 xx.p 1.Performance 2. Interpretadores.. I.Título. CDU 536.21 Wilson de Almeida Avaliação de Performance de Interpretadores Ruby Monograa apresentada ao Curso de Sistemas de Informação da UFSC, como requisito para a obten- ção parcial do grau de BACHAREL em Sistemas de Informação. Aprovado em 21 de junho de 2010 BANCA EXAMINADORA Lúcia Helena Martins Pacheco Doutora em Engenharia José Eduardo De Lucca Mestre em Ciências da Computação Eduardo Bellani Bacharel em Sistemas de Informação Aos meus pais e meu irmão. Aos familiares e amigos, em especial pra mi- nha eterna amiga Liliana, que está torcendo por mim de onde ela estiver. Agradecimentos Agradeço ao meu amigo, colega de curso, parceiro de trabalhos e orientador Eduardo Bellani, pelo encorajamento, apoio e seus ricos conselhos sobre o melhor direci- onamento deste trabalho. A professora Lúcia Helena Martins Pacheco pela orientação, amizade, e pela paciência, sem a qual este trabalho não se realizaria. Ao professor José Eduardo Delucca, por seus conselhos objetivos e pontuais. Todos os meus amigos que incentivaram e compreenderam a minha ausência nesse período de corrida atrás do objetivo de concluir o curso.
    [Show full text]
  • Aplikacija Za Pregled Tehnologij Spletnih Projektov Na Podlagi Avtomatske Analize Repozitorijev
    Univerza v Ljubljani Fakulteta za računalništvo in informatiko Aljana Polanc Aplikacija za pregled tehnologij spletnih projektov na podlagi avtomatske analize repozitorijev DIPLOMSKO DELO VISOKOŠOLSKI STROKOVNI ŠTUDIJSKI PROGRAM PRVE STOPNJE RAČUNALNIŠTVO IN INFORMATIKA Mentor: doc. dr. Aleš Smrdel Ljubljana, 2016 Rezultati diplomskega dela so intelektualna lastnina avtorja in Fakultete za računalništvo in informatiko Univerze v Ljubljani. Za objavljanje ali iz- koriščanje rezultatov diplomskega dela je potrebno pisno soglasje avtorja, Fakultete za računalništvo in informatiko ter mentorja. Besedilo je oblikovano z urejevalnikom besedil LATEX. Fakulteta za računalništvo in informatiko izdaja naslednjo nalogo: Tematika naloge: V okviru diplomskega dela razvijte aplikacijo, ki bo služila za vzdrževanje ažurne evidence o tehnologijah pri različnih spletnih projektih. Aplikacija mora omogočiti avtomatsko periodično pregledovanje vseh aktivnih projek- tov znotraj nekega podjetja in posodabljanje podatkov o uporabljenih teh- nologijah za vsakega izmed projektov. V ta namen najprej analizirajte teh- nologije, ki se uporabljajo pri izdelavi sodobnih spletnih projektov, nato pa realizirajte aplikacijo, ki se mora biti sposobna povezati z repozitorijem pro- jektov, prebrati vse projekte in na podlagi analize datotek projektov razbrati tehnologije, ki so uporabljene pri posameznem projektu. Za vsak projekt mora aplikacija razbrati uporabljene programske jezike, orodja, knjižnice ter razvijalce, ki sodelujejo pri posameznem projektu. Razvijte tudi spletni vme- snik, ki bo omogočal prikaz podatkov o projektih in tehnologijah znotraj ne- kega podjetja ter nadroben prikaz tehnologij uporabljenih pri posameznem projektu. Razvijte tudi administrativni spletni vmesnik, ki bo omogočal do- polnjevanje in popravljanje avtomatsko pridobljenih podatkov. Pri razvoju aplikacije izberite najprimernejše tehnologije na strani odjemalca in na strani strežnika. Uspešnost delovanja razvite aplikacije testirajte na nekem repozi- toriju projektov.
    [Show full text]
  • Supporting C Extensions for Dynamic Languages an Abbreviated Version of [10]
    High-Performance Language Composition: Supporting C Extensions for Dynamic Languages An abbreviated version of [10]. Grimmer Matthias1, Chris Seaton2, Thomas W¨urthinger2 and Hanspeter M¨ossenb¨ock1 1 Johannes Kepler University, Linz, Austria fgrimmer,[email protected] 2 Oracle Labs fchris.seaton,[email protected] Abstract. Many dynamic languages such as Ruby offer functionality for writing parts of applications in a lower-level language such as C. These C extension modules are usually written against the API of an interpreter, which provides access to the higher-level language's internal data struc- tures. Alternative implementations of the high-level languages often do not support such C extensions because implementing the same API as in the original implementations is complicated and limits performance. In this paper we describe a novel approach for modular composition of languages that allows dynamic languages to support C extensions through interpretation. We propose a flexible and reusable cross-language mechanism that allows composing multiple language interpreters. This mechanism allows us to efficiently exchange runtime data across different interpreters and also enables the dynamic compiler of the host VM to inline and optimize programs across multiple language boundaries. We evaluate our approach by composing a Ruby interpreter with a C interpreter. We run existing Ruby C extensions and show how our system executes combined Ruby and C modules on average over 3× faster than the conventional implementation of Ruby with native C extensions. 1 Introduction Most programming languages offer functionality for calling routines in modules that are written in another language. There are multiple reasons why program- mers want to do this, including to run modules already written in another lan- guage, to achieve higher performance than is normally possible in the primary language, or generally to allow different parts of the system to be written in the most appropriate language.
    [Show full text]
  • Specialising Dynamic Techniques for Implementing the Ruby Programming Language
    SPECIALISING DYNAMIC TECHNIQUES FOR IMPLEMENTING THE RUBY PROGRAMMING LANGUAGE A thesis submitted to the University of Manchester for the degree of Doctor of Philosophy in the Faculty of Engineering and Physical Sciences 2015 By Chris Seaton School of Computer Science This published copy of the thesis contains a couple of minor typographical corrections from the version deposited in the University of Manchester Library. [email protected] chrisseaton.com/phd 2 Contents List of Listings7 List of Tables9 List of Figures 11 Abstract 15 Declaration 17 Copyright 19 Acknowledgements 21 1 Introduction 23 1.1 Dynamic Programming Languages.................. 23 1.2 Idiomatic Ruby............................ 25 1.3 Research Questions.......................... 27 1.4 Implementation Work......................... 27 1.5 Contributions............................. 28 1.6 Publications.............................. 29 1.7 Thesis Structure............................ 31 2 Characteristics of Dynamic Languages 35 2.1 Ruby.................................. 35 2.2 Ruby on Rails............................. 36 2.3 Case Study: Idiomatic Ruby..................... 37 2.4 Summary............................... 49 3 3 Implementation of Dynamic Languages 51 3.1 Foundational Techniques....................... 51 3.2 Applied Techniques.......................... 59 3.3 Implementations of Ruby....................... 65 3.4 Parallelism and Concurrency..................... 72 3.5 Summary............................... 73 4 Evaluation Methodology 75 4.1 Evaluation Philosophy
    [Show full text]
  • Lightweight Method Dispatch On
    Lightweight Method Dispatch on MRI Koichi Sasada <[email protected]> EURUKO2015 Koichi Sasada A programmer from Japan Koichi is a Programmer •MRI committer since 2007/01 • Original YARV developer since 2004/01 • YARV: Yet Another RubyVM • Introduced into Ruby (MRI) 1.9.0 and later • Generational/incremental GC for 2.x “Why I wouldn’t use rails for a new company” by Jared Friedman “The ruby interpreter is just a volunteer effort. Between 2007- 2012, there were a number of efforts to fix the interpreter and make it fast (Rubinius, Jruby, YARV, etc) But lacking backers with staying power, the volunteers got bored and some of the efforts withered. JRuby is still active and recent versions are showing more promise with performance, but it’s been a long road.” Quoted from http://blog.jaredfriedman.com/2015/09/15/why-i- wouldnt-use-rails-for-a-new-company/ (September 15, 2015) Koichi is an Employee Koichi is a member of Heroku Matz team Mission Design Ruby language and improve quality of MRI Heroku employs three full time Ruby core developers in Japan named “Matz team” Heroku Matz team Matz Designer/director of Ruby Nobu Quite active committer Ko1 Internal Hacker Matz Title collector • He has so many (job) title • Japanese teacher • Chairman - Ruby Association • Fellow - NaCl • Chief architect, Ruby - Heroku • Research institute fellow – Rakuten • Chairman – NPO mruby Forum • Senior researcher – Kadokawa Ascii Research Lab • Visiting professor – Shimane University • Honorable citizen (living) – Matsue city • Honorable member – Nihon Ruby no Kai
    [Show full text]
  • Load Testing of Containerised Web Services
    UPTEC IT 16003 Examensarbete 30 hp Mars 2016 Load Testing of Containerised Web Services Christoffer Hamberg Abstract Load Testing of Containerised Web Services Christoffer Hamberg Teknisk- naturvetenskaplig fakultet UTH-enheten Load testing web services requires a great deal of environment configuration and setup. Besöksadress: This is especially apparent in an environment Ångströmlaboratoriet Lägerhyddsvägen 1 where virtualisation by containerisation is Hus 4, Plan 0 used with many moving and volatile parts. However, containerisation tools like Docker Postadress: offer several properties, such as; application Box 536 751 21 Uppsala image creation and distribution, network interconnectivity and application isolation that Telefon: could be used to support the load testing 018 – 471 30 03 process. Telefax: 018 – 471 30 00 In this thesis, a tool named Bencher, which goal is to aid the process of load testing Hemsida: containerised (with Docker) HTTP services, is http://www.teknat.uu.se/student designed and implemented. To reach its goal Bencher automates some of the tedious steps of load testing, including connecting and scaling containers, collecting system metrics and load testing results to name a few. Bencher’s usability is verified by testing a number of hypotheses formed around different architecture characteristics of web servers in the programming language Ruby. With a minimal environment setup cost and a rapid test iteration process, Bencher proved its usability by being successfully used to verify the hypotheses in this thesis. However, there is still need for future work and improvements, including for example functionality for measuring network bandwidth and latency, that could be added to enhance process even further. To conclude, Bencher fulfilled its goal and scope that were set for it in this thesis.
    [Show full text]
  • Inter-Language Collaboration in an Object-Oriented Virtual Machine Bachelor’S Thesis
    Inter-language Collaboration in an Object-oriented Virtual Machine Bachelor’s Thesis MATTHIAS SPRINGER, Hasso Plattner Institute, University of Potsdam TIM FELGENTREFF, Hasso Plattner Institute, University of Potsdam (Supervisor) TOBIAS PAPE, Hasso Plattner Institute, University of Potsdam (Supervisor) ROBERT HIRSCHFELD, Hasso Plattner Institute, University of Potsdam (Supervisor) Multi-language virtual machines have a number of advantages. They allow software developers to use soft- ware libraries that were written for different programming languages. Furthermore, language implementors do not have to bother with low-level VM functionality and their implementation can benefit from optimiza- tions in existing virtual machines. MagLev is an implementation of the Ruby programming language on top of the GemStone/S virtual machine for the Smalltalk programming language. In this work, we present how software components written in both languages can interact. We show how MagLev unifies the Smalltalk and the Ruby object model, taking into account Smalltalk meta classes, Ruby singleton classes, and Ruby modules. Besides, we show how we can call Ruby methods from Smalltalk and vice versa. We also present MagLev’s concept of bridge methods for implementing Ruby method calling conventions. Finally, we compare our solution to other language implementations and virtual machines. Additional Key Words and Phrases: Virtual Machines, Ruby, Smalltalk, MagLev, Language Implementation 1. MULTI-LANGUAGE VIRTUAL MACHINES Multi-language virtual machines are virtual machines that support the execution of source code written in multiple languages. According to Vraný [Vraný 2010], we have to distinguish multi-lanuguage virtual machines from interpreters and native code execution. Languages inside multi-language virtual machines are usually compiled to byte code and share the same object space.
    [Show full text]
  • Ruby Programming
    Ruby Programming Wikibooks.org December 1, 2012 On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects were licensed under Creative Commons Attribution-ShareAlike 3.0 Unported license. An URI to this license is given in the list of figures on page 249. If this document is a derived work from the contents of one of these projects and the content was still licensed by the project under this license at the time of derivation this document has to be licensed under the same, a similar or a compatible license, as stated in section 4b of the license. The list of contributors is included in chapter Contributors on page 243. The licenses GPL, LGPL and GFDL are included in chapter Licenses on page 253, since this book and/or parts of it may or may not be licensed under one or more of these licenses, and thus require inclusion of these licenses. The licenses of the figures are given in the list of figures on page 249. This PDF was generated by the LATEX typesetting software. The LATEX source code is included as an attachment (source.7z.txt) in this PDF file. To extract the source from the PDF file, we recommend the use of http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ utility or clicking the paper clip attachment symbol on the lower left of your PDF Viewer, selecting Save Attachment. After extracting it from the PDF file you have to rename it to source.7z. To uncompress the resulting archive we recommend the use of http://www.7-zip.org/.
    [Show full text]
  • Fine Articles on Ruby & Rails
    Rails Magazine MyMagazineIssue 1, Julyfine 2008 articles on Ruby & Rails Extending Rails Through Plugins by John Yerhot Receiving E-Mail With Rails by Jason Seifer Delegation in Ruby by Khaled al Habache Subscription billing with Saasy by Alex MacCaw Making the Switch From RSpec to Shoulda by Dan Pickett Playing Hooky a.k.a. web hooks by John Nunemaker Adhearsion by Jason Goecke & Jay Phillips Rails Performance Analysis by Terry Heath Getting Started with JRuby and JRuby on Rails by Joshua Moore 1 ISSN 1916-8004 http://RailsMagazine.com Editorial2 by Olimpiu Metiu Editorial Contents by Olimpiu Metiu Welcome to the first edition of Rails Magazine, the first and Editorial ...........................................................................2 only free magazine dedicated to the Ruby on Rails community! by Olimpiu Metiu If you are interested in a quality compilation of timely, relevant articles, with editorial oversight and beautiful layout, Extending Rails Through Plugins .................................3 please check out the magazine regularly or subscribe online. by John Yerhot Long before launch, I was impressed with the level of interest and receptiveness. Rails always had a vibrant and dedicated com- Receiving E-Mail With Rails .........................................4 munity, and I hope Rails Magazine will become an appreciated by Jason Seifer resource for those looking for quality information — at the same time providing global exposure to those interested in getting Delegation in Ruby .........................................................8 published. by Khaled al Habache Subscription billing with Saasy ...................................13 Olimpiu Metiu is a Toronto-based architect and by Alex MacCaw the leader of the Emergent Technologies group at Bell Canada. His work includes many of Canada's Making the Switch From RSpec to Shoulda ..............16 largest web sites and intranet portals.
    [Show full text]
  • Squimera : a Live, Smalltalk-Based IDE for Dynamic Programming Languages
    Squimera: A live, Smalltalk- based IDE for dynamic programming languages Fabio Niephaus, Tim Felgentreff, Robert Hirschfeld Technische Berichte Nr. 120 des Hasso-Plattner-Instituts für Digital Engineering an der Universität Potsdam ISBN 978-3-86956-422-7 ISSN 1613-5652 Technische Berichte des Hasso-Plattner-Instituts für Digital Engineering an der Universität Potsdam Technische Berichte des Hasso-Plattner-Instituts für Digital Engineering an der Universität Potsdam | 120 Fabio Niephaus | Tim Felgentreff | Robert Hirschfeld Squimera A live, Smalltalk-based IDE for dynamic programming languages Universitätsverlag Potsdam Bibliografische Information der Deutschen Nationalbibliothek Die Deutsche Nationalbibliothek verzeichnet diese Publikation in der Deutschen Nationalbibliografie; detaillierte bibliografische Daten sind im Internet über http://dnb.dnb.de/ abrufbar. Universitätsverlag Potsdam 2018 http://verlag.ub.uni-potsdam.de/ Am Neuen Palais 10, 14469 Potsdam Tel.: +49 (0)331 977 2533 / Fax: 2292 E-Mail: [email protected] Die Schriftenreihe Technische Berichte des Hasso-Plattner-Instituts für Digital Engineering an der Universität Potsdam wird herausgegeben von den Professoren des Hasso-Plattner-Instituts für Digital Engineering an der Universität Potsdam. ISSN (print) 1613-5652 ISSN (online) 2191-1665 Das Manuskript ist urheberrechtlich geschützt. Online veröffentlicht auf dem Publikationsserver der Universität Potsdam URN urn:nbn:de:kobv:517-opus4-403387 http://nbn-resolving.de/urn:nbn:de:kobv:517-opus4-403387 Zugleich gedruckt erschienen im Universitätsverlag Potsdam: ISBN 978-3-86956-422-7 Abstract Software development tools that work and behave consistently across different programming languages are helpful for developers, because they do not have to familiarize themselves with new tooling whenever they decide to use a new lan- guage.
    [Show full text]
  • Object Persistence with Ruby and Smalltalk BP2012H1
    Object Persistence with Ruby and Smalltalk BP2012H1 MagLev – Object Persistence with Ruby and Smalltalk Dimitri Korsch Stefan Bunk Nicco Kunzmann Matthias Springer Kirstin Heidler Supervisors Prof. Dr. Robert Hirschfeld Tim Felgentreff Tobias Pape Software Architecture Group Hasso Plattner Institute University of Potsdam, Germany July 1, 2013 Preface Object-oriented applications often rely on persistent data that will continue to exist even after the application was closed. To save such data, programmers often use relational databases. They save the data in so called relations, i.e. tables with a fixed schema. However, as objects and relations have fundamentally different concepts, objects cannot be stored in relational databases easily. Aspects such as behavior, inheritance, object identity or encapsulation cannot be mapped to relations in a straightforward way. A mapping has to be defined to translate between object and relational data. This and further differences between object-oriented and relational concepts are summarized with the term Object-relational Impedance Mismatch. To avoid this mismatch, object-oriented databases were built. Instead of translating objects to relations, they directly store the objects in the database. This allows to persist arbitrary objects, such as trees, functions, and threads in the database, without mapping problems. MagLev is an implementation of the Ruby programming language with a built- in object database. It is built on top of GemStone/S, a Smalltalk implementation with a transactional object persistence concept. GemStone/S stores objects in the database and its virtual machine decides which objects are held in-memory and which objects are written to the hard-drive. This work presents different aspects of MagLev: the persistence concept of MagLev and GemStone/S, a Ruby library for the builtin object database, the implementation and language collaboration concepts of MagLev, and the course of action for reimplementing a programming language.
    [Show full text]
  • Ruby Cookbook, Second Edition, by Lucas Carlson and Leonard Richardson
    Updated2nd for Edition Ruby 2.1 Ruby Cookbook SECOND EDITION Why spend time on coding problems that others have already solved when Programmersdon’t “ Cookbook Ruby you could be making real progress on your Ruby project? This updated livebylanguagesyn- cookbook provides more than 350 recipes for solving common problems, on topics ranging from basic data structures, classes, and objects, to web taxalone,butbyevery development, distributed programming, and multithreading. lineofconcretecode Revised for Ruby 2.1, each recipe includes a discussion on why and how theywrite.Tothatend, the solution works. You’ll find recipes suitable for all skill levels, from thisbookisfilledwith Ruby newbies to experts who need an occasional reference. With Ruby practicalrecipes,tips, Cookbook, you’ll not only save time, but keep your brain percolating with new ideas as well. knowledge,andwisdom. Ihopeitleadsreaders Recipes cover: tothenextstepofRuby ■ Data structures including strings, numbers, date and time, programming.” arrays, hashes, files, and directories —Yukihiro (Matz) Matsumoto ■ Using Ruby’s code blocks, also known as closures Creator of Ruby ■ OOP features such as classes, methods, objects, and modules ■ XML and HTML, databases and persistence, and graphics and other formats ■ Web development with Rails and Sinatra ■ Internet services, web services, and distributed programming ■ Software testing, debugging, packaging, and distributing ■ Multitasking, multithreading, and extending Ruby with other languages Ruby Lucas Carlson founded AppFog, a PaaS that leverages the open source Cloud Foundry project. A professional developer for 20 years, he specializes in Ruby on Rails development. Lucas has written Programming for PaaS and Ruby Cookbook, First Edition (both O’Reilly). He maintains a website at http://www.lucascarlson.net/.
    [Show full text]