Introduction to Ruby on Rails

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Ruby on Rails Introduction to Ruby on Rails Thomas Kowark Software Engineering II Prof. Plattner, Dr. Uflacker WS 2015/16 Enterprise Platform and Integration Concepts group Introduction to Ruby on Rails 1. Ruby & Ruby on Rails ■ What is Ruby on Rails? ■ A few words about Ruby ■ Rails' core components ■ RESTful architecture 2. Your first Rails applicaon 3. Your introductory Rails exercise 4. AddiAonal Literature Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 2 What is Ruby on Rails? Web applicaon development framework wriHen in Ruby ■ hHp://rubyonrails.org/ Philosophy ■ "Don't repeat yourself" – DRY ■ ConvenAon over Configuraon – there is "the Rails way" ■ RESTful architecture ■ Everything in its place Rails 1 Rails2 Rails 3 Rails 4 Rails 5 2003 2006 2009 2013 est. 2015 ■ Used by Github, Groupon, TwiHer (parAally) Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 3 A few words about Ruby hHp://www.ruby-lang.org/ ■ Dynamic, reflecAve, general-purpose, object-oriented ■ Influenced by Perl, Smalltalk, Eiffel, and Lisp ■ Open-source, mature soaware ■ Matz’s Ruby Interpreter (MRI) versions: Yukihiro "Matz" Matsumoto with R. Stallman Ruby 1.0 Ruby 1.8.7 Ruby 1.9.3 Ruby 2.0.0 Ruby 2.2.2 1996 2010 2011 2013 2015 □ AddiAonally different VMs available (JRuby, Rubinius, IronRuby, Maglev) Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 Image by Rubén Rodríguez (CC BY 3.0) - hHp://commons.wikimedia.org/wiki/File:Matz.jpgOctober 16, 2015 4 Rails Core Components Ac1on Pack Raili1es Ac1on View (core code, e.G. rake) View (renders template) Ac1ve Support Ac1on Dispatch (ulity classes, (parses HTTP, sessions, cookies, etc.) e.g. i18n) Controller Ac1on Controller (make data available, applica1on flow) Ac1on Mailer (email services) Ac1ve Model Model (e.G. validaons) Gems Ac1ve Record (ORM) (packaGed libraries) Data storage hps://rubygems.orG/ Database (SQL, Graph..) Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 hHp://adrianmejia.com/blog/2011/08/11/ruby-on-rails-architectural-design/ October 16, 2015 5 Rails Application Layout my_first_rails_app/ app/ assets/ controller/ applicaon_controller.rb helpers/ applicaon_helper.rb models/ views/ applicaon/ index.html.erb layouts/ applicaon.html.erb Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 6 RESTful Architecture ■ Representaonal State Transfer (REST) is a soaware architecture style for distributed systems ■ Principles □ Uniform Interface □ Stateless InteracAons □ Cacheable □ Clients and servers □ Layered System □ Code on Demand (opAonal) ■ Largest RESTful implementaon: World Wide Web Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 7 RESTful Architecture – HTTP verbs ■ REST supports all 4 HTTP 1.1 verbs: GET, PUT, POST, DELETE ■ DifferenAaon of collecAons and individual elements Resource GET PUT POST DELETE Single element Retrieve Update or create Create Delete hHp://localhost:3000/authors/1 Collecon List Replace Create Delete hHp://localhost:3000/authors Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 8 Examples of Routes ■ GET / # invoke “home” controller ■ GET /authors # retrieve a list of all authors ■ GET /authors/new # get the form to enter a new author ■ POST /authors # create a new author ■ GET /authors/1 # show details of the first author ■ GET /authors/1/edit # get the form to edit the first author ■ PUT /authors/1 # update the first author ■ DELETE /authors/1 # delete the first author Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 9 Introduction to Ruby on Rails 1. Ruby & Ruby on Rails 2. Your first Rails applica1on 3. Your introductory Rails exercise 4. AddiAonal Literature Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 10 How to Start? ■ Opon 1: You use Mac or Linux □ Install and use Ruby on Rails directly on your OS □ Ruby version manager (e.g. RVM, rbenv) if older versions of Ruby should be kept □ hHp://guides.rubyonrails.org/geng_started.html#installing-rails □ Or use opon 2 ■ Opon 2: You have Windows or want to use a VM (recommended) □ We prepared one for you via Vagrant (hHps://www.vagrantup.com/) □ Uses VirtualBox in the backend (free on all plaorms) (hHps://www.virtualbox.org/) □ Use your own tools & editors, run the project in a headless VM □ See project README for setup instrucAons ■ Opon 3: You have Windows and install Ruby on Rails directly on your OS □ Tends to consume some Ame, might cause problems with certain dependencies □ hHp://railsinstaller.org/en Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 11 Comprehensive RoR tutorial Recommended to work through / read this hands-on tutorial. Seriously. hHp://guides.rubyonrails.org/geng_started.html Info: Before you start coding, make sure, the correct versions are installed. $ ruby --version $ rails --version The following slides give a general overview Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 12 rails – Main executable Start interacAve shell to test out ideas $ rails console Start new rails applicaon $ rails new Generate boilerplate for models, controllers & views $ rails generate Start the development server $ rails server Start a direct database shell $ rails dbconsole ■ Example: generate model, controller and view without controller specs $ rails g scaffold author last_name:string homepage:string --controller-specs false Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 hHp://guides.rubyonrails.org/command_line.html October 16, 2015 13 Bundler – Ruby package manager ■ Ruby libraries are packaged as "gems" ■ Online repository at hps://rubygems.org/ ■ Bundler resolves dependencies of gems ■ Gemfile holds a list of required gems □ Specify versions, e.g. gem 'rails' >= '4.1.6’ □ Alt. sources, e.g. :github => ”tkowark/sawyer” ■ Gemfile.lock is populated with resolved dependencies □ Should be under version control Manually install a gem (Ruby package) $ gem install Info: Gemfile.lock Install all gems listed as depencies in Gemfile contains all the actually installed $ bundle install versions of gems. Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 14 rake – Ruby make List all available rake commands $ rake -T List all configured routes $ rake routes Setup the database and run all migraons $ rake db:setup && rake db:migrate Replace database with db layout from db/schema.rb Info: Do not run migraons. Running schema:load $ rake db:schema:load is advisable when seng up a completely new project. It is not Run Rspec (tesAng framework for RoR) tests intended to work around bad migraons. $ rake spec Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 15 Git – distributed version control system ■ Install Git: □ sudo apt-get install git □ hHp://git-scm.com/ (Installers for all systems) ■ Seng up user name and email: □ Mandatory to commit changes □ Use your github credenAals! $ git config --global user.email “[email protected]” $ git config --global user.name “Max Mustermann” ■ Alternave: seng parameters only for one project: $ cd /path/to/your/project $ git config user.email “[email protected]” $ git config user.name “Max Mustermann” Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 16 Git workflow – commiting a change Checkout remote repository to local copy $ git clone https://github.com/hpi-swt2/wimi-portal Change main layout template app/views/layouts/applicaon.html.erb Stage changes (add files from working copy to repository index) $ git add app/views/layouts List changes to be commiHed $ git status Commit with commit messages. Reference Github issue #25 $ git commit –m "Fixed issue #25" Fetch and merge changes from remote repository $ git pull Publish local commits $ git push Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 17 Introduction to Ruby on Rails 1. Ruby & Ruby on Rails 2. Your first Rails applicaon 3. Your introductory Rails exercise 4. AddiAonal Literature Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 18 Exercise 1 – Code School ■ Goals □ Get familiar with Ruby on Rails □ Create necessary accounts for the project ■ Tasks □ Create a Github account □ Link it with CodeSchool.com (unless you already have an account) □ Complete Rails coding school: hHp://railsforzombies.com □ Complete Git Tutorial: hHps://www.codeschool.com/courses/try-git □ When done, create a screenshot of your report card ■ Deadline: Nov 6, 11:59 pm CET (firm) Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 19 Exercise 2 - Develop a Rails App ■ Goals □ Deepen your understanding of Rails Apps □ Get used to TDD/BDD ■ Tasks □ Sign up on Github Classroom – hHps://classroom.github.com/assignment-invitaons/ebc02d7d20638a7ef2660434c04136c2 – Repository might take some me to receive iniAal skeleton code (be paent...) □ Make the tests “green” – Start with ‘rake spec’ – Run single feature tests with ‘rspec spec/features/…/..._spec.rb’ □ Commit your screenshot from Exercise 1 ■ Deadline □ Nov 6, 11:59 pm CET (firm) □ POs are exempt from this task. Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 20 Exercise 2 – Requirements ■ Web-based paper management system □ Author – First name – Last name – Homepage □ Paper – Title – Publicaon – Year □ A paper has many authors (max. 5) □ An author has many papers ■ We prepared a Rails applicaon for you Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 21 Exercise 2 – Use Cases & Site Map Home Show Show Papers Authors Add Author Add Paper Show Author Show Paper Details Details Edit Author Edit Paper Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 22 Exercise 2 – Mock Up hHps://gomockingbird.com/mockingbird/index.html?project=v890g6l Introduction to Ruby on Rails — Software Engineering II — WS 2015/16 October 16, 2015 23 Additional Literature General literature ■ Ruby, S.; Thomas, D.; Hansson D.
Recommended publications
  • Github Essentials.Pdf
    [ 1 ] GitHub Essentials Unleash the power of collaborative workflow development using GitHub, one step at a time Achilleas Pipinellis BIRMINGHAM - MUMBAI GitHub Essentials 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: 1280915 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78355-371-6 www.packtpub.com Credits Author Copy Editor Achilleas Pipinellis Trishya Hajare Reviewer Project Coordinator Umesh Ram Sharma Shweta H Birwatkar Commissioning Editor Proofreader Dipika Gaonkar Safis Editng Acquisition Editor Indexer Nikhil Karkal Hemangini Bari Content Development Editor Production Coordinator Sumeet Sawant Nitesh Thakur Technical Editor Cover Work Saurabh Malhotra Nitesh Thakur About the Author Achilleas Pipinellis is an open source enthusiast and tries to get involved in as many projects as possible.
    [Show full text]
  • 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]
  • Michael Johann Mjohann@Rails­Experts.Com
    Steinfurt, Germany Michael Johann mjohann@rails­experts.com http://www.rails­experts.com I am interested in new projects where various modern technologies are combined to build great innovative products. My view is from the full stack developer to architecture and engineering aspects. I am also passionate about being a CTO if the company is trusting my technical experience. I've supported the most known industry standards before thy became mainstream. I've founded JavaSPEKTRUM print magazine in 1996 and RailsWayMagazine (print) in 2009 and have been editor in chief for both magazines. In 2008 I wrote a german book about "JRuby on Rails for Java Enterprise Developers). As a regular speaker at conferences in Europe/USA, I always spread the news about new technologies and how they apply to projects. As a person with multiple interests I combine using technical aspects in development with writing and speaking at conferences. I've been an evangelist for Java and Rails. Technical Skills Like: ruby, on, rails, ios, android, java, jee, html5, css3, javascript, mongodb, torquebox, ansible, docker, rspec, cucumber Dislike: php, typo3, cobol Experience Chief Full Stack Developer – Smaps GmbH December 2013 ­ Current ruby­on­rails­4.1, objective­c, mongodb, android Responsible for product development of backend, frontend and mobile clients Backend consists of MongoDB Frontend is HTML5 with Bootstrap, JQuery, GoogleMaps API iOS Client native with RestKit API communication Android native (Java) Interims CTO – Eco Novum GmbH 2012 ­ November 2013 ios, mongodb, jrubyonrails, html5, css3, javascript, chef, git, jira, json Responsible for all architectural and technological aspects of the products (several mobile payment solutions).
    [Show full text]
  • UNIVERSITY of CALIFORNIA, SAN DIEGO Toward Understanding And
    UNIVERSITY OF CALIFORNIA, SAN DIEGO Toward Understanding and Dealing with Failures in Cloud-Scale Systems A dissertation submitted in partial satisfaction of the requirements for the degree of Doctor of Philosophy in Computer Science by Peng Huang Committee in charge: Professor Yuanyuan Zhou, Chair Professor Tara Javidi Professor Ranjit Jhala Professor George Porter Professor Stefan Savage 2016 Copyright Peng Huang, 2016 All rights reserved. The Dissertation of Peng Huang is approved and is acceptable in quality and form for publication on microfilm and electronically: Chair University of California, San Diego 2016 iii DEDICATION To my parents, brother and fiancée for their unconditional love and support. iv EPIGRAPH Quis custodiet ipsos custodes? (But who can watch the watchmen?) Juvenal Anything that can go wrong, will go wrong. Murphy’s law Those who fail to learn from the mistakes are doomed to repeat them. George Santayana In the middle of the night, [...] He would awaken and find himeself wondering if one of the machines had stopped working for some new, unknown reason. Or he would wake up thinking about the latest failure, the one whose cause they’d been looking for a whole week and sitll hadn’t found. The bogeyman—la machine—was there in his bedroom. Tracy Kidder, The Soul of a New Machine v TABLE OF CONTENTS SignaturePage...................................... .................. iii Dedication ......................................... .................. iv Epigraph........................................... .................. v TableofContents
    [Show full text]
  • Ruby on Rails™ Tutorial: Learn Web Developments with Rails
    ptg8286261 www.it-ebooks.info Praise for Michael Hartl’s Books and Videos on Ruby on RailsTM ‘‘My former company (CD Baby) was one of the first to loudly switch to Ruby on ptg8286261 Rails, and then even more loudly switch back to PHP (Google me to read about the drama). This book by Michael Hartl came so highly recommended that I had to try it, and the Ruby on RailsTM Tutorial is what I used to switch back to Rails again.’’ —From the Foreword by Derek Sivers (sivers.org) Formerly: Founder, CD Baby Currently: Founder, Thoughts Ltd. ‘‘Michael Hartl’s Rails Tutorial book is the #1 (and only, in my opinion) place to start when it comes to books about learning Rails. It’s an amazing piece of work and, unusually, walks you through building a Rails app from start to finish with testing. If you want to read just one book and feel like a Rails master by the end of it, pick the Ruby on RailsTM Tutorial.’’ —Peter Cooper Editor, Ruby Inside www.it-ebooks.info ‘‘Grounded in the real world.’’ —I Programmer (www.i-programmer.info), by Ian Elliot ‘‘The book gives you the theory and practice, while the videos focus on showing you in person how its done. Highly recommended combo.’’ —Antonio Cangiano, Software Engineer, IBM ‘‘The author is clearly an expert at the Ruby language and the Rails framework, but more than that, he is a working software engineer who introduces best practices throughout the text.’’ —Greg Charles, Senior Software Developer, Fairway Technologies ‘‘Overall, these video tutorials should be a great resource for anyone new to Rails.’’ —Michael Morin, ruby.about.com ‘‘Hands-down, I would recommend this book to anyone wanting to get into Ruby on Rails development.’’ —Michael Crump, Microsoft MVP ptg8286261 www.it-ebooks.info RUBY ON RAILSTM TUTORIAL Second Edition ptg8286261 www.it-ebooks.info Visit informit.com/ruby for a complete list of available products.
    [Show full text]
  • Deploying with Jruby Is the Definitive Text on Getting Jruby Applications up and Running
    Early Praise for Deploying JRuby Deploying with JRuby is the definitive text on getting JRuby applications up and running. Joe has pulled together a great collection of deployment knowledge, and the JRuby story is much stronger as a result. ➤ Charles Oliver Nutter JRuby Core team member and coauthor, Using JRuby Deploying with JRuby answers all of the most frequently asked questions regarding real-world use of JRuby that I have seen, including many we were not able to answer in Using JRuby. Whether you’re coming to JRuby from Ruby or Java, Joe fills in all the gaps you’ll need to deploy JRuby with confidence. ➤ Nick Sieger JRuby Core team member and coauthor, Using JRuby This book is an excellent guide to navigating the various JRuby deployment op- tions. Joe is fair in his assessment of these technologies and describes a clear path for getting your Ruby application up and running on the JVM. ➤ Bob McWhirter TorqueBox team lead at Red Hat Essential reading to learn not only how to deploy web applications on JRuby but also why. ➤ David Calavera Creator of Trinidad Deploying with JRuby is a must-read for anyone interested in production JRuby deployments. The book walks through the major deployment strategies by providing easy-to-follow examples that help the reader take full advantage of the JRuby servers while avoiding the common pitfalls of migrating an application to JRuby. ➤ Ben Browning TorqueBox developer at Red Hat Deploying with JRuby is an invaluable resource for anyone planning on using JRuby for web-based development. For those who have never used JRuby, Joe clearly presents its many advantages and few disadvantages in comparison to MRI.
    [Show full text]
  • Prioritizing Pull Requests
    Prioritizing pull requests Version of June 17, 2015 Erik van der Veen Prioritizing pull requests THESIS submitted in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE in COMPUTER SCIENCE by Erik van der Veen born in Voorburg, the Netherlands Software Engineering Research Group Q42 Department of Software Technology Waldorpstraat 17F Faculty EEMCS, Delft University of Technology 2521 CA Delft, the Netherlands The Hague, the Netherlands www.ewi.tudelft.nl www.q42.com c 2014 Erik van der Veen. Cover picture: Finding the pull request that needs the most attention. Prioritizing pull requests Author: Erik van der Veen Student id: 1509381 Email: [email protected] Abstract Previous work showed that in the pull-based development model integrators face challenges with regard to prioritizing work in the face of multiple concurrent pull requests. We identified the manual prioritization heuristics applied by integrators and ex- tracted features from these heuristics. The features are used to train a machine learning model, which is capable of predicting a pull request’s importance. The importance is then used to create a prioritized order of the pull requests. Our main contribution is the design and initial implementation of a prototype service, called PRioritizer, which automatically prioritizes pull requests. The service works like a priority inbox for pull requests, recommending the top pull requests the project owner should focus on. It keeps the pull request list up-to-date when pull requests are merged or closed. In addition, the service provides functionality that GitHub is currently lacking. We implemented pairwise pull request conflict detection and several new filter and sorting options e.g.
    [Show full text]
  • High Availability Framework for Mix-Cloud Secure Applications
    PETR BELYAEV HIGH AVAILABILITY FRAMEWORK FOR MIX-CLOUD SE- CURE APPLICATIONS Master of Science thesis Examiners: Prof. Jose Luis Martinez Lastra, Dr. Andrei Lobov Examiners and topic approved by the Faculty Council of the Faculty of Automation and Science Engineering on 6th April 2016 i ABSTRACT PETR BELYAEV: High Availability Framework for Mix-Cloud Secure Applications Tampere University of Technology Master of Science thesis, 53 pages, 6 Appendix pages November 2016 Master's Degree Programme in Automation Technology Major: Factory Automation and Industrial Informatics Examiners: Prof. Jose Luis Martinez Lastra, Dr. Andrei Lobov Keywords: High Availability, clustering, cloud Having one of the services, such as web applications, databases or telephony systems, unavailable because of a single server failure is very annoying, yet very common issue, especially if the service is deployed on-premises. The simplest way to address it is to introduce redundancy to the system. But in this case the amount of physical machines needed will raise, while their eciency will drop as most of the services do not use 100% of machine's capabilities. The better way to solve the service availability issue is to logically separate the service from the underlying hardware, balancing the load between instances and migrating them between the physical machines in case of failure. This way is much more eective, but it also contains a number of challenges, such as conguration diculty and inter-service request routing. The High Availability (HA) framework discussed in this thesis was designed to miti- gate those issues. The key goal solved by the HA framework is raising the scalability and reliability of the service while keeping the conguration as simple as possible.
    [Show full text]
  • Debugging at Full Speed
    Debugging at Full Speed Chris Seaton Michael L. Van De Vanter Michael Haupt Oracle Labs Oracle Labs Oracle Labs University of Manchester michael.van.de.vanter [email protected] [email protected] @oracle.com ABSTRACT Ruby; D.3.4 [Programming Languages]: Processors| Debugging support for highly optimized execution environ- run-time environments, interpreters ments is notoriously difficult to implement. The Truffle/- Graal platform for implementing dynamic languages offers General Terms an opportunity to resolve the apparent trade-off between Design, Performance, Languages debugging and high performance. Truffle/Graal-implemented languages are expressed as ab- Keywords stract syntax tree (AST) interpreters. They enjoy competi- tive performance through platform support for type special- Truffle, deoptimization, virtual machines ization, partial evaluation, and dynamic optimization/deop- timization. A prototype debugger for Ruby, implemented 1. INTRODUCTION on this platform, demonstrates that basic debugging services Although debugging and code optimization are both es- can be implemented with modest effort and without signifi- sential to software development, their underlying technolo- cant impact on program performance. Prototyped function- gies typically conflict. Deploying them together usually de- ality includes breakpoints, both simple and conditional, at mands compromise in one or more of the following areas: lines and at local variable assignments. The debugger interacts with running programs by insert- • Performance: Static compilers
    [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]
  • Maglev: a Fast and Reliable Software Network Load Balancer
    Maglev: A Fast and Reliable Software Network Load Balancer Daniel E. Eisenbud, Cheng Yi, Carlo Contavalli, Cody Smith, Roman Kononov, Eric Mann-Hielscher, Ardas Cilingiroglu, Bin Cheyney, Wentao Shang†* and Jinnah Dylan Hosein‡* Google Inc. †UCLA ‡SpaceX [email protected] Abstract Maglev is Google’s network load balancer. It is a large distributed software system that runs on commodity Linux servers. Unlike traditional hardware network load balancers, it does not require a specialized physical rack deployment, and its capacity can be easily adjusted by adding or removing servers. Network routers distribute packets evenly to the Maglev machines via Equal Cost Multipath (ECMP); each Maglev machine then matches Figure 1: Hardware load balancer and Maglev. the packets to their corresponding services and spreads them evenly to the service endpoints. To accommodate high and ever-increasing traffic, Maglev is specifically balancers form a critical component of Google’s produc- optimized for packet processing performance. A single tion network infrastructure. Maglev machine is able to saturate a 10Gbps link with A network load balancer is typically composed of small packets. Maglev is also equipped with consistent multiple devices logically located between routers and hashing and connection tracking features, to minimize service endpoints (generally TCP or UDP servers), as the negative impact of unexpected faults and failures on shown in Figure 1. The load balancer is responsible for connection-oriented protocols. Maglev has been serving matching each packet to its corresponding service and Google’s traffic since 2008. It has sustained the rapid forwarding it to one of that service’s endpoints. global growth of Google services, and it also provides Network load balancers have traditionally been imple- network load balancing for Google Cloud Platform.
    [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]