Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Brief Ruby/Ruby on Rails intro
Search
Florian Plank
March 28, 2014
Programming
3
160
Brief Ruby/Ruby on Rails intro
Florian Plank
March 28, 2014
Tweet
Share
More Decks by Florian Plank
See All by Florian Plank
Ready, set, immersion!
polarblau
0
160
Prototyping all the things
polarblau
2
150
CoffeeScript vs. ECMAScript 6
polarblau
5
3.4k
Design for a complex Reality — Siili Breakfast Edition
polarblau
0
120
Enabling Design for a Complex Reality
polarblau
2
120
A primer on Content Security Policy
polarblau
1
360
Rails and the future of the open web
polarblau
3
110
Ruby Idioms
polarblau
3
550
How to ask questions and find the right answers
polarblau
2
330
Other Decks in Programming
See All in Programming
命名をリントする
chiroruxx
1
380
선언형 UI에서의 상태관리
l2hyunwoo
0
140
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
740
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
920
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
快速入門可觀測性
blueswen
0
320
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
Recoilを剥がしている話
kirik
5
6.6k
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
103 Early Hints
sugi_0000
1
220
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
137
6.7k
Adopting Sorbet at Scale
ufuk
73
9.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Agile that works and the tools we love
rasmusluckow
328
21k
Embracing the Ebb and Flow
colly
84
4.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
What's in a price? How to price your products and services
michaelherold
243
12k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
Transcript
RUBY A PROGRAMMER’S BEST FRIEND
Background
Yukihiro “Matz” Matsumoto
I hope to see Ruby help every programmer in the
world to be productive, and to enjoy programming, and to be happy. at is the primary purpose of Ruby language.” “
- Programmer happiness - Principle of least astonishment - Human
readable - Beautiful syntax Principles
- RubyGems, Bundler & Rake - Multiple implementations (MRI, JRuby,
Rubinius, mruby, MacRuby, Topaz, …) - Solid Standard Library Ecosystem
- MINASWAN - Self re ective - Open - Quirky
Community
The Language A Sales Pitch
None
Object–oriented 1
5.times { print "We love Ruby" }
class Animal def eat(food) puts "Animal eating" end end my_animal
= Animal.new animal.eat # => "Animal eating"
class Dog < Animal def eat(food) puts "Dog eating" super
end end
module Stomach def digest(food) # ... end end
class Dog < Animal include Stomach end my_dog = Dog.new
dog.digest
-199.abs # => 199 "Foobar".split("").uniq.sort.join # => "abFor" nil.class #
=> "NilClass"
Dynamically typed Duck–typing 2
if dog.is_a? Animal dog.eat end dog.eat if dog.respond_to?(:eat)
Monkey–patching (Duck–punching) 3
… if it walks like a duck and talks like
a duck, it’s a duck, right? So if this duck is not giving you the noise that you want, you’ve got to just punch that duck until it returns what you expect.” “
class String def yell "#{self.upcase}!" end end "hello".yell # =>
"HELLO!"
Meta–programming 4
class Greeter def method_missing(name, *args) name = name.to_s if name
=~ /^hello_/ puts "Hello, #{name.gsub(/^hello_/, '')}!" else super end end end Greeter.new.hello_john # => "Hello, john!"
Blocks & Lambdas 5
[1, 2, 3].map { |i| i ** 2 } #
=> [1, 4, 9]
def greet(&block) # ... greeting = yield("John") # ... end
greet do |name| "Hello, #{name}!" end
A word on speed
Ruby on Rails An (even shorter) sales pitch
None
- Open Source Web Framework - MVC - Convention over
Con guration - DRY - Opinionated Principles
- Generators - ORM - Restful routing - Included webserver
Features
$ gem install rails $ rails new blog $ cd
blog $ rails generate scaffold post title content:text $ rake db:migrate $ rails server
author = Author.find_by :name => "John" author.posts.first.title
Book.where(:title => 'Tale of Two Cities') .first_or_create
class Account < ActiveRecord::Base # Returns all accounts with unread
messages. def self.with_unread_messages joins(:messages).merge(Message.unread) end end
None