SlideShare une entreprise Scribd logo
1  sur  21
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!

Contenu connexe

Tendances

Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim Perlchinaguestcf9240
 
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 RubyJason 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 typesMark Godfrey
 
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/ProcessingDan 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 2019Brian Cardiff
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressAlena Holligan
 
Perl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaPerl.Hacks.On.Vim Perlchina
Perl.Hacks.On.Vim PerlchinaLin Yo-An
 
eJADA web development the Ruby way
eJADA web development the Ruby wayeJADA web development the Ruby way
eJADA web development the Ruby wayMustafah 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 KotlinMarco Vasapollo
 
Rails for PHP Developers
Rails for PHP DevelopersRails for PHP Developers
Rails for PHP DevelopersRobert Dempsey
 
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 TracerySarah Sexton
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkSarah Sexton
 

Tendances (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
 

En vedette

Profile p4property
Profile p4propertyProfile p4property
Profile p4propertyp4property
 
Heroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedHeroku Waza 2013 Lessons Learned
Heroku Waza 2013 Lessons LearnedSimon Bagreev
 
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 UnicornSimon 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 laterSimon Bagreev
 
Syamiah alfi reguler b
Syamiah alfi reguler bSyamiah alfi reguler b
Syamiah alfi reguler bSyamiah Alfi
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
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 Ortegaarman 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 20100506Vu Hung Nguyen
 
Ruby on Rails, a brief introduction
Ruby on Rails, a brief introductionRuby on Rails, a brief introduction
Ruby on Rails, a brief introductionroaldnel
 
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 2014Ken-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 uglytlv-ios-dev
 

En vedette (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
 

Similaire à 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 LispAstrails
 
[ “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 MomentSergio Gil
 
Go(lang) for the Rubyist
Go(lang) for the RubyistGo(lang) for the Rubyist
Go(lang) for the RubyistMark
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlinShem 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 minutesSumit Raj
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Wen-Tien Chang
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 

Similaire à 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
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 

Dernier

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

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

Notes de l'éditeur

  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.