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
Ruby 2.0 (en)
Search
Yukihiro Matsumoto
March 01, 2013
Technology
40
4.4k
Ruby 2.0 (en)
Ruby 2.0 at Waza 2013 (English version)
Yukihiro Matsumoto
March 01, 2013
Tweet
Share
More Decks by Yukihiro Matsumoto
See All by Yukihiro Matsumoto
Ruby 2.0
yukihiro_matz
24
4.6k
Reinventhing Wheels of Future
yukihiro_matz
56
5.5k
Other Decks in Technology
See All in Technology
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
140
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
340
Qiita埋め込み用スライド
naoki_0531
0
5.1k
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
200
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
490
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
750
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
240
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
2
110
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
32
6.3k
A designer walks into a library…
pauljervisheath
204
24k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Fireside Chat
paigeccino
34
3.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Transcript
Powered by Rabbit 1.0.4 Ruby 2.0 Chief Architect, Ruby @
Heroku @yukihiro_matz Yukihiro "Matz" Matsumoto
Powered by Rabbit 1.0.4 Ruby1.8 will die soon 1/143
Powered by Rabbit 1.0.4 Move to Ruby2.0 now 2/143
Powered by Rabbit 1.0.4 1.8.7 3/143
Powered by Rabbit 1.0.4 Rails tragedy 4/143
Powered by Rabbit 1.0.4 1.9.0 5/143
Powered by Rabbit 1.0.4 Compatibility tragedy 6/143
Powered by Rabbit 1.0.4 Ruby2.0 7/143
Powered by Rabbit 1.0.4 The happiest release ever 8/143
Powered by Rabbit 1.0.4 Faster 9/143
Powered by Rabbit 1.0.4 Better 10/143
Powered by Rabbit 1.0.4 `100% Compatible' 11/143
Powered by Rabbit 1.0.4 February 24 1993 12/143
Powered by Rabbit 1.0.4 I started developing Ruby 13/143
Powered by Rabbit 1.0.4 The date I named it
14/143
Powered by Rabbit 1.0.4 December 21 1995 15/143
Powered by Rabbit 1.0.4 I released it to public
(0.95) 16/143
Powered by Rabbit 1.0.4 Dec 1996 1.0 Aug 1997
1.1 Dec 1998 1.2 Aug 1999 1.4 Sep 2000 1.6 17/143
Powered by Rabbit 1.0.4 Aug 2003 1.8 Dec 2007
1.9.0 Aug 2010 1.9.2 Oct 2011 1.9.3 18/143
Powered by Rabbit 1.0.4 by courtesy of @a_matsuda 19/143
Powered by Rabbit 1.0.4 by courtesy of @a_matsuda 20/143
Powered by Rabbit 1.0.4 We released Ruby2.0 21/143
Powered by Rabbit 1.0.4 Finally 22/143
Powered by Rabbit 1.0.4 On Faburary 24th 2013 23/143
Powered by Rabbit 1.0.4 Ruby's 20th birthday 24/143
Powered by Rabbit 1.0.4 RubyConf2001 25/143
Powered by Rabbit 1.0.4 RubyConf2001 I mentioned Ruby2 26/143
Powered by Rabbit 1.0.4 RubyConf2001 new VM new GC native
thread embeddable API 27/143
Powered by Rabbit 1.0.4 RubyConf2001 I also mentioned psychological barrier
28/143
Powered by Rabbit 1.0.4 Version Numbers limited resource 29/143
Powered by Rabbit 1.0.4 Psychological Barrier 20 years anniversary 30/143
Powered by Rabbit 1.0.4 Psychological Barrier Anniversary Driven Development 31/143
Powered by Rabbit 1.0.4 Psychological Barrier ADD 32/143
Powered by Rabbit 1.0.4 RubyConf2001 new VM new GC native
thread embeddable API 33/143
Powered by Rabbit 1.0.4 new VM for performance 34/143
Powered by Rabbit 1.0.4 new VM Implemented by Ruby1.9 (YARV)
35/143
Powered by Rabbit 1.0.4 new GC GC performance 36/143
Powered by Rabbit 1.0.4 new GC Generatoinal GC 37/143
Powered by Rabbit 1.0.4 new GC Gave up 38/143
Powered by Rabbit 1.0.4 new GC Ruby1.9 improved GC 39/143
Powered by Rabbit 1.0.4 new GC Lazy Sweeping 40/143
Powered by Rabbit 1.0.4 new GC Bitmap marking (2.0) 41/143
Powered by Rabbit 1.0.4 native thread green thread til 1.8
42/143
Powered by Rabbit 1.0.4 native thread stack copying 43/143
Powered by Rabbit 1.0.4 native thread linking threading library problem
44/143
Powered by Rabbit 1.0.4 native thread Ruby1.9 uses native thread
45/143
Powered by Rabbit 1.0.4 native thread with GIL 46/143
Powered by Rabbit 1.0.4 native thread Giant Interpreter Lock 47/143
Powered by Rabbit 1.0.4 native thread thread safe core 48/143
Powered by Rabbit 1.0.4 native thread fine grained lock problem
49/143
Powered by Rabbit 1.0.4 native thread Compromise 50/143
Powered by Rabbit 1.0.4 embeddable API Gave up 51/143
Powered by Rabbit 1.0.4 embeddable API Compatibility matters 52/143
Powered by Rabbit 1.0.4 Ruby2 in 2001 53/143
Powered by Rabbit 1.0.4 Done in Ruby1.9 54/143
Powered by Rabbit 1.0.4 The origin of Ruby2.0 today
55/143
Powered by Rabbit 1.0.4 RubyConf2003 56/143
Powered by Rabbit 1.0.4 RubyConf2003 New Hash literals Keyword arguments
Method combination Selector namespace 57/143
Powered by Rabbit 1.0.4 New Hash literals {:foo => 1,
:bar => 2} as {foo: 1, bar: 2} 58/143
Powered by Rabbit 1.0.4 New Hash literals Done in 1.9
59/143
Powered by Rabbit 1.0.4 Method combination Allowing method decoration 60/143
Powered by Rabbit 1.0.4 Selector namespace Monkey patching with scope
61/143
Powered by Rabbit 1.0.4 New features in Ruby2.0 62/143
Powered by Rabbit 1.0.4 New features in 2.0 Keyword arguments
Module#prepend Enumerable#lazy Refinements 63/143
Powered by Rabbit 1.0.4 New features in 2.0 symbol array
literals to_h conversion method UTF-8 by default Dtrace / TracePoint 64/143
Powered by Rabbit 1.0.4 Keyword Arguments 65/143
Powered by Rabbit 1.0.4 Keyword Arguments Named optinal arguments No
specific order Descriptive Easy-to-remember 66/143
Powered by Rabbit 1.0.4 Keyword Arguments log("Hello!", level: "INFO") Possoble
in Ruby1.9 67/143
Powered by Rabbit 1.0.4 Keyword Arguments in 1.9 def log(msg,
opt = {}) level = opt[:level] || "ERROR" time = opt[:time] || Time.now puts "#{ time.ctime } [#{ level }] #{ msg }" end 68/143
Powered by Rabbit 1.0.4 Keyword Arguments in 1.9 What if
you want to combin with arbitrary number of arguments descriptive exceptions pass nil as a valid value 69/143
Powered by Rabbit 1.0.4 Keyword Arguments in 1.9 def log(*msgs)
opt = msgs.last.is_a?(Hash) ? msgs.pop : {} level = opt.key?(:level) ? opt.delete(:level) : "ERROR" time = opt.key?(:time) ? opt.delete(:time) : Time.now raise "unknown keyword: #{ opt.keys.first }" if !opt.empty? msgs.each {|msg| puts "#{ time.ctime } [#{ level }] #{ msg }" } end 70/143
Powered by Rabbit 1.0.4 Keyword Arguments in 2.0 def log(msg,
level: "ERROR", time: Time.now) puts "#{ time.ctime } [#{ level }] #{ msg }" end 71/143
Powered by Rabbit 1.0.4 Keyword Arguments in 2.0 Simpler More
descriptive API Easy to read Easy to write 72/143
Powered by Rabbit 1.0.4 Keyword Arguments in 2.0 log("Hello!", **opt)
You can pass existing hash as keyword arguments 73/143
Powered by Rabbit 1.0.4 Keyword Arguments in 2.0 def log(msg,
level: "ERROR", time: Time.now, **kw) puts "#{ time.ctime } [#{ level }] #{ msg }" end You can get keyword arguments as a hash Unkown keywords do not raise error 74/143
Powered by Rabbit 1.0.4 Keyword Arguments in 2.0 Summary Easy
API More descriptive Rails prefer keyword arguments 75/143
Powered by Rabbit 1.0.4 Module#prepend 76/143
Powered by Rabbit 1.0.4 Module#prepend Method combination Decrating existing methods
77/143
Powered by Rabbit 1.0.4 alias method chain Decorate existing methods
using aliases AcriveSupport 78/143
Powered by Rabbit 1.0.4 alias method chain class A def
foo; puts "foo"; end end class A # reopen def foo_with_bar foo_without_bar puts "bar" end alias_method_chain :foo, :bar end A.new.foo 79/143
Powered by Rabbit 1.0.4 alias method chain def alias_method_chain(target, feature)
alias_method "#{target}_without_#{feature}", target alias_method target, "#{target}_with_#{feature}" end 80/143
Powered by Rabbit 1.0.4 alias method chain problems many public
methods spilled out accidental feature name conflict adding same feature set to classes 81/143
Powered by Rabbit 1.0.4 Method combination from CLOS(CommonLisp Object System)
to extend existing methods confugurable via MOP 82/143
Powered by Rabbit 1.0.4 Method combination Standard combination in CLOS
before hook after hook around hook 83/143
Powered by Rabbit 1.0.4 Method combination Confugurable via MOP and-combination
or-combination whatever-combination 84/143
Powered by Rabbit 1.0.4 Method combination in CLOS Too complex
for Ruby 85/143
Powered by Rabbit 1.0.4 Module#prepend Simplified Method Comnbination 86/143
Powered by Rabbit 1.0.4 Module#prepend Methods added by #include comes
after exisiting methods #prepend put them before to wrap methods 87/143
Powered by Rabbit 1.0.4 Module#prepend class Foo def foo; p
:foo; end end module Prepend def foo p :before super p :after end end class Foo prepend Prepend end Foo.new.foo 88/143
Powered by Rabbit 1.0.4 Module#prepend Summary Extending exising methods No
method name conflict Package features in a module 89/143
Powered by Rabbit 1.0.4 Refinements 90/143
Powered by Rabbit 1.0.4 Refinements Scoped Monkey Patching 91/143
Powered by Rabbit 1.0.4 Monkey Patching Open class Reopen existing
class/module Adding methods Replacing methods 92/143
Powered by Rabbit 1.0.4 Adding methods ActiveSupport 93/143
Powered by Rabbit 1.0.4 Adding methods 20.years.ago # => Sun
Feb 28 17:32:42 94/143
Powered by Rabbit 1.0.4 Replacing methods mathn 95/143
Powered by Rabbit 1.0.4 Replacing methods 1 / 2 #=>
0 96/143
Powered by Rabbit 1.0.4 Replacing methods require 'mathn' 1 /
2 #=> 1/2 (Rational) 97/143
Powered by Rabbit 1.0.4 Open class is so strong
98/143
Powered by Rabbit 1.0.4 Any Problem? 99/143
Powered by Rabbit 1.0.4 Problems Name conflict Behavior conflict 100/143
Powered by Rabbit 1.0.4 Global modification is bad 101/143
Powered by Rabbit 1.0.4 Scoped enhancement Refinement 102/143
Powered by Rabbit 1.0.4 Refinements module R refine String do
def foo ... end end end "".foo # => error! using R "".foo 103/143
Powered by Rabbit 1.0.4 Other Languages Selector namespace (Smallscript) Classbox
(Smalltalk/Java) Extended Method (C#) 104/143
Powered by Rabbit 1.0.4 Selector namespace No one knows Smallscript
Smallscript still alive? Very complex 105/143
Powered by Rabbit 1.0.4 Classbox Scoped class modification Local rebinding
Dynamic scope 106/143
Powered by Rabbit 1.0.4 Extended Methods Can only add methods
No replacing 107/143
Powered by Rabbit 1.0.4 Enumerable#lazy 108/143
Powered by Rabbit 1.0.4 Enumerable#lazy for Lazy evaluation 109/143
Powered by Rabbit 1.0.4 Enumerable#lazy Inspired by functional programming 110/143
Powered by Rabbit 1.0.4 Enumerable#lazy Functional programming wannabe 111/143
Powered by Rabbit 1.0.4 Functional programming wannabe Immutable data Pattern
matching Lazy evaluation Function composition 112/143
Powered by Rabbit 1.0.4 Function composition sort of method chains
in Ruby 113/143
Powered by Rabbit 1.0.4 Method chains (1..Float::INFINITY).map {|i| i.to_s }.select{|s|
/3/ === s }.first(5) This doesn't work 114/143
Powered by Rabbit 1.0.4 Method chains If we had lazy
evaluation.. 115/143
Powered by Rabbit 1.0.4 Lazy evaluation What if we had
lazy version of enumerating methods 116/143
Powered by Rabbit 1.0.4 Lazy evaluation map_lz, select_lz 117/143
Powered by Rabbit 1.0.4 Method chains (1..Float::INFINITY).map_lz {|i| i.to_s }.select_lz{|s|
/3/ === s }.first(5) 118/143
Powered by Rabbit 1.0.4 Lazy evaluation Lazy people need lazy
evaluation 119/143
Powered by Rabbit 1.0.4 Lazy evaluation to lazy to add
_lz all the time 120/143
Powered by Rabbit 1.0.4 Enumerable#lazy (1..Float::INFINITY).lazy.map {|i| i.to_s }.select{|s| /3/
=== s }.first(5) 121/143
Powered by Rabbit 1.0.4 Enumerable#lazy Looks better 122/143
Powered by Rabbit 1.0.4 Symbol array literals 123/143
Powered by Rabbit 1.0.4 Symbol array literals %i(foo bar baz)
124/143
Powered by Rabbit 1.0.4 to_h conversion method 125/143
Powered by Rabbit 1.0.4 to_h conversion method Hash, ENV, Struct
to have to_h 126/143
Powered by Rabbit 1.0.4 to_i and to_int to_i for explicit
conversion to_int for implicit conversion 127/143
Powered by Rabbit 1.0.4 conversion methods to_i and to_int to_s
and to_str to_h and to_hash 128/143
Powered by Rabbit 1.0.4 UTF-8 by default 129/143
Powered by Rabbit 1.0.4 UTF-8 by default No magic comment
needed 130/143
Powered by Rabbit 1.0.4 UTF-8 by default Unicode everywhere now
131/143
Powered by Rabbit 1.0.4 Dtrace/TracePoint Better debug/profile support 132/143
Powered by Rabbit 1.0.4 Performance VM GC require 133/143
Powered by Rabbit 1.0.4 Ruby 2.0 134/143
Powered by Rabbit 1.0.4 Now works on Heroku 135/143
Powered by Rabbit 1.0.4 136/143
Powered by Rabbit 1.0.4 Ruby2.0 working under the platform 137/143
Powered by Rabbit 1.0.4 Ruby2.0 and beyond I have no
idea (yet) 138/143
Powered by Rabbit 1.0.4 Ruby2.1 We made a 2.1 branch
139/143
Powered by Rabbit 1.0.4 Ruby2.1 Coming next Christmas (hopefull) 140/143
Powered by Rabbit 1.0.4 Ruby2.1 less strict Unicode validation even
better perfomance 141/143
Powered by Rabbit 1.0.4 Thank you 142/143
Powered by Rabbit 1.0.4 Any Questions? 143/143