SlideShare a Scribd company logo
Introduction to Ruby & Modern
Programming
Christos Sotirelis
www.sotirelischristos.com
December 2015
What am I doing here?
Our goal
 Meet Ruby and modern programming
 See how to benefit from Ruby
 Learn some Ruby basics
 Prepare to dive in Rails and modern web applications
 Keep the journey going
What is Ruby?
What is Ruby?
o Dynamic, interpreted, object-oriented programming
language written in C
o Expressive and declarative
o Invented by Yukihiro “Matz” Matsumoto in 1996 but
was popularized by Ruby on Rails in 2005
o Influenced by Perl, Python, Smalltalk, Eiffel, Ada, Lisp
o Designed to make programmers happy
o Open source
Why another language?
Why Ruby?
o Very well documented
o Highly readable
o Multi-paradigm
o Memory-managed and garbage-collected
o Built-in data structures
o Many more..
Getting on Cloud9
 https://c9.io/
 “SIGN UP” or “TRY IT NOW”
 Create a new workspace
 “Ruby on Rails Tutorial” template
The IRB
On Cloud9’s terminal: irb
Alternatively, save your Ruby code with .rb
extension and run with: ruby <file.rb>
Ruby is multi-paradigm
Procedural
Procedural + Object-Oriented
OO Ruby
 In a website, a User is a class
 It has fields, such as an email and a password
 It also has methods, such as register() and login()
 We can create objects (or instances) of a class, such
as user1, user2 and so on
 We can also access their fields, like user1.email and
user1.password
 Most importantly, we can use class methods on our
objects, like user2.register() or user2.login()
 In a traditional, non-OO system, we would have to use
many different variables and methods for every user
we had (too much space)
OO Ruby
Procedural + Object-Oriented + Functional
Functional?
Chained methods
Java VS. Ruby
In Ruby, everything is an object!
is actually that:
So this..
Tell me 10 random methods of you
Hey 10, what are you?
More (expressive) Ruby..
Syntactic sugar
Parentheses and semicolons are optional
Dynamic typing
Duck typing
“If it walks like a duck and quacks like a duck, then
it must be a duck.”
Ruby conditionals
Ruby conditionals
Ruby loops
..much better this way!
Too old style..
Ranges :D
Homemade alphabet
Methods
Multiple returns plus
syntactic sugar
Arrays & hashes
Arrays & hashes
 Arrays and hashes in Ruby are more like collections
 They respond to same methods
 We can think of arrays as dynamic lists
 Arrays are also type-agnostic
Arrays
Hashes
 Hashes are pairs of unique keys and values
 Hashes (and arrays) include the Enumerable mixin
Advanced concepts
Open classes
 In Ruby, classes are never closed: methods can always
be added to an existing class
 Applies to all classes, including the standard, built-in
classes
 If not cautious, bad things are bound to happen
Metaprogramming & reflection
 In Ruby, code can be programmatically modified at
runtime
 Writing code that writes code
 Classes and methods know about themselves
Metaprogramming & reflection
Ruby gems
 Libraries in Ruby are called gems
 Can be installed with “gem install capistrano”
 View locally installed gems with “gem list”
Simple deck with cards
Save as cards.rb and run with “ruby cards.rb”
Look up on your own
 method_missing
 Mixins
 Introspection
 Exceptions
 Procs & lambdas
 Multithreading
 File I/O
 Sockets
 Regular expressions
 (Unit) Testing
More about Ruby
 https://www.ruby-lang.org
 https://www.codecademy.com
 http://www.tryruby.org
 http://www.ruby-doc.org
 http://www.sitepoint.com/ruby
Thank you!
you.ask(me) or you.email(me) if any_questions?
you.applause
www.sotirelischristos.com
Ad

More Related Content

Similar to Introduction to Ruby & Modern Programming (20)

ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008
Brian Sam-Bodden
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
Felipe Schmitt
 
Ruby
RubyRuby
Ruby
Vladimir Bystrov
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Mark Menard
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
Mark Menard
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
Thomas Asikis
 
Optimizing for programmer happiness
Optimizing for programmer happinessOptimizing for programmer happiness
Optimizing for programmer happiness
Josh Schramm
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
Espen Brækken
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
Amit Patel
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
Tushar Pal
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on Rails
James Gray
 
All I want for Matz-mas
All I want for Matz-masAll I want for Matz-mas
All I want for Matz-mas
Andrew Grimm
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
chamomilla
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
guest5dedf5
 
Vim 讓你寫 Ruby 的速度飛起來
Vim 讓你寫 Ruby 的速度飛起來Vim 讓你寫 Ruby 的速度飛起來
Vim 讓你寫 Ruby 的速度飛起來
Chris Houng
 
Intro for RoR
Intro for RoRIntro for RoR
Intro for RoR
Vigneshwaran Seetharaman
 
Intro to Ruby on Rails: From Zero to Basics
Intro to Ruby on Rails: From Zero to BasicsIntro to Ruby on Rails: From Zero to Basics
Intro to Ruby on Rails: From Zero to Basics
Oppo16
 
Why hadoop map reduce needs scala, an introduction to scoobi and scalding
Why hadoop map reduce needs scala, an introduction to scoobi and scaldingWhy hadoop map reduce needs scala, an introduction to scoobi and scalding
Why hadoop map reduce needs scala, an introduction to scoobi and scalding
Xebia Nederland BV
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008
Brian Sam-Bodden
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
Felipe Schmitt
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Mark Menard
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
Mark Menard
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
Thomas Asikis
 
Optimizing for programmer happiness
Optimizing for programmer happinessOptimizing for programmer happiness
Optimizing for programmer happiness
Josh Schramm
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
Espen Brækken
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
Amit Patel
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on Rails
James Gray
 
All I want for Matz-mas
All I want for Matz-masAll I want for Matz-mas
All I want for Matz-mas
Andrew Grimm
 
Vim 讓你寫 Ruby 的速度飛起來
Vim 讓你寫 Ruby 的速度飛起來Vim 讓你寫 Ruby 的速度飛起來
Vim 讓你寫 Ruby 的速度飛起來
Chris Houng
 
Intro to Ruby on Rails: From Zero to Basics
Intro to Ruby on Rails: From Zero to BasicsIntro to Ruby on Rails: From Zero to Basics
Intro to Ruby on Rails: From Zero to Basics
Oppo16
 
Why hadoop map reduce needs scala, an introduction to scoobi and scalding
Why hadoop map reduce needs scala, an introduction to scoobi and scaldingWhy hadoop map reduce needs scala, an introduction to scoobi and scalding
Why hadoop map reduce needs scala, an introduction to scoobi and scalding
Xebia Nederland BV
 

Recently uploaded (20)

Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Ad

Introduction to Ruby & Modern Programming