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.5k
Reinventhing Wheels of Future
yukihiro_matz
56
5.5k
Other Decks in Technology
See All in Technology
APIテスト自動化の勘所
yokawasa
7
4k
カメラを用いた店内計測におけるオプトインの仕組みの実現 / ai-optin-camera
cyberagentdevelopers
PRO
1
120
「 SharePoint 難しい」ってよく聞くけど、そんなに言うなら8歳の息子に試してもらった
taichinakamura
1
520
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
9
120k
20241031_AWS_生成AIハッカソン_GenMuck
tsumita
0
100
【LT】ソフトウェア産業は進化しているのか? -Javaの想い出とともに- #jjug_ccc
takabow
0
170
ガチ勢によるPipeCD運用大全〜滑らかなCI/CDを添えて〜 / ai-pipecd-encyclopedia
cyberagentdevelopers
PRO
3
190
生成AIの強みと弱みを理解して、生成AIがもたらすパワーをプロダクトの価値へ繋げるために実践したこと / advance-ai-generating
cyberagentdevelopers
PRO
1
170
CyberAgent 生成AI Deep Dive with Amazon Web Services / genai-aws
cyberagentdevelopers
PRO
1
470
クライアントサイドでよく使われる Debounce処理 をサーバサイドで3回実装した話
yoshiori
1
140
話題のGraphRAG、その可能性と課題を理解する
hide212131
4
1.4k
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
170
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
What's in a price? How to price your products and services
michaelherold
243
12k
Automating Front-end Workflow
addyosmani
1365
200k
Unsuck your backbone
ammeep
668
57k
Producing Creativity
orderedlist
PRO
341
39k
Rails Girls Zürich Keynote
gr2m
93
13k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.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