SlideShare a Scribd company logo
1 of 23
Ruby
Programming Language
Introduction
28 Jun 2015
Kwangshin Oh
kwangshin@gmail.com
http://kwangshin.pe.kr
Seven Languages in Seven Weeks
A Pragmatic
Guide to
Learning
Programming
Languages
By Bruce A. Tate
Why New Programming Language?
“Learning a new programming language will show you
new ways of thinking, and new approaches to problem solving
that will help you be a better programmer in any language.”
- Pragmatic Bookshelf
“Ultimately, programming is about understanding, and
understanding is about ideas. So, exposure to new ideas is essential
to a deeper understanding of what programming is all about.”
- Foreword By Joe Armstrong, creator of Erlang
Agenda
 Ruby is…
 History & Why?
 With a Spoonful of Sugar
 So, Ruby is…
 Ruby: Interpreted Language
 Ruby: Interpreted Language – Example
 Compare: Compiled Language - Java
 Ruby: Object-Oriented Language
 Ruby: Pure Object-Oriented Language
 Ruby: Dynamically Typed Language
 What is Duck Typing?
 Ruby: Duck Typing Code Example
 Download & Installation
 Ruby Code
 Reference
Ruby is…
 Programming Language!
Dynamic
Open Source
 Focus on…
Simplicity
Productivity
 Has an elegant syntax
Natural to read
Easy to write
Image Source: Ruby Programming Language
History & Why?
 Ruby’s Creator
Yukihiro “Matz” Matsumoto
 Created in about 1993
 Motivation
The primary motivation was to amuse himself!
Just a hobby at the beginning
New object-oriented language that combines
characteristics from Lisp, Smalltalk and Perl
To enhance programmers’ productivity
“Ruby is simple in appearance, but is very complex inside, just like our human body.”
- Matz, speaking on the Ruby-Talk mailing list, May 12th, 2000.
Image Source: Ruby Everywhere
With a Spoonful of Sugar
 Ruby with more syntactic sugar
Makes code easier to read and write
 Focus on the efficiency of the
programmers
“A spoonful of sugar makes the medicine go down.”
Mary Poppins
Image Source: Disney Wiki – A Spoonful of Sugar
So, Ruby is…
 Interpreted Language
Ruby code is executed by an interpreter
 Object-Oriented Language
Encapsulation
Inheritance
Polymorphism
 Dynamically Typed Language
Types are bound at execution time
Image Source: Skillcrush - Ruby
Interactive
Console
Ruby File
(*.rb)
Ruby: Interpreted Language
Image Source: http://www.iconsdb.com, http://dryicons.com and http://findicons.com
Ruby
Interpreter
Interactive
Console
Ruby File
(Ha.rb)
Ruby: Interpreted Language - Example
D:Ruby22bin>type Ha.rb
3.Times do
print “Ha “
end
D:Ruby22bin>ruby Ha.rb
Ha Ha Ha
D:Ruby22bin>
D:Ruby22bin>ruby
3.Times do
print “Ha “
end
^D
Ha Ha Ha
D:Ruby22bin>
Compare: Compiled Language - Java
Java Source File
(*.java)
Java
Compiler
Java Class File
(*.class)
JRE
(Java Runtime Environment)
Ruby: Object-Oriented Language
 Encapsulation
[State & Behavior] : Packaged together
 Inheritance
[Class Tree] : Object types are organized
 Polymorphism
[Many Forms]
: Objects can be shown
Image Source: What Is an Object?
Image Source: What Is Inheritance?Image Source: Object-Oriented Concepts
Ruby: Pure Object-Oriented Language
 Ruby Programming Language
Everything is an object!
 Compare: Java Programming Language
Primitive types (int, char, ……) are not objects!
D:Ruby22bin>irb
irb(main):001:0> 4
=> 4
irb(main):002:0> 4.class
=> Fixnum
irb(main):003:0> 4 + 4
=> 8
irb(main):004:0> 4.methods
=> [:to_s, :inspect, :-
@, :+, ∙∙∙∙∙∙, :__id__]
irb(main):005:0>
Ruby: Dynamically Typed Language
Types are bound
at execution time
Flexibility
Execution Safety
 Types are bound
at compile time
 Flexibility
 Execution Safety
Dynamically Typed
Statically Typed
Java
What is Duck Typing?
Quacks
like a duck
Swims
like a duck
Walks
like a duck
Call it
a duck
“When I see a bird that walks like a duck and
swims like a duck and quacks like a duck,
I call that bird a duck.” - James Whitcomb Riley
Image Source: https://www.iconfinder.com and http://www.vectors4all.net/
Ruby: Duck Typing Code Example
D:Ruby22bin>irb
irb(main):001:0> i = 0
=> 0
irb(main):002:0> a = ['100', 100.0]
=> ["100", 100.0]
irb(main):003:0> while i < 2
irb(main):004:1> puts a[i].to_i
irb(main):005:1> i = i + 1
irb(main):006:1> end
100
100
=> nil
irb(main):007:0>
We consider this to_i method as quack!
Duck typing doesn’t care
what the underlying type might be
(whether string or float).
string
float
Download & Installation
 Current Stable Version
 Ruby 2.2.2 (As of 28 Jun 2015)
 Windows
 RubyInstaller - http://rubyinstaller.org/downloads/
 OS X
 Homebrew - http://brew.sh/
 Debian GNU/Linux and Ubuntu
 apt – command : $ sudo apt-get install ruby-full
 CentOS, Fedora, and RHEL
 yum – command :$ sudo yum install ruby
Ruby: Sample Code
D:Ruby22bin>ruby
properties = ['object oriented', 'duck typed', 'productive', 'fun']
properties.each {|property| puts "Ruby is #{property}."}
^D
Ruby is object oriented.
Ruby is duck typed.
Ruby is productive.
Ruby is fun.
D:Ruby22bin>
Ruby Code: Hello World!
D:Ruby22bin>irb
irb(main):001:0> puts 'Hello World!'
Hello World!
=> nil
irb(main):002:0> language = 'Ruby'
=> "Ruby"
irb(main):003:0> puts "Hello, #{language}"
Hello, Ruby
=> nil
irb(main):004:0> language = 'my Ruby'
=> "my Ruby"
irb(main):005:0> puts "Hello, #{language}"
Hello, my Ruby
=> nil
irb(main):006:0>
Ruby’s Interactive Console
<One Quote String>
Interpreted Literally
<Two Quotes String>
String Evaluation
Ruby Code: Comparison Operators
D:Ruby22bin>irb
irb(main):001:0> x = 4
=> 4
irb(main):002:0> x < 5
=> true
irb(main):003:0> x > 4
=> false
irb(main):004:0> false.class
=> FalseClass
irb(main):005:0> true.class
=> TrueClass
irb(main):006:0> puts 'X value is equal to 4.' if x == 4
X value is equal to 4.
=> nil
irb(main):007:0>
Everything is an object
in Ruby!
Ruby Code: Loops – until & while
D:Ruby22bin>irb
irb(main):001:0> x = 5
=> 5
irb(main):002:0> x = x - 1 until x == 1
=> nil
irb(main):003:0> x
=> 1
irb(main):004:0> while x < 5
irb(main):005:1> x = x + 1
irb(main):006:1> puts x
irb(main):007:1> end
2
3
4
5
=> nil
Ruby Code: Expressions - true & false
D:Ruby22bin>irb
irb(main):001:0> puts '1 is true in Ruby' if 1
1 is true in Ruby
=> nil
irb(main):002:0> puts 'String is true in Ruby' if 'Kwangshin Oh'
(irb):2: warning: string literal in condition
String is true in Ruby
=> nil
irb(main):003:0> puts '0 is also true in Ruby' if 0
0 is also true in Ruby
=> nil
irb(main):004:0> puts 'The false is false in Ruby' if false
=> nil
irb(main):005:0> puts 'The nil is false in Ruby' if nil
=> nil
irb(main):006:0>
Everything
( but nil and false )
evaluate to true!
Reference
 Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Language
by Bruce A. Tate
 https://pragprog.com/book/btlang/seven-languages-in-seven-weeks
 Ruby Programming Language
 https://www.ruby-lang.org/
 Ruby-Talk mailing list, May 12th, 2000
 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/2773
 Disney Wiki – A Spoonful of Sugar
 http://disney.wikia.com/wiki/A_Spoonful_of_Sugar
 Matzにっき (Matz Diary)
 http://www.rubyist.net/~matz/
 The Java™ Tutorials - Object-Oriented Programming Concepts
 https://docs.oracle.com/javase/tutorial/java/concepts/index.html
 Duck typing
 https://en.wikipedia.org/wiki/Duck_typing

More Related Content

What's hot

ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern JavascriptES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern JavascriptWojciech Dzikowski
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6Rob Eisenberg
 
Handle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | EdurekaHandle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | EdurekaEdureka!
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .paradisetechsoftsolutions
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
Node JS reverse shell
Node JS reverse shellNode JS reverse shell
Node JS reverse shellMadhu Akula
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingHaim Michael
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance CenterMartin Spier
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAMehak Tawakley
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 
Recon and Bug Bounties - What a great love story!
Recon and Bug Bounties - What a great love story!Recon and Bug Bounties - What a great love story!
Recon and Bug Bounties - What a great love story!Abhijeth D
 
Java Presentation
Java PresentationJava Presentation
Java Presentationaitrichtech
 

What's hot (20)

ES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern JavascriptES2015 / ES6: Basics of modern Javascript
ES2015 / ES6: Basics of modern Javascript
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Handle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | EdurekaHandle Exceptions in Selenium Webdriver | Edureka
Handle Exceptions in Selenium Webdriver | Edureka
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Node JS reverse shell
Node JS reverse shellNode JS reverse shell
Node JS reverse shell
 
React js
React jsReact js
React js
 
XSS
XSSXSS
XSS
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript Programming
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance Center
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Recon and Bug Bounties - What a great love story!
Recon and Bug Bounties - What a great love story!Recon and Bug Bounties - What a great love story!
Recon and Bug Bounties - What a great love story!
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 

Viewers also liked

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyRanjith Siji
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails PresentationJoost Hietbrink
 
Vaporware To Awesome
Vaporware To AwesomeVaporware To Awesome
Vaporware To AwesomeYehuda Katz
 
Feeling Objects: Pattern Matching in Ruby
Feeling Objects: Pattern Matching in RubyFeeling Objects: Pattern Matching in Ruby
Feeling Objects: Pattern Matching in RubyRyan Levick
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Rubykim.mens
 
Lemme tell ya 'bout Ruby
Lemme tell ya 'bout RubyLemme tell ya 'bout Ruby
Lemme tell ya 'bout RubyArvin Jenabi
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming IntroductionAnthony Brown
 
핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신Kwangshin Oh
 
Sapphire Presentation for Review_CPG_Food.PPTX
Sapphire Presentation for Review_CPG_Food.PPTXSapphire Presentation for Review_CPG_Food.PPTX
Sapphire Presentation for Review_CPG_Food.PPTXJohn V. Counts Sr.
 
Pure Function and Rx
Pure Function and RxPure Function and Rx
Pure Function and RxHyungho Ko
 
Akka Fault Tolerance
Akka Fault ToleranceAkka Fault Tolerance
Akka Fault ToleranceHyungho Ko
 
[Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아![Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아!Arawn Park
 
Sapphire Presentation
Sapphire PresentationSapphire Presentation
Sapphire Presentationusama17
 
Web Development Ppt
Web Development PptWeb Development Ppt
Web Development PptBruce Tucker
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJSKyung Yeol Kim
 
java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰Sungchul Park
 

Viewers also liked (20)

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
Vaporware To Awesome
Vaporware To AwesomeVaporware To Awesome
Vaporware To Awesome
 
Feeling Objects: Pattern Matching in Ruby
Feeling Objects: Pattern Matching in RubyFeeling Objects: Pattern Matching in Ruby
Feeling Objects: Pattern Matching in Ruby
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Ruby
 
Lemme tell ya 'bout Ruby
Lemme tell ya 'bout RubyLemme tell ya 'bout Ruby
Lemme tell ya 'bout Ruby
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming Introduction
 
핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신
 
Ruby Egison
Ruby EgisonRuby Egison
Ruby Egison
 
Why Ruby
Why RubyWhy Ruby
Why Ruby
 
Sapphire Presentation for Review_CPG_Food.PPTX
Sapphire Presentation for Review_CPG_Food.PPTXSapphire Presentation for Review_CPG_Food.PPTX
Sapphire Presentation for Review_CPG_Food.PPTX
 
Pure Function and Rx
Pure Function and RxPure Function and Rx
Pure Function and Rx
 
Akka Fault Tolerance
Akka Fault ToleranceAkka Fault Tolerance
Akka Fault Tolerance
 
[Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아![Spring Camp 2013] Java Configuration 없인 못살아!
[Spring Camp 2013] Java Configuration 없인 못살아!
 
Sapphire Presentation
Sapphire PresentationSapphire Presentation
Sapphire Presentation
 
Web Development Ppt
Web Development PptWeb Development Ppt
Web Development Ppt
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰java 8 람다식 소개와 의미 고찰
java 8 람다식 소개와 의미 고찰
 
Introducing Ruby
Introducing RubyIntroducing Ruby
Introducing Ruby
 

Similar to Ruby Programming Language - Introduction

Spoiling The Youth With Ruby (Euruko 2010)
Spoiling The Youth With Ruby (Euruko 2010)Spoiling The Youth With Ruby (Euruko 2010)
Spoiling The Youth With Ruby (Euruko 2010)Karel Minarik
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Rormyuser
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHiroshi SHIBATA
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 
An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsvinicorp
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506Vu Hung Nguyen
 
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan  Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan edthix
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorialknoppix
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An IntroductionShrinivasan T
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml MappingMarc Seeger
 
Why everyone like ruby
Why everyone like rubyWhy everyone like ruby
Why everyone like rubyIvan Grishaev
 

Similar to Ruby Programming Language - Introduction (20)

IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
Spoiling The Youth With Ruby (Euruko 2010)
Spoiling The Youth With Ruby (Euruko 2010)Spoiling The Youth With Ruby (Euruko 2010)
Spoiling The Youth With Ruby (Euruko 2010)
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Ruby Presentation - Beamer
Ruby Presentation - BeamerRuby Presentation - Beamer
Ruby Presentation - Beamer
 
An introduction-to-ruby-on-rails
An introduction-to-ruby-on-railsAn introduction-to-ruby-on-rails
An introduction-to-ruby-on-rails
 
An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506An Introduction to Ruby on Rails 20100506
An Introduction to Ruby on Rails 20100506
 
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan  Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
Ruby on Rails - Pengenalan kepada “permata” dalam pengaturcaraan
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Ruby An Introduction
Ruby An IntroductionRuby An Introduction
Ruby An Introduction
 
Ruby.new @ VilniusRB
Ruby.new @ VilniusRBRuby.new @ VilniusRB
Ruby.new @ VilniusRB
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml Mapping
 
Ruby
RubyRuby
Ruby
 
Why everyone like ruby
Why everyone like rubyWhy everyone like ruby
Why everyone like ruby
 

More from Kwangshin Oh

CS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsCS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsKwangshin Oh
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsKwangshin Oh
 
CS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsCS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsKwangshin Oh
 
CS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryCS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryKwangshin Oh
 
Jini Network Technology
Jini Network TechnologyJini Network Technology
Jini Network TechnologyKwangshin Oh
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming ConceptsKwangshin Oh
 

More from Kwangshin Oh (6)

CS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsCS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design Patterns
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
 
CS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsCS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary Translators
 
CS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryCS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile Industry
 
Jini Network Technology
Jini Network TechnologyJini Network Technology
Jini Network Technology
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 

Recently uploaded

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

Ruby Programming Language - Introduction

  • 1. Ruby Programming Language Introduction 28 Jun 2015 Kwangshin Oh kwangshin@gmail.com http://kwangshin.pe.kr
  • 2. Seven Languages in Seven Weeks A Pragmatic Guide to Learning Programming Languages By Bruce A. Tate
  • 3. Why New Programming Language? “Learning a new programming language will show you new ways of thinking, and new approaches to problem solving that will help you be a better programmer in any language.” - Pragmatic Bookshelf “Ultimately, programming is about understanding, and understanding is about ideas. So, exposure to new ideas is essential to a deeper understanding of what programming is all about.” - Foreword By Joe Armstrong, creator of Erlang
  • 4. Agenda  Ruby is…  History & Why?  With a Spoonful of Sugar  So, Ruby is…  Ruby: Interpreted Language  Ruby: Interpreted Language – Example  Compare: Compiled Language - Java  Ruby: Object-Oriented Language  Ruby: Pure Object-Oriented Language  Ruby: Dynamically Typed Language  What is Duck Typing?  Ruby: Duck Typing Code Example  Download & Installation  Ruby Code  Reference
  • 5. Ruby is…  Programming Language! Dynamic Open Source  Focus on… Simplicity Productivity  Has an elegant syntax Natural to read Easy to write Image Source: Ruby Programming Language
  • 6. History & Why?  Ruby’s Creator Yukihiro “Matz” Matsumoto  Created in about 1993  Motivation The primary motivation was to amuse himself! Just a hobby at the beginning New object-oriented language that combines characteristics from Lisp, Smalltalk and Perl To enhance programmers’ productivity “Ruby is simple in appearance, but is very complex inside, just like our human body.” - Matz, speaking on the Ruby-Talk mailing list, May 12th, 2000. Image Source: Ruby Everywhere
  • 7. With a Spoonful of Sugar  Ruby with more syntactic sugar Makes code easier to read and write  Focus on the efficiency of the programmers “A spoonful of sugar makes the medicine go down.” Mary Poppins Image Source: Disney Wiki – A Spoonful of Sugar
  • 8. So, Ruby is…  Interpreted Language Ruby code is executed by an interpreter  Object-Oriented Language Encapsulation Inheritance Polymorphism  Dynamically Typed Language Types are bound at execution time Image Source: Skillcrush - Ruby
  • 9. Interactive Console Ruby File (*.rb) Ruby: Interpreted Language Image Source: http://www.iconsdb.com, http://dryicons.com and http://findicons.com Ruby Interpreter
  • 10. Interactive Console Ruby File (Ha.rb) Ruby: Interpreted Language - Example D:Ruby22bin>type Ha.rb 3.Times do print “Ha “ end D:Ruby22bin>ruby Ha.rb Ha Ha Ha D:Ruby22bin> D:Ruby22bin>ruby 3.Times do print “Ha “ end ^D Ha Ha Ha D:Ruby22bin>
  • 11. Compare: Compiled Language - Java Java Source File (*.java) Java Compiler Java Class File (*.class) JRE (Java Runtime Environment)
  • 12. Ruby: Object-Oriented Language  Encapsulation [State & Behavior] : Packaged together  Inheritance [Class Tree] : Object types are organized  Polymorphism [Many Forms] : Objects can be shown Image Source: What Is an Object? Image Source: What Is Inheritance?Image Source: Object-Oriented Concepts
  • 13. Ruby: Pure Object-Oriented Language  Ruby Programming Language Everything is an object!  Compare: Java Programming Language Primitive types (int, char, ……) are not objects! D:Ruby22bin>irb irb(main):001:0> 4 => 4 irb(main):002:0> 4.class => Fixnum irb(main):003:0> 4 + 4 => 8 irb(main):004:0> 4.methods => [:to_s, :inspect, :- @, :+, ∙∙∙∙∙∙, :__id__] irb(main):005:0>
  • 14. Ruby: Dynamically Typed Language Types are bound at execution time Flexibility Execution Safety  Types are bound at compile time  Flexibility  Execution Safety Dynamically Typed Statically Typed Java
  • 15. What is Duck Typing? Quacks like a duck Swims like a duck Walks like a duck Call it a duck “When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck.” - James Whitcomb Riley Image Source: https://www.iconfinder.com and http://www.vectors4all.net/
  • 16. Ruby: Duck Typing Code Example D:Ruby22bin>irb irb(main):001:0> i = 0 => 0 irb(main):002:0> a = ['100', 100.0] => ["100", 100.0] irb(main):003:0> while i < 2 irb(main):004:1> puts a[i].to_i irb(main):005:1> i = i + 1 irb(main):006:1> end 100 100 => nil irb(main):007:0> We consider this to_i method as quack! Duck typing doesn’t care what the underlying type might be (whether string or float). string float
  • 17. Download & Installation  Current Stable Version  Ruby 2.2.2 (As of 28 Jun 2015)  Windows  RubyInstaller - http://rubyinstaller.org/downloads/  OS X  Homebrew - http://brew.sh/  Debian GNU/Linux and Ubuntu  apt – command : $ sudo apt-get install ruby-full  CentOS, Fedora, and RHEL  yum – command :$ sudo yum install ruby
  • 18. Ruby: Sample Code D:Ruby22bin>ruby properties = ['object oriented', 'duck typed', 'productive', 'fun'] properties.each {|property| puts "Ruby is #{property}."} ^D Ruby is object oriented. Ruby is duck typed. Ruby is productive. Ruby is fun. D:Ruby22bin>
  • 19. Ruby Code: Hello World! D:Ruby22bin>irb irb(main):001:0> puts 'Hello World!' Hello World! => nil irb(main):002:0> language = 'Ruby' => "Ruby" irb(main):003:0> puts "Hello, #{language}" Hello, Ruby => nil irb(main):004:0> language = 'my Ruby' => "my Ruby" irb(main):005:0> puts "Hello, #{language}" Hello, my Ruby => nil irb(main):006:0> Ruby’s Interactive Console <One Quote String> Interpreted Literally <Two Quotes String> String Evaluation
  • 20. Ruby Code: Comparison Operators D:Ruby22bin>irb irb(main):001:0> x = 4 => 4 irb(main):002:0> x < 5 => true irb(main):003:0> x > 4 => false irb(main):004:0> false.class => FalseClass irb(main):005:0> true.class => TrueClass irb(main):006:0> puts 'X value is equal to 4.' if x == 4 X value is equal to 4. => nil irb(main):007:0> Everything is an object in Ruby!
  • 21. Ruby Code: Loops – until & while D:Ruby22bin>irb irb(main):001:0> x = 5 => 5 irb(main):002:0> x = x - 1 until x == 1 => nil irb(main):003:0> x => 1 irb(main):004:0> while x < 5 irb(main):005:1> x = x + 1 irb(main):006:1> puts x irb(main):007:1> end 2 3 4 5 => nil
  • 22. Ruby Code: Expressions - true & false D:Ruby22bin>irb irb(main):001:0> puts '1 is true in Ruby' if 1 1 is true in Ruby => nil irb(main):002:0> puts 'String is true in Ruby' if 'Kwangshin Oh' (irb):2: warning: string literal in condition String is true in Ruby => nil irb(main):003:0> puts '0 is also true in Ruby' if 0 0 is also true in Ruby => nil irb(main):004:0> puts 'The false is false in Ruby' if false => nil irb(main):005:0> puts 'The nil is false in Ruby' if nil => nil irb(main):006:0> Everything ( but nil and false ) evaluate to true!
  • 23. Reference  Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Language by Bruce A. Tate  https://pragprog.com/book/btlang/seven-languages-in-seven-weeks  Ruby Programming Language  https://www.ruby-lang.org/  Ruby-Talk mailing list, May 12th, 2000  http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/2773  Disney Wiki – A Spoonful of Sugar  http://disney.wikia.com/wiki/A_Spoonful_of_Sugar  Matzにっき (Matz Diary)  http://www.rubyist.net/~matz/  The Java™ Tutorials - Object-Oriented Programming Concepts  https://docs.oracle.com/javase/tutorial/java/concepts/index.html  Duck typing  https://en.wikipedia.org/wiki/Duck_typing