SlideShare a Scribd company logo
1 of 75
Download to read offline
Ruby on Rails
Web Development that doesn„t hurt
Dezember 2008



                          www.xing.com/profile/Christian_Feser
                          www.xing.com/profile/Michael_Kram
                          www.xing.com/profile/Jakob_Schroeter
                          www.Marc-Seeger.de
Ruby
A Programmer„s Best Friend
3
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 agenda
   •   Design History of Ruby
   •   Agile Manifesto
   •   Language basics
   •   Exercise
   •   Typing
   •   Libraries & Gems
   •   Ruby VMs
   •   Good & bad things
Design History of Ruby
Ruby *is* different from other
languages, indeed.
--Matz.
5
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 History
    • Origin:
         ▫ Yukihiro quot;Matzquot; Matsumoto
         ▫ Japan 1993




    • 1st english book: 2000
    • Ruby on Rails: 2004
6
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 What Matz has to say
                  I wanted a scripting language that
                  was more powerful than Perl, and
                      more object-oriented than
                    Python. That's why I decided to
                       design my own language
7
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 The Power of Ruby
   … according to Yukihiro „Matz“ Matsumoto
8
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby is
   Smalltalk
   – „Unfamiliar Syntax“
   + Perl„s scripting power
   + Pythons exceptions etc.
   + CLU„s iterator
9
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 This helps making ruby…
   •   a Scripting Language
   •   a dynamic typing Language
   •   an Object Oriented Programming Language
   •   a good taste of Functional Programming
   •   a highly reflective Language
   •   a base for creating Domain Specific Languages
10
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Can‘t I do all of that in Java/C?
   Sapir-Whorf-Hypothesis:


   • Language determines the way we think
        ▫ Basic Programmers never use recursion
        ▫ LISP programmers use macros for everything
        ▫ FORTRAN programmers can write FORTRAN in
          any language
11
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby = human-oriented
   •   reduces the burden of programming.
   •   tries to push jobs back to machines.
   •   You can accomplish more tasks with less work
   •   … in smaller yet readable code.
12
 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




  principle of least surprise
 I believe people want to express
 themselves when they program.
 They don't want to fight with the
 language.




Programming languages must feel
natural to programmers. I tried to
make people enjoy programming
and concentrate on the fun and
creative part of programming when
they use Ruby.
13
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Programming experience
 (according to Dr. Jacob Nielson)

   •   Learnability
   •   Efficiency
   •   Memorability
   •   Errors
   •   Satisfaction
14
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 How Ruby helps you: Learnability
15
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 How Ruby helps you: Efficiency
   • Not that fast to execute…
   • BUT fast to programm
        ▫ Pseudo-simplicity
        ▫ Consistency
        ▫ „Smartness“
16
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




    How Ruby helps you: Memorability
•   Conservativeness helps
•   Easy to remember syntax
•   Ruby is NOT a simple language …
•   … BUT the complexity is:
    ▫ Hidden
    ▫ Natural
    ▫ Consistent
17
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 How Ruby helps you: Errors
   • You won„t see that many because:
        ▫ Consistent syntax rules
        ▫ less code  less bugs
18
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 How Ruby helps you: Satisfaction
   • Ruby is fun
   • Ruby makes you feel smart 
19
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby in five E’s
   •   Everything is an object
   •   Elegant blocks give inline power
   •   Exploring with reflection
   •   Extending at runtime
   •   Extensive standard libray

                                                      David Heinemeier Hansson
Agile Manifesto
Painless Programming
21
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby – An Agile Language?
   • the language design should focus on users

   • the language should encourage readability

   • the language should be expressive, and helps
     communication between developers

   • the language should embrace changes, and be
     dynamic
   (Matz@Rubyconf2006)
Language Basics
A Programmer„s Best Friend
23
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Hello World!
24
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Read the following aloud
25
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: comments
26
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics
   •   ClassNames
   •   method_names and variable_names
   •   methods_asking_a_question?
   •   slightly_dangerous_methods!
   •   @instance_variables
   •   $global_variables
   •   SOME_CONSTANTS or OtherConstants
27
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics
   • Variable Declaration:




   • Function Declaration:
28
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Strings
29
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Strings
30
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Strings
31
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Strings
32
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Hashes
33
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Arrays
34
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Give me some sugar: Array
35
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Control Structures
36
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Classes
37
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Classes
   • Classes are always open (even built in classes)




 Another Example from Rails:
 1.hour.from_now
38
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: Inheritance
   • Single Inheritance
        ▫ But mixins are available (= Interface with implemented methods)
39
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




Language Basics: Mixin Example
                                                              This module implements the
                                                             mixin




                                                              A class that doesn„t do that
                                                              much




                                                              inheriting
                                                              and mixing!



                                                             We inherited that one
                                                             And mixed in that one
40
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Blocks




                                    „Blocks are unnamed functions“
41
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Blocks
   Define:




   Call:




   Result:
42
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Blocks Example: Iterators
                                         The current piece
                                                                What we are going
                                         of the collection we
                                                                to do with it
                                         are working with
43
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Closures
44
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Language Basics: IO
Exercise
 http://tryruby.hobix.com 
Typing
…and why do you call Ruby
„dynamic“?
47
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Typing: strong / weak
  • Strong typing
             quot; 5 quot; / 2  „NoMethodError“
  • Weak typing
             quot; 16 quot; / 2  8 (e.g. in Perl)




  Ruby is strongly typed! (Java too)
48
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Typing: explicit/implicit
    • Explicit: int a = 5
    • Implicit: a = 5




    Ruby is implicitly typed! (Java explicitly)
49
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Typing: static / dynamic
    • Static typing
         ▫ The compiler checks types during compilation
    • Dynamic typing
         ▫ The compiler doesn„t check types during compilation




    Ruby uses dynamic typing
    Java uses static typing,
    C# 4.0 will feature the concept of „Dynamic lookup‟ (“foreach()“ already uses it)
    Visual Basic allows you to do both
50
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Typing: duck?!
         If it walks like a duck and quacks like a duck, I would call it a duck.



       duck.quack
                                                                  Some other languages
                                                                  supporting duck-typing:
                                                                  •C# 4.0 will
                                                                  •Groovy
                                                                  •Javascript
                                                                  •Perl
                                                                  •Python
                                                                  •Smalltalk (no types for variables)
                          duck.walk                               •VB
51
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Typing: duck
   • Duck typing allows an object to be passed in to a
     method that expects a certain type even if it
     doesn‟t inherit from that type. All it has to do is
     support the methods and properties of the
     expected type in use by the method.
Libraries & Gems
Because you don„t want to do all of
the work yourself
53
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 The ruby world
54
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Libraries
55
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Rubygems
56
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Gems - search
   > gem search -l xml

   *** LOCAL GEMS ***

   libxml-ruby (0.9.2, 0.9.0, 0.8.3)
   xml-mapping (0.8.1)
   xml-object (0.9.8)
   xml-simple (1.0.11)
57
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Gems - search
   > gem search -r xml

   *** REMOTE GEMS ***

   axml (0.0.2)
   diff2xml (0.0.2)
   eimxml (0.0.2)
   faster_xml_simple (0.5.0)
   fastxml (0.1.92)
   gccxml_gem (0.9.1)
   hashtoxml (0.0.5)
   jrexml (0.5.3)
   libxml-feed (0.0.1)
   libxml-ruby (0.9.4)
   libxml-xmlrpc (0.1.5)
   […]
58
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Gems - installing
   > gem install textgraph
   Successfully installed textgraph-0.1.0
   1 gem installed
   Installing ri documentation for textgraph-0.1.0...
   Installing RDoc documentation for textgraph-
     0.1.0...
59
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Gems - Updates
   > gem update

   Updating installed gems
   Updating haml
   Successfully installed haml-2.0.5
   Updating libxml-ruby
   Building native extensions. This could take a while...
   Successfully installed libxml-ruby-0.9.4-x86-
    mswin32-60
   Updating ruby-debug-ide
   Successfully installed ruby-debug-ide-0.4.2
   […]
60
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Gems - Usage
61
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 RDoc
Ruby
VMs
63
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby VMs
   •   Ruby 1.8 („MRI“-Matz's Ruby Interpreter)
   •   Ruby 1.9 („YARV“)
   •   JRuby
   •   Rubinius
   •   (IronRuby)
64
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Speed
   Rubinius < Ruby 1.8 < JRuby < Ruby 1.9
65
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby 1.8
   • Matz's Ruby Interpreter or Ruby MRI

   • Performance: Code -> Syntax Tree -> Run
   • Threading: Green
   • Unicode: no (utf8 though)
66
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Ruby 1.9
   • YARV (Yet another Ruby VM)

   •   Performance: Code -> Syntax Tree -> ByteCode
   •   Unicode: yes
   •   Threading: Native (but “global interpreter lock“)
   •   small syntax changes
   •   no more continuations
67
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 JRuby
   •   Performance: Hotspot!
   •   Threading: Native
   •   Unicode: no (utf8 or java unicode)
   •   Compatibility: 1.8 and 1.9!
   •   Addon:
        ▫ Deployable on Tomcat/Glassfish/…
        ▫ Access Java from Ruby or Ruby from Java
   • Problems: C Libraries
68
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Rubinius
   • the ultimate level of “dogfooding”
Good and bad things
A Programmer„s Best Friend
70
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Good Things
   • Sweet Language
   • Ruby on Rails
   • Big community
     quot;ruby people are nicequot; - Martin Fowler
   • Open Source
71
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Bad Things

   • Ruby 2 is vaporware
   • „slow“
   • IDE
Ruby 2
Future Prospects
73
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Future Prospects
   • gather wild & weird ideas

   • try to make ruby the best language ever

   • shed light to undefined corners of Ruby

   • finally (if possible), document Ruby specification
Questions & Answers
75
Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger




 Quellen
   • confreaks.com – RubyConf 2006/2007/2008
   • ruby-lang.org
   • tryruby.hobbix.com
   • „Ruby Grundlagen – PDF zum Buch Rapid Web
     Development mit Ruby on Rails“ – besimple.de
   • OReilly - Ruby Cookbook
   • poignantguide.net/ruby/

More Related Content

More from Jakob

Client-side Web Performance Optimization [paper]
Client-side Web Performance Optimization [paper]Client-side Web Performance Optimization [paper]
Client-side Web Performance Optimization [paper]Jakob
 
HTML5 Video vs. Flash Video [paper]
HTML5 Video vs. Flash Video [paper]HTML5 Video vs. Flash Video [paper]
HTML5 Video vs. Flash Video [paper]Jakob
 
Client-side Performance Optimizations
Client-side Performance OptimizationsClient-side Performance Optimizations
Client-side Performance OptimizationsJakob
 
Flash vs. Silverlight auf dem mobilen Endgerät
Flash vs. Silverlight auf dem mobilen EndgerätFlash vs. Silverlight auf dem mobilen Endgerät
Flash vs. Silverlight auf dem mobilen EndgerätJakob
 
Flash Video vs. HTML5 Video
Flash Video vs. HTML5 VideoFlash Video vs. HTML5 Video
Flash Video vs. HTML5 VideoJakob
 
Ruby On Rails - 2. Rails Introduction
Ruby On Rails - 2. Rails IntroductionRuby On Rails - 2. Rails Introduction
Ruby On Rails - 2. Rails IntroductionJakob
 
Ruby On Rails - 3. Rails Addons
Ruby On Rails - 3. Rails AddonsRuby On Rails - 3. Rails Addons
Ruby On Rails - 3. Rails AddonsJakob
 

More from Jakob (7)

Client-side Web Performance Optimization [paper]
Client-side Web Performance Optimization [paper]Client-side Web Performance Optimization [paper]
Client-side Web Performance Optimization [paper]
 
HTML5 Video vs. Flash Video [paper]
HTML5 Video vs. Flash Video [paper]HTML5 Video vs. Flash Video [paper]
HTML5 Video vs. Flash Video [paper]
 
Client-side Performance Optimizations
Client-side Performance OptimizationsClient-side Performance Optimizations
Client-side Performance Optimizations
 
Flash vs. Silverlight auf dem mobilen Endgerät
Flash vs. Silverlight auf dem mobilen EndgerätFlash vs. Silverlight auf dem mobilen Endgerät
Flash vs. Silverlight auf dem mobilen Endgerät
 
Flash Video vs. HTML5 Video
Flash Video vs. HTML5 VideoFlash Video vs. HTML5 Video
Flash Video vs. HTML5 Video
 
Ruby On Rails - 2. Rails Introduction
Ruby On Rails - 2. Rails IntroductionRuby On Rails - 2. Rails Introduction
Ruby On Rails - 2. Rails Introduction
 
Ruby On Rails - 3. Rails Addons
Ruby On Rails - 3. Rails AddonsRuby On Rails - 3. Rails Addons
Ruby On Rails - 3. Rails Addons
 

Recently uploaded

State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...SOFTTECHHUB
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfAnubhavMangla3
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 

Recently uploaded (20)

State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 

Ruby On Rails - 1. Ruby Introduction

  • 1. Ruby on Rails Web Development that doesn„t hurt Dezember 2008 www.xing.com/profile/Christian_Feser www.xing.com/profile/Michael_Kram www.xing.com/profile/Jakob_Schroeter www.Marc-Seeger.de
  • 3. 3 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger agenda • Design History of Ruby • Agile Manifesto • Language basics • Exercise • Typing • Libraries & Gems • Ruby VMs • Good & bad things
  • 4. Design History of Ruby Ruby *is* different from other languages, indeed. --Matz.
  • 5. 5 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger History • Origin: ▫ Yukihiro quot;Matzquot; Matsumoto ▫ Japan 1993 • 1st english book: 2000 • Ruby on Rails: 2004
  • 6. 6 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger What Matz has to say I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language
  • 7. 7 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger The Power of Ruby … according to Yukihiro „Matz“ Matsumoto
  • 8. 8 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby is Smalltalk – „Unfamiliar Syntax“ + Perl„s scripting power + Pythons exceptions etc. + CLU„s iterator
  • 9. 9 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger This helps making ruby… • a Scripting Language • a dynamic typing Language • an Object Oriented Programming Language • a good taste of Functional Programming • a highly reflective Language • a base for creating Domain Specific Languages
  • 10. 10 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Can‘t I do all of that in Java/C? Sapir-Whorf-Hypothesis: • Language determines the way we think ▫ Basic Programmers never use recursion ▫ LISP programmers use macros for everything ▫ FORTRAN programmers can write FORTRAN in any language
  • 11. 11 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby = human-oriented • reduces the burden of programming. • tries to push jobs back to machines. • You can accomplish more tasks with less work • … in smaller yet readable code.
  • 12. 12 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger principle of least surprise I believe people want to express themselves when they program. They don't want to fight with the language. Programming languages must feel natural to programmers. I tried to make people enjoy programming and concentrate on the fun and creative part of programming when they use Ruby.
  • 13. 13 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Programming experience (according to Dr. Jacob Nielson) • Learnability • Efficiency • Memorability • Errors • Satisfaction
  • 14. 14 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger How Ruby helps you: Learnability
  • 15. 15 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger How Ruby helps you: Efficiency • Not that fast to execute… • BUT fast to programm ▫ Pseudo-simplicity ▫ Consistency ▫ „Smartness“
  • 16. 16 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger How Ruby helps you: Memorability • Conservativeness helps • Easy to remember syntax • Ruby is NOT a simple language … • … BUT the complexity is: ▫ Hidden ▫ Natural ▫ Consistent
  • 17. 17 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger How Ruby helps you: Errors • You won„t see that many because: ▫ Consistent syntax rules ▫ less code  less bugs
  • 18. 18 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger How Ruby helps you: Satisfaction • Ruby is fun • Ruby makes you feel smart 
  • 19. 19 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby in five E’s • Everything is an object • Elegant blocks give inline power • Exploring with reflection • Extending at runtime • Extensive standard libray David Heinemeier Hansson
  • 21. 21 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby – An Agile Language? • the language design should focus on users • the language should encourage readability • the language should be expressive, and helps communication between developers • the language should embrace changes, and be dynamic (Matz@Rubyconf2006)
  • 23. 23 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Hello World!
  • 24. 24 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Read the following aloud
  • 25. 25 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: comments
  • 26. 26 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics • ClassNames • method_names and variable_names • methods_asking_a_question? • slightly_dangerous_methods! • @instance_variables • $global_variables • SOME_CONSTANTS or OtherConstants
  • 27. 27 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics • Variable Declaration: • Function Declaration:
  • 28. 28 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Strings
  • 29. 29 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Strings
  • 30. 30 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Strings
  • 31. 31 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Strings
  • 32. 32 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Hashes
  • 33. 33 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Arrays
  • 34. 34 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Give me some sugar: Array
  • 35. 35 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Control Structures
  • 36. 36 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Classes
  • 37. 37 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Classes • Classes are always open (even built in classes) Another Example from Rails: 1.hour.from_now
  • 38. 38 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Inheritance • Single Inheritance ▫ But mixins are available (= Interface with implemented methods)
  • 39. 39 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: Mixin Example  This module implements the mixin A class that doesn„t do that much inheriting and mixing! We inherited that one And mixed in that one
  • 40. 40 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Blocks „Blocks are unnamed functions“
  • 41. 41 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Blocks Define: Call: Result:
  • 42. 42 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Blocks Example: Iterators The current piece What we are going of the collection we to do with it are working with
  • 43. 43 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Closures
  • 44. 44 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Language Basics: IO
  • 46. Typing …and why do you call Ruby „dynamic“?
  • 47. 47 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Typing: strong / weak • Strong typing  quot; 5 quot; / 2  „NoMethodError“ • Weak typing  quot; 16 quot; / 2  8 (e.g. in Perl) Ruby is strongly typed! (Java too)
  • 48. 48 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Typing: explicit/implicit • Explicit: int a = 5 • Implicit: a = 5 Ruby is implicitly typed! (Java explicitly)
  • 49. 49 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Typing: static / dynamic • Static typing ▫ The compiler checks types during compilation • Dynamic typing ▫ The compiler doesn„t check types during compilation Ruby uses dynamic typing Java uses static typing, C# 4.0 will feature the concept of „Dynamic lookup‟ (“foreach()“ already uses it) Visual Basic allows you to do both
  • 50. 50 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Typing: duck?! If it walks like a duck and quacks like a duck, I would call it a duck. duck.quack Some other languages supporting duck-typing: •C# 4.0 will •Groovy •Javascript •Perl •Python •Smalltalk (no types for variables) duck.walk •VB
  • 51. 51 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Typing: duck • Duck typing allows an object to be passed in to a method that expects a certain type even if it doesn‟t inherit from that type. All it has to do is support the methods and properties of the expected type in use by the method.
  • 52. Libraries & Gems Because you don„t want to do all of the work yourself
  • 53. 53 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger The ruby world
  • 54. 54 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Libraries
  • 55. 55 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Rubygems
  • 56. 56 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Gems - search > gem search -l xml *** LOCAL GEMS *** libxml-ruby (0.9.2, 0.9.0, 0.8.3) xml-mapping (0.8.1) xml-object (0.9.8) xml-simple (1.0.11)
  • 57. 57 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Gems - search > gem search -r xml *** REMOTE GEMS *** axml (0.0.2) diff2xml (0.0.2) eimxml (0.0.2) faster_xml_simple (0.5.0) fastxml (0.1.92) gccxml_gem (0.9.1) hashtoxml (0.0.5) jrexml (0.5.3) libxml-feed (0.0.1) libxml-ruby (0.9.4) libxml-xmlrpc (0.1.5) […]
  • 58. 58 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Gems - installing > gem install textgraph Successfully installed textgraph-0.1.0 1 gem installed Installing ri documentation for textgraph-0.1.0... Installing RDoc documentation for textgraph- 0.1.0...
  • 59. 59 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Gems - Updates > gem update Updating installed gems Updating haml Successfully installed haml-2.0.5 Updating libxml-ruby Building native extensions. This could take a while... Successfully installed libxml-ruby-0.9.4-x86- mswin32-60 Updating ruby-debug-ide Successfully installed ruby-debug-ide-0.4.2 […]
  • 60. 60 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Gems - Usage
  • 61. 61 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger RDoc
  • 63. 63 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby VMs • Ruby 1.8 („MRI“-Matz's Ruby Interpreter) • Ruby 1.9 („YARV“) • JRuby • Rubinius • (IronRuby)
  • 64. 64 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Speed Rubinius < Ruby 1.8 < JRuby < Ruby 1.9
  • 65. 65 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby 1.8 • Matz's Ruby Interpreter or Ruby MRI • Performance: Code -> Syntax Tree -> Run • Threading: Green • Unicode: no (utf8 though)
  • 66. 66 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Ruby 1.9 • YARV (Yet another Ruby VM) • Performance: Code -> Syntax Tree -> ByteCode • Unicode: yes • Threading: Native (but “global interpreter lock“) • small syntax changes • no more continuations
  • 67. 67 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger JRuby • Performance: Hotspot! • Threading: Native • Unicode: no (utf8 or java unicode) • Compatibility: 1.8 and 1.9! • Addon: ▫ Deployable on Tomcat/Glassfish/… ▫ Access Java from Ruby or Ruby from Java • Problems: C Libraries
  • 68. 68 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Rubinius • the ultimate level of “dogfooding”
  • 69. Good and bad things A Programmer„s Best Friend
  • 70. 70 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Good Things • Sweet Language • Ruby on Rails • Big community quot;ruby people are nicequot; - Martin Fowler • Open Source
  • 71. 71 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Bad Things • Ruby 2 is vaporware • „slow“ • IDE
  • 73. 73 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Future Prospects • gather wild & weird ideas • try to make ruby the best language ever • shed light to undefined corners of Ruby • finally (if possible), document Ruby specification
  • 75. 75 Christian Feser, Michael Kram, Jakob Schröter, Marc Seeger Quellen • confreaks.com – RubyConf 2006/2007/2008 • ruby-lang.org • tryruby.hobbix.com • „Ruby Grundlagen – PDF zum Buch Rapid Web Development mit Ruby on Rails“ – besimple.de • OReilly - Ruby Cookbook • poignantguide.net/ruby/