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
Introduction to Ruby Programming Language
Search
Didik Wicaksono
August 26, 2017
Technology
2
210
Introduction to Ruby Programming Language
Created for For SARCCOM Indonesia meetup
Didik Wicaksono
August 26, 2017
Tweet
Share
More Decks by Didik Wicaksono
See All by Didik Wicaksono
CFP Advice for Global Diversity CFP Day 2019 Jakarta
did1k
0
61
Automate workflow with Ruby
did1k
0
88
Generating Multiple Dimension Icon Sprites for Retina Display
did1k
0
78
Cookpad Indonesia Technology Stack
did1k
1
290
Other Decks in Technology
See All in Technology
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
450
20241220_S3 tablesの使い方を検証してみた
handy
4
390
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
180
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
230
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
13
3.7k
UI State設計とテスト方針
rmakiyama
2
550
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
200
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
480
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
140
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Rails Girls Zürich Keynote
gr2m
94
13k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Building Adaptive Systems
keathley
38
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Unsuck your backbone
ammeep
669
57k
Site-Speed That Sticks
csswizardry
2
190
Statistics for Hackers
jakevdp
796
220k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Transcript
Ruby Programming Language
Didik Wicaksono CTO Cookpad Indonesia
Github: firewalker06 Twitter: did1k
I work in
Its where I learn to program with Ruby
The question is: Why Ruby?
Meet Matz
He invented Ruby in 1995
He designed Ruby to be human-oriented
Ruby syntax is designed to be elegant
print "elephant" if "elephant".include? "ant" "elephant"
print "elephant" if "elephant".include? "ant" You can speak this in
proper english: “Print an elephant if elephant include ant”
print "elephant" if "elephant".include? "ant" You can speak this in
proper english: “Print elephant if elephant include ant”
print "elephant" if "elephant".include? "ant" You can speak this in
proper english: “Print elephant if elephant include ant”
This sentence still doesn’t make any sense, but it is
readable You can speak this in proper english: “Print elephant if elephant include ant” print "elephant" if "elephant".include? "ant"
print "elephant" if "elephant".include? "ant" “if” can be used to
modify expression
print "elephant" if "elephant".include? "ant" “if” can be used to
modify expression Method name can have question mark
Writing Ruby code is easy because it can be written
in plain english
Programmer can express themselves into their code
movie.awesome? bedroom.with_twin_beds? recipe.cooked_under 10.minutes Programmer can express themselves into their
code
humans.obliterate!
humans.obliterate! unless humans.nice?
There are more than one way to do anything in
Ruby
false 2.negative? 2 < 0
"hello" puts "hello" $stdout.puts "hello" p "hello"
one = 1 two = 2 three = 3 one,
two, three = [1, 2, 3]
one = 1 two = 2 three = 3 one,
two, three = [1, 2, 3] one, two, three = 1, 2, 3 You don’t even need
[1, 2, 3, 4, 5].map { |element| element if element.even?
}.compact [2,4]
[1, 2, 3, 4, 5]. select { |element| element.even? }
[2,4]
[1, 2, 3, 4, 5].select(&:even?) [2,4]
Block arguments also makes Ruby popular
method do ... end method do |argument| ... end
%w(Google Yahoo MSN).map do |engine| "https://www.#{engine.downcase}.com" end ["https://www.google.com", "https://www.yahoo.com", "https://www.msn.com"]
Blocks allows us to attach closure to any method %w(Google
Yahoo MSN).map do |engine| "https://www.#{engine.downcase}.com" end this will be returned
Blocks allows us to attach closure to any method %w(Google
Yahoo MSN).map do |engine| "https://www.#{engine.downcase}.com" end this will be returned You don’t even need to write return
Almost forgot! %w(Google Yahoo MSN).map do |engine| "https://www.#{engine.downcase}.com" end Is
equal: ["Google", "Yahoo", "MSN"]
More Blocks
%w(jakarta bandung).map do |city| city.capitalize end
%w(jakarta bandung).map do |city| city.capitalize end ["Jakarta", "Bandung"]
%w(jakarta bandung).map(&:capitalize) ["Jakarta", "Bandung"]
[ ["jakarta", "province"], ["bandung", "city"] ].each do |name, type| puts
"#{name}_#{type}" end
"jakarta_province" "bandung_city" [ ["jakarta", "province"], ["bandung", "city"] ].each do |name,
type| puts "#{name}_#{type}" end
This kind of flexibility improves the joy of programming
You might notice that Ruby makes you write fewer codes
one = 1 two = 2 three = 3 one,
two, three = [1, 2, 3] one, two, three = 1, 2, 3 You don’t even need FLASHBACK!
[1, 2, 3, 4, 5].select(&:even?) [2,4] FLASHBACK!
Who doesn’t want to write less?
Have you tried programming with Ruby?
You might not noticed, but Mac users already have Ruby
(even though its outdated) Installation is pretty easy: https://www.ruby-lang.org/en/docum entation/installation/
It only takes 20 minutes to learn Ruby from this
page: https://www.ruby-lang.org/en/docu mentation/quickstart/
There is also tutorials in Bahasa Indonesia: https://www.idrails.com/
How about you try to learn together with fellow Rubyists?
Ruby community is known to be friendly (nice)
MINASWAN (Matz is nice and so we are nice) みなさん
(read: mina-san) translation: everyone (polite)
MINASWAN (Matz is nice and so we are nice) みなさん
(read: mina-san) translation: everyone (polite)
Friday Hug
None
None
In Indonesia, we are known as ID-Ruby We are active
on Slack and Telegram
In Indonesia, we are known as ID-Ruby We are active
on Slack and Telegram Feel free to join: http://ruby.id/slack and https://t.me/ruby_id
We held meetups regularly
We held meetups regularly
Ruby ecosystem is huge
More than 135,000 gems in rubygems.org
“Gems” are what we called as Ruby libraries
One of the most popular gem is Ruby on Rails
framework
It is said that Rails made Ruby gaining popularity in
2006
Its over 10 years, but Rails is still on demand!
https://infinum.co/the-capsized-eight/analyzing-rubygems-stats-v2016
Big companies that uses Ruby
• Github • Heroku • Airbnb • Shopify
How about in Indonesia?
• Bukalapak • Go-Jek • Midtrans • Vidio
Now you know!
List of Ruby companies in Indonesia can be seen in
ID-Ruby homepage!
None
Feel free to browse http://ruby.id !
How about?
Started using Rails on ver 1.2.3 with Ruby 1.8.7
Current Rails version is 5.1 with Ruby 2.4 Started using
Rails on ver 1.2.3 with Ruby 1.8.7 (2009!)
Previously we used ColdFusion
We have several large Rails applications running in Cookpad!
Our app servers run less than 100ms
If you are interested https://speakerdeck.com/mirakui/high-performance-rails-long-edition
If you are interested https://speakerdeck.com/a_matsuda/the-recip e-for-the-worlds-largest-rails-monolith
You can still be productive and run fast web application
with Ruby on Rails