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
190
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
56
Automate workflow with Ruby
did1k
0
88
Generating Multiple Dimension Icon Sprites for Retina Display
did1k
0
77
Cookpad Indonesia Technology Stack
did1k
1
280
Other Decks in Technology
See All in Technology
フルカイテン株式会社 採用資料
fullkaiten
0
36k
「 SharePoint 難しい」ってよく聞くけど、そんなに言うなら8歳の息子に試してもらった
taichinakamura
1
620
CyberAgent 生成AI Deep Dive with Amazon Web Services / genai-aws
cyberagentdevelopers
PRO
1
480
生成AIの強みと弱みを理解して、生成AIがもたらすパワーをプロダクトの価値へ繋げるために実践したこと / advance-ai-generating
cyberagentdevelopers
PRO
1
180
ネット広告に未来はあるか?「3rd Party Cookie廃止とPrivacy Sandboxの効果検証の裏側」 / third-party-cookie-privacy
cyberagentdevelopers
PRO
1
130
【若手エンジニア応援LT会】AWSで繋がり、共に成長! ~コミュニティ活動と新人教育への挑戦~
kazushi_ohata
0
180
Amazon FSx for NetApp ONTAPを利用するにあたっての要件整理と設計のポイント
non97
1
160
小規模に始めるデータメッシュとデータガバナンスの実践
kimujun
3
590
Gradle: The Build System That Loves To Hate You
aurimas
2
150
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
130
pandasはPolarsに性能面で追いつき追い越せるのか
vaaaaanquish
4
4.6k
ユーザーの購買行動モデリングとその分析 / dsc-purchase-analysis
cyberagentdevelopers
PRO
2
100
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Writing Fast Ruby
sferik
626
61k
RailsConf 2023
tenderlove
29
880
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
A Tale of Four Properties
chriscoyier
156
23k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
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