SlideShare a Scribd company logo
Simon Bagreev
Twitter: @status_200
Github: semmin
Email: simon.bagreev@employmentguide.com
Programs must be written for people to read, and onlyPrograms must be written for people to read, and only
incidentally for machines to execute.incidentally for machines to execute.
Abelson and SussmanAbelson and Sussman
... We are the masters. They are the slaves.... We are the masters. They are the slaves.
Yukihiro Matsumoto, creator of RubyYukihiro Matsumoto, creator of Ruby
on people and machineson people and machines
Knowing Rails != Knowing Ruby
simple and efficient
duck-typed
functional
metaprogramming
module Fooinizer
def fooinize()
self.split(" ").map{|t| t + "foo"}.join(" ")
end
end
# String.send(:include, Fooinizer)
class String
include Fooinizer
end
puts "my nifty string".fooinize
# => myfoo niftyfoo stringfoo
If you quack like a duck, you must be a duckIf you quack like a duck, you must be a duck
def print_size(item)
puts "This item size is #{item.size}"
end
# String
item = "This is string"
print_size(item) # => This item size is 14
# Array
item = %w(This item is array)
print_size(item) # => This item size is 4
#File
item = File::Stat.new("efficiency.rb")
print_size(item) # => This item size is 229
# Integer
item = 5
print_size(item) # => This item size is 8
No mutable data (== no side effects)
No state (== no hidden state)
Once assigned, “variable” doesn‘t change its
value
Pure mathematical functions, i.e. f(x) == f(x)
always, no matter how many times you run it
x = x + 1x = x + 1
x - x = 1x - x = 1
0 = 10 = 1
Programmer has a choice between imperative and functionalProgrammer has a choice between imperative and functional
# Imperative
days = %w(Mon Tue Wed)
days << "Thu"
days += ["Fri", "Sat", "Sun"]
days # ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
# Functional
days = %w(Mon Tue Wed)
all_days = days + ["Thu"] + ["Fri", "Sat", "Sun"]
all_days # ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
Functions are first-class citizens (can be passed andFunctions are first-class citizens (can be passed and
returned as other values)returned as other values)
# Passing a function
hello_proc = proc { puts "hello world!"}
def some_method(&some_proc)
some_proc.call
end
some_method &hello_proc # => hello world!
# Returning a function
def greeting_builder(*args)
proc { puts "Hello #{args.join(" ")}!" }
end
new_greeting = greeting_builder("Nifty", "Functional", "Ruby")
new_greeting.call # => Hello Nifty Functional Ruby!
Recall FoonizerRecall Foonizer
module Fooinizer
def fooinize()
self.split(" ").map{|t| t + "foo"}.join(" ")
end
end
# String.send(:include, Fooinizer)
class String
include Fooinizer
end
puts "my nifty string".fooinize
# => myfoo niftyfoo stringfoo
Higher order functions: mapHigher order functions: map
Code that writes codeCode that writes code
# Classic
class Car
def make
@make
end
def make=(value)
@make=value
end
end
# Metaprogramming - method defines method
class Car
attr_accessor :make # defines getter and setter
end
# Add methods to Car at runtime
Car.class_eval %{ attr_accessor :year }
c = Car.new()
puts c.respond_to? :year # => true
Define a Class with methods from within another ClassDefine a Class with methods from within another Class
class Definer
def self.build_custom_class(class_name, *methods)
methods.each do |m|
class_eval %{ class ::#{class_name}
attr_accessor :#{m}
end }
end
end
end
Definer.build_custom_class("Foo", "bar", "baz")
f = Foo.new
puts f.methods # => bar bar= baz baz=...
Framework does things for youFramework does things for you
== awesome== awesome
Don’t Repeat YourselfDon’t Repeat Yourself
Convention Over ConfigurationConvention Over Configuration
Homebrew, XCodeHomebrew, XCode
DatabaseDatabase
Ruby Version Manager (RVM)Ruby Version Manager (RVM)
Ruby, RailsRuby, Rails
BundlerBundler
GitGit
Heroku ToolbeltHeroku Toolbelt
You are ready to build your first RailsYou are ready to build your first Rails
application!application!
ruby.railstutorial.org/ruby-on-rails-tutorial-bookruby.railstutorial.org/ruby-on-rails-tutorial-book
edgeguides.rubyonrails.orgedgeguides.rubyonrails.org
tryruby.orgtryruby.org
railsforzombies.orgrailsforzombies.org
railscasts.comrailscasts.com
github.com/rails/rails – rails source codegithub.com/rails/rails – rails source code
github.com/semmin/intro-to-ror-preso – thisgithub.com/semmin/intro-to-ror-preso – this
presentationpresentation
Arkin, McAnally, Ruby in Practice, Manning Publications, March 5, 2008Arkin, McAnally, Ruby in Practice, Manning Publications, March 5, 2008
Khell’s blog, khelll.com/blog/ruby/ruby-and-functional-programmingKhell’s blog, khelll.com/blog/ruby/ruby-and-functional-programming
Stuart, www.rubyinside.com/functional-programming-in-ruby-2713.htmlStuart, www.rubyinside.com/functional-programming-in-ruby-2713.html
Thank You!Thank You!

More Related Content

What's hot

Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
guestcf9240
 
Ruby Kaigi 2008 LT
Ruby Kaigi 2008 LTRuby Kaigi 2008 LT
Ruby Kaigi 2008 LT
Motohiro Takayama
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
Lin Yo-An
 
Rochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to RubyRochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to Ruby
Jason Morrison
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
Tomas Doran
 
Understanding our code with tests, schemas, and types
Understanding our code with tests, schemas, and typesUnderstanding our code with tests, schemas, and types
Understanding our code with tests, schemas, and types
Mark Godfrey
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
Dmitry Baranovskiy
 
Hacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/ProcessingHacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/Processing
Dan Chudnov
 
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Brian Cardiff
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPress
Alena Holligan
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
Lin Yo-An
 
eJADA web development the Ruby way
eJADA web development the Ruby wayeJADA web development the Ruby way
eJADA web development the Ruby way
Mustafah Elbanna
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
Peter Higgins
 
Bologna Developer Zone - About Kotlin
Bologna Developer Zone - About KotlinBologna Developer Zone - About Kotlin
Bologna Developer Zone - About Kotlin
Marco Vasapollo
 
Rails for PHP Developers
Rails for PHP DevelopersRails for PHP Developers
Rails for PHP Developers
Robert Dempsey
 
Ruby 101
Ruby 101Ruby 101
Ruby 101
Harisankar P S
 
Voyage by example
Voyage by exampleVoyage by example
Voyage by example
Esteban Lorenzano
 
Word Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TraceryWord Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with Tracery
Sarah Sexton
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot Framework
Sarah Sexton
 

What's hot (19)

Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
Ruby Kaigi 2008 LT
Ruby Kaigi 2008 LTRuby Kaigi 2008 LT
Ruby Kaigi 2008 LT
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
Rochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to RubyRochester on Rails: Introduction to Ruby
Rochester on Rails: Introduction to Ruby
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
 
Understanding our code with tests, schemas, and types
Understanding our code with tests, schemas, and typesUnderstanding our code with tests, schemas, and types
Understanding our code with tests, schemas, and types
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
Hacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/ProcessingHacker 101/102 - Introduction to Programming w/Processing
Hacker 101/102 - Introduction to Programming w/Processing
 
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPress
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchina
 
eJADA web development the Ruby way
eJADA web development the Ruby wayeJADA web development the Ruby way
eJADA web development the Ruby way
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
Bologna Developer Zone - About Kotlin
Bologna Developer Zone - About KotlinBologna Developer Zone - About Kotlin
Bologna Developer Zone - About Kotlin
 
Rails for PHP Developers
Rails for PHP DevelopersRails for PHP Developers
Rails for PHP Developers
 
Ruby 101
Ruby 101Ruby 101
Ruby 101
 
Voyage by example
Voyage by exampleVoyage by example
Voyage by example
 
Word Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TraceryWord Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with Tracery
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot Framework
 

Viewers also liked

Profile p4property
Profile p4propertyProfile p4property
Profile p4property
p4property
 
Syamiah alfi
Syamiah alfiSyamiah alfi
Syamiah alfi
Syamiah Alfi
 
Heroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedHeroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons Learned
Simon Bagreev
 
Fisdasoptik
FisdasoptikFisdasoptik
Fisdasoptik
Syamiah Alfi
 
WeCare Paper
WeCare PaperWeCare Paper
WeCare Paper
Andy Tseng
 
Energytransfer
EnergytransferEnergytransfer
Energytransfer
Syamiah Alfi
 
Fondo de ojo
Fondo de ojoFondo de ojo
Fondo de ojo
Adrian Valen'z
 
Improving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and UnicornImproving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and Unicorn
Simon Bagreev
 
Testing and Software Writer a year later
Testing and Software Writer a year laterTesting and Software Writer a year later
Testing and Software Writer a year later
Simon Bagreev
 
Imap presentation~ Sales Solutions for Aesthetic Staff
Imap presentation~ Sales Solutions for Aesthetic StaffImap presentation~ Sales Solutions for Aesthetic Staff
Imap presentation~ Sales Solutions for Aesthetic Staff
Patricia Heitz CIDESCO Diplomat
 
Syamiah alfi reguler b
Syamiah alfi reguler bSyamiah alfi reguler b
Syamiah alfi reguler b
Syamiah Alfi
 
Intro To Swift
Intro To SwiftIntro To Swift
Intro To Swift
Natasha Murashev
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
John Brunswick
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
Menno van der Sman
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
arman o
 
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
Vu Hung Nguyen
 
Ruby on Rails, a brief introduction
Ruby on Rails, a brief introductionRuby on Rails, a brief introduction
Ruby on Rails, a brief introduction
roaldnel
 
Ruby on Rails Introduction | FEU-EAC, February 2014
Ruby on Rails Introduction | FEU-EAC, February 2014Ruby on Rails Introduction | FEU-EAC, February 2014
Ruby on Rails Introduction | FEU-EAC, February 2014
Ken-Lauren Daganio
 
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the uglyUri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
tlv-ios-dev
 

Viewers also liked (19)

Profile p4property
Profile p4propertyProfile p4property
Profile p4property
 
Syamiah alfi
Syamiah alfiSyamiah alfi
Syamiah alfi
 
Heroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedHeroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons Learned
 
Fisdasoptik
FisdasoptikFisdasoptik
Fisdasoptik
 
WeCare Paper
WeCare PaperWeCare Paper
WeCare Paper
 
Energytransfer
EnergytransferEnergytransfer
Energytransfer
 
Fondo de ojo
Fondo de ojoFondo de ojo
Fondo de ojo
 
Improving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and UnicornImproving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and Unicorn
 
Testing and Software Writer a year later
Testing and Software Writer a year laterTesting and Software Writer a year later
Testing and Software Writer a year later
 
Imap presentation~ Sales Solutions for Aesthetic Staff
Imap presentation~ Sales Solutions for Aesthetic StaffImap presentation~ Sales Solutions for Aesthetic Staff
Imap presentation~ Sales Solutions for Aesthetic Staff
 
Syamiah alfi reguler b
Syamiah alfi reguler bSyamiah alfi reguler b
Syamiah alfi reguler b
 
Intro To Swift
Intro To SwiftIntro To Swift
Intro To Swift
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
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, a brief introduction
Ruby on Rails, a brief introductionRuby on Rails, a brief introduction
Ruby on Rails, a brief introduction
 
Ruby on Rails Introduction | FEU-EAC, February 2014
Ruby on Rails Introduction | FEU-EAC, February 2014Ruby on Rails Introduction | FEU-EAC, February 2014
Ruby on Rails Introduction | FEU-EAC, February 2014
 
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the uglyUri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
Uri Nachmias - Adopting Swift @Houzz - The good, the bad and the ugly
 

Similar to Introduction to Ruby, Rails, and Ruby on Rails

Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
Astrails
 
Go &lt;-> Ruby
Go &lt;-> RubyGo &lt;-> Ruby
Go &lt;-> Ruby
Eleanor McHugh
 
[ “Love", :Ruby ].each { |i| p i }
[ “Love", :Ruby ].each { |i| p i }[ “Love", :Ruby ].each { |i| p i }
[ “Love", :Ruby ].each { |i| p i }
Herval Freire
 
Five Languages in a Moment
Five Languages in a MomentFive Languages in a Moment
Five Languages in a Moment
Sergio Gil
 
Go(lang) for the Rubyist
Go(lang) for the RubyistGo(lang) for the Rubyist
Go(lang) for the Rubyist
Mark
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
Geeks Anonymes
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
Shem Magnezi
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
Wen-Tien Chang
 
Erlang
ErlangErlang
Elixir for rubysts
Elixir for rubystsElixir for rubysts
Elixir for rubysts
Danni Friedland
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
ppt7
ppt7ppt7
ppt7
callroom
 
ppt2
ppt2ppt2
ppt2
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt9
ppt9ppt9
ppt9
callroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
 
ppt18
ppt18ppt18
ppt18
callroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 
test ppt
test ppttest ppt
test ppt
callroom
 

Similar to Introduction to Ruby, Rails, and Ruby on Rails (20)

Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 
Go &lt;-> Ruby
Go &lt;-> RubyGo &lt;-> Ruby
Go &lt;-> Ruby
 
[ “Love", :Ruby ].each { |i| p i }
[ “Love", :Ruby ].each { |i| p i }[ “Love", :Ruby ].each { |i| p i }
[ “Love", :Ruby ].each { |i| p i }
 
Five Languages in a Moment
Five Languages in a MomentFive Languages in a Moment
Five Languages in a Moment
 
Go(lang) for the Rubyist
Go(lang) for the RubyistGo(lang) for the Rubyist
Go(lang) for the Rubyist
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
 
Erlang
ErlangErlang
Erlang
 
Elixir for rubysts
Elixir for rubystsElixir for rubysts
Elixir for rubysts
 
Python basic
Python basicPython basic
Python basic
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt9
ppt9ppt9
ppt9
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 
ppt18
ppt18ppt18
ppt18
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 

Recently uploaded

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 

Recently uploaded (20)

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 

Introduction to Ruby, Rails, and Ruby on Rails

  • 1. Simon Bagreev Twitter: @status_200 Github: semmin Email: simon.bagreev@employmentguide.com
  • 2. Programs must be written for people to read, and onlyPrograms must be written for people to read, and only incidentally for machines to execute.incidentally for machines to execute. Abelson and SussmanAbelson and Sussman ... We are the masters. They are the slaves.... We are the masters. They are the slaves. Yukihiro Matsumoto, creator of RubyYukihiro Matsumoto, creator of Ruby on people and machineson people and machines
  • 3. Knowing Rails != Knowing Ruby
  • 5. module Fooinizer def fooinize() self.split(" ").map{|t| t + "foo"}.join(" ") end end # String.send(:include, Fooinizer) class String include Fooinizer end puts "my nifty string".fooinize # => myfoo niftyfoo stringfoo
  • 6. If you quack like a duck, you must be a duckIf you quack like a duck, you must be a duck def print_size(item) puts "This item size is #{item.size}" end # String item = "This is string" print_size(item) # => This item size is 14 # Array item = %w(This item is array) print_size(item) # => This item size is 4 #File item = File::Stat.new("efficiency.rb") print_size(item) # => This item size is 229 # Integer item = 5 print_size(item) # => This item size is 8
  • 7. No mutable data (== no side effects) No state (== no hidden state) Once assigned, “variable” doesn‘t change its value Pure mathematical functions, i.e. f(x) == f(x) always, no matter how many times you run it
  • 8. x = x + 1x = x + 1 x - x = 1x - x = 1 0 = 10 = 1
  • 9. Programmer has a choice between imperative and functionalProgrammer has a choice between imperative and functional # Imperative days = %w(Mon Tue Wed) days << "Thu" days += ["Fri", "Sat", "Sun"] days # ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] # Functional days = %w(Mon Tue Wed) all_days = days + ["Thu"] + ["Fri", "Sat", "Sun"] all_days # ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
  • 10. Functions are first-class citizens (can be passed andFunctions are first-class citizens (can be passed and returned as other values)returned as other values) # Passing a function hello_proc = proc { puts "hello world!"} def some_method(&some_proc) some_proc.call end some_method &hello_proc # => hello world! # Returning a function def greeting_builder(*args) proc { puts "Hello #{args.join(" ")}!" } end new_greeting = greeting_builder("Nifty", "Functional", "Ruby") new_greeting.call # => Hello Nifty Functional Ruby!
  • 11. Recall FoonizerRecall Foonizer module Fooinizer def fooinize() self.split(" ").map{|t| t + "foo"}.join(" ") end end # String.send(:include, Fooinizer) class String include Fooinizer end puts "my nifty string".fooinize # => myfoo niftyfoo stringfoo Higher order functions: mapHigher order functions: map
  • 12. Code that writes codeCode that writes code # Classic class Car def make @make end def make=(value) @make=value end end # Metaprogramming - method defines method class Car attr_accessor :make # defines getter and setter end # Add methods to Car at runtime Car.class_eval %{ attr_accessor :year } c = Car.new() puts c.respond_to? :year # => true
  • 13. Define a Class with methods from within another ClassDefine a Class with methods from within another Class class Definer def self.build_custom_class(class_name, *methods) methods.each do |m| class_eval %{ class ::#{class_name} attr_accessor :#{m} end } end end end Definer.build_custom_class("Foo", "bar", "baz") f = Foo.new puts f.methods # => bar bar= baz baz=...
  • 14.
  • 15. Framework does things for youFramework does things for you == awesome== awesome
  • 16. Don’t Repeat YourselfDon’t Repeat Yourself Convention Over ConfigurationConvention Over Configuration
  • 17. Homebrew, XCodeHomebrew, XCode DatabaseDatabase Ruby Version Manager (RVM)Ruby Version Manager (RVM) Ruby, RailsRuby, Rails BundlerBundler GitGit Heroku ToolbeltHeroku Toolbelt
  • 18. You are ready to build your first RailsYou are ready to build your first Rails application!application!
  • 20. Arkin, McAnally, Ruby in Practice, Manning Publications, March 5, 2008Arkin, McAnally, Ruby in Practice, Manning Publications, March 5, 2008 Khell’s blog, khelll.com/blog/ruby/ruby-and-functional-programmingKhell’s blog, khelll.com/blog/ruby/ruby-and-functional-programming Stuart, www.rubyinside.com/functional-programming-in-ruby-2713.htmlStuart, www.rubyinside.com/functional-programming-in-ruby-2713.html

Editor's Notes

  1. Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state.