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
A Practitioner's Journey from Ruby 1.8 to Present
Search
Koichi ITO
September 09, 2023
Programming
1
2k
A Practitioner's Journey from Ruby 1.8 to Present
大阪Ruby会議03 (
https://regional.rubykaigi.org/osaka03/
)
Koichi ITO
September 09, 2023
Tweet
Share
More Decks by Koichi ITO
See All by Koichi ITO
Carving the Way to Ruby Engineering
koic
3
440
Beyond the RuboCop Defaults
koic
3
3k
Minify Ruby Code
koic
2
2.2k
Permanent Agility
koic
37
7.7k
RuboCop: LSP and Prism
koic
3
4.2k
Organizational Pattern Hatching
koic
0
1.5k
A Story Featuring Right Hand Archetype
koic
0
1.1k
Without Practice, No Emergence
koic
4
2.4k
The Resurrection of the Fast Parallel Test Runner
koic
1
6.2k
Other Decks in Programming
See All in Programming
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
선언형 UI에서의 상태관리
l2hyunwoo
0
150
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
710
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
CSC305 Lecture 26
javiergs
PRO
0
140
talk-with-local-llm-with-web-streams-api
kbaba1001
0
180
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
1
150
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Writing Fast Ruby
sferik
628
61k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Applications with DynamoDB
mza
91
6.1k
KATA
mclloyd
29
14k
GitHub's CSS Performance
jonrohan
1030
460k
Building Adaptive Systems
keathley
38
2.3k
Why Our Code Smells
bkeepers
PRO
335
57k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Transcript
,PJDIJ*50&4. *OD A Practitioner's Journey from Ruby 1.8 to Present
Have you been able to craft your job to be fun? େࡕ3VCZձٞ 4BU ϋʔτϯϗςϧ৺ࡈڮদ෩ϗʔϧ
@koic w044ϓϩάϥϚʔ w3VCP$PQίΞνʔϜ wגࣜձࣾӬγεςϜϚωδϝϯτ &4. *OD ΤϯδχΞϦϯάϚωʔδϟʔ݉ σΟεςΟϯάΠογϡυΤϯδχΞ
w ʰΦϒδΣΫτࢦεΫϦϓτݴޠ3VCZʱ ͕ڭຊɻʰσεΫτοϓϦϑΝϨϯεʱΛ ࣋ͪา͍ͯ௨ۈͯͨ͠ɻ 3VCZͱࢲ
None
େࡕ3VCZձٞͷ&4.ϝϯόʔ 4 Q FBLFS @junk0612 4 Q FBLFS @koic -5
@maimux2x 4 UB f @haruguchiyuma " UUFOEFF @fugakkbn " UUFOEFF @nsgc " UUFOEFF @kakutani ϑΣϩʔ
w ຊ3VCZΧϯϑΝϨϯε͔Βࠓͷ 3VCZ,BJHJ·Ͱͯ͢εϙϯαʔͯ͠Δ ੈք།Ұͷاۀ ެืͷͳ͍ আ͘ w 3VCZ,BJHJ
-5 -5 ొஃഐग़ w ຊࠃͰ34QFDͱ)BNMॳظͷಋೖاۀ 3VCZͱ&4. *OD
044ίϛϡχςΟͱͷڞੜΛࢧԉ 3BJMT044ύονձ #esm_oss
w !KVOL-SBNBίϯτϦϏϡʔλʔ w !4)QBSTFZίϯτϦϏϡʔλʔ w !LPJD1BSTFSHFNίϛολʔ w !JNB[VNJ*3#ίϛολʔ w !GVHBLLCO3#4ίϯτϦϏϡʔλʔ
ߏจղੳثݚڀ෦ IUUQTNBHB[JOFSVCZJTUOFUBSUJDMFT'PMMPX6Q,JSJTIJNB3VCZIUNM /&8
w3VCZͱΞδϟΠϧιϑτ ΣΞ։ൃΛ௨ͯ͡ίϛϡ χςΟͱ͍ͨ͠ਓ wຊશࠃ͔Βઈࢍืूத ΤϯδχΞืूத ͜Εɺωλ͡Όͳ͍Ͱ͔͢ΒͶʁ 🗾
3VCZ͔࣌Βݱࡏͷ࠷৽։ൃ൛Ͱ͋Δ 3VCZ·Ͱɺ3VCZͷόʔδϣϯΞοϓʹ ΑͬͯͲͷΑ͏ͳΠϕϯτ͕͋Γɺ࣌ͷ ࣄͰͷΞϓϦέʔγϣϯ։ൃ͋Δ͍044 ΤίγεςϜͰͲͷΑ͏ͳग़དྷࣄίʔυ ͷมֵ͕͔͋ͬͨԹނ৽Λ͓͠͠·͢ɻ ࠓͷ $'1ఏग़֓ཁΑΓ
ྺ࢙
#FGPSF3BJMT
w ຊ൪ϥϯλΠϜʹ3VCZ͕ೖ͍ͬͯͳ͍ w ։ൃڥͰ͋Ε3VCZΛΠϯείͰ͖Δ w +BWBͩͱෳछͷ+&&αʔόʔʹσϓϩΠ͢Δ &"3ϑΝΠϧͷBQQMJDBUJPOYNMͳΜ͔ͷ αʔόʔݻ༗9.-ଐੑͷฤूΛ3&9.-ͰࣗಈԽ
w 0ODF8SJUF3VO"OZXIFSFͷάϧʔݴޠ🤔 U%JBSZ͕ΩϥʔΞϓϦ࣌
0.(ʹ࠾ʁ !LLE IUUQPCKFDUDMVCKQNMBSDINBHB[JOFIUNM
"GUFS3BJMT
w 3BJMTͱ͍͏ࠇધ͕͖ͬͯͨ w ࣌3BJMTͷ࠾·ͩϦεΫ w 3BJMTొͷ࣌TDB ff PMEͰ·ͱͳΞϓϦ ࡞ΕΔͷٙʁͬͯΈͨΒશવͰ͖ͨ w
࣮ࡍͷͱ͜ΖTDB ff PME͏ػձ͕ͳ͍Α͏ͳ ͓ࣄͰ3VCZΛΩϝΔ࣌
w 3VCZPO3BJMTͰΓΓίʔυΛॻ͚ΔΑ ͏ʹͳͬͨΘΓʹΩϚΓ͗͢ͷΦʔόʔ ϫʔΫʹͳͬͯ͠·ͬͨࣄྫ͋Γ w ࣌ੜ࢈ੑഒͱݴΘΕ͍ͯͨཪ w 3VCZPO3BJMTͰఆ࣌ʹؼΖ͏"8%X3 Ωϝա͗ҙใ͕ग़Δ
w has_manyͳͲͰݴޠ%4-ͷڧྗ͞Λྲྀ w Ҿ࠷ޙͷϋογϡͷϒϨʔεͷলུͰ ΩʔϫʔυҾͬΆ͞ ࣌=>ه๏ͷΈ w 3BJMTͰಋೖ͞ΕͨSymbol#to_proc͕3VCZ
ʹϙʔςΟϯά͞ΕΔ 3BJMTʹΑΔ3VCZͷදݱྗ
͡·ΓͷSymbol#to_proc https://github.com/rails/rails/commit/69bf71f5e9b537f88acc0d4492a057336e7305d1
.FSHF:"37
w :"37͕ೖͬͯɺ"45ϕʔεͷධՁث͔ Β7.ʹΑΔόΠτίʔυ࣮ߦʹͳͬͨ w άϦʔϯεϨου͔ΒωΠςΟϒεϨουʹ ͳͬͨ (7-͕͋Δͷͷ*0ͪͳͲͷϒ ϩοΫதଞͷεϨου͕࣮ߦͰ͖Δ w
ͭ·ΓΞοϓάϨʔυ͢Δͱ͘ͳΔ࣌ ΞϓϦίʔυԼͰͷมԽ
w key => valueʹՃ͑key: valueͷ)BTIه๏ಋೖ w ྩ ࣌3VCZEFW ʹ
ʮ3VCZͷ)BTIه๏ʯͱίϝϯτ͢Δ͜ͱ͕ʂ w ΩʔϫʔυҾ͕ೖͬͨͷ3VCZ͔Β͕ͩɺϝιο υҾͷ࠷ޙͷϋογϡ͕ຊʹͦΕͬΆ͘ w ࣌ࢍ൱྆ͷlambdaͷ->ه๏͕ೖͬͨ w จࣈͱه߸ͷࣝผௐ͕ઈົ ΞϓϦίʔυ͕ݱతͳݟͨʹ
w 3VCZҎલͷจࣈྻόΠτͷγʔέϯε w ⤴Ͱଟ͘ͷEncoding::CompatibilityErrorͱରቂ w # encoding: UTF-8ϚδοΫίϝϯτʹΑΔ εΫϦϓτΤϯίʔσΟϯάͷࢦఆͱ
String#force_encodingͳͲʹΑΔετϦʔϜ ΤϯίʔσΟϯάมͰΓͬͨΑ͏ͳ w ͓͔͛ͰͷΞοϓάϨʔυ͘͠ͳ͔ͬͨʁ ΞϓϦίʔυͷඇޓ աڈ࠷େ
5IF'JSTU4UBCMF
w 3VCZ(FNT͕ඪ४ఴʹͳΔ w ruby setup.rbίϚϯυʹΑΔΠϯετʔϧ apt-get install railsͱ͍͏gemཧͱࠞ ͥΔͳةݥͷ౫ଡ
w ͜ͷޙ͘Β͍ʹ3BJMTʹ#VOEMFS͕౷߹͞Εͯ ύοέʔδཧͷΤίγεςϜ͕҆ఆͨ͠ ܥ࠷ॳͷ҆ఆόʔδϣϯ
.BOZ/FX'FBUVSFT
w ΩʔϫʔυҾɺModule#prependɺ γϯϘϧϦςϥϧɺEnumerable#lazyɺ َӢɺTracePointɺ3F fi OFNFOUTͳͲͳͲ w ӽ͠ͷΞοϓάϨʔυͰຊʹ৽ػೳ
Γͩ͘͞Μͩͬͨ w ϝλϓϩΪϟϯάେتͼʁ ޫͷػೳͱҋͷػೳͨ͘͞Μ
w εΫϦϓτΤϯίʔσΟϯάͷσϑΥϧτ͕ 65'ʹͳͬͨ ࠓϚδίϝෆཁ εΫϦϓτΤϯίʔσΟϯάෆཁ
*NQSPWFNFOUT
w ΞϓϦ໘Ͱେ͖ͳมߋࢥ͍ग़ͤͳ͍ վળʹײँ
4ZNCPM($
w 3BJMTͰ4ZNCPM($ඞਢͷͨΊಋೖ ͞Εͨ3VCZҎ্Λཁٻ͢Δ w ݫີʹόάϑΟοΫεͷҎ্͕ཁ݅ վળʹײँ
4FWFSBM6TFGVM4ZOUBYFT
w 4BGF/BWJHBUJPO0QFSBUPS ΅ͬͪԋࢉࢠ ʹΑΔ3BJMTΞϓϦͷtryͱtry!ͷஔ͖͑ w .Ͱेͳ߹ʹ&.Λكʹݟ͔͚Δ 4BGF/BWJHBUJPO0QFSBUPS
w 4RVJHHMZ)FSFEPDʹΑΔ3BJMTΞϓϦͷ strip_heredocͷஔ͖͑ 4RVJHHMZ)FSFEPD
• # frozen_string_literal: trueʹΑ ΔϚδοΫίϝϯτͰfreeze͞Εͨ String͕खʹೖΔΑ͏ʹͳͬͨ • RubyͷॊΒ͔͕͞ݮͬͨʁ w ͕࣌ٞৢ͞Ε͍ͯͨ
GTUSJOHMJUFSBMͷಋೖ
3VCZͰԆظޙͷԻࠫଡʁ https://mametter.hatenablog.com/entry/20151004/p1
3BJMTͱGTUSJOHMJUFSBMT https://github.com/rails/rails/pull/30342
*OUFHFS6OJ fi DBUJPO
ܯࠂͷ͕ྲྀΕΔ w 3VCZͷͱ͖ͱҟͳΓɺ·ͣඇޓͷ ඇਪܯࠂ͞Ε͍ͯͨ w 3VCZEFWΛ͏͜ͱͰϦϦʔε࣌ ʹͷ൙ཞ͕ݮΔΑ͏ʹύονΛૹ͍ͬͯͨ
044ͱৗ w HIR HFNTSD ཧϦϙδτϦ ͷඇਪܯࠂ ύονΛग़͢Τί γεςϜࢀՃͷ ͖͔͚ͬʹͳΔ
*NQSPWFNFOUT
w rescueelseensure͕doend ϒϩοΫʹॻ͚ΔΑ͏ʹͳͬͨͷॻ͖৺ ྑ͍ վળʹײँ
.+*53VCZ7."45
w ͍ͪΜ࣮༻໘ͰӨڹ͍ͯͦ͠͏ w 3VCZΛΠϯετʔϧͨ͠ޙʹ gem i bundlerͱ͍͏ఆܕّྱ͕ෆཁʹ #VOEMFS͕ඪ४ఴ͞ΕΔ
w .+*5͕ಋೖ͞Ε͕ͨɺ3BJMTΞϓϦέʔγϣ ϯͰͷ࣮༻ࣄྫՉฉʹͯ͠ฉ͔ͣͩͬͨ w 3VCZ7."CTUSBDU4ZOUBY5SFFʹΪϟϯά ͕ΞϓϦ֎ͰΓ্͕ΓΛݟ͍ͤͯͨ w ΞϓϦͷ࣮༻໘ͰFOEMFTTSBOHFͳͲͷ ৽ػೳΛ͑ΔΑ͏ʹͳͬͨ
͍Ζ͍Ζͱ࣮ݧతͳ೩ྉԼ
4VQFS)BSE.PEF3VCZ
LXBSHT w ͍͍ͩͨฐࣾͷ ύονձʹग़ͯͨ ਓͷपลͰΤί γεςϜଆͷ LXBSHTͷͷ ରԠΛਐΊ͍ͯͨ ҹ
w OVNCFSFEQBSBNFUFSͷελΠϧੋඇʹͭ ͍ͯʮ3VCZ8FCΛ࡞ΔͨΊͷݴޠͰ ͳ͘εΫϦϓτݴޠʯͱ͍͏ͷͳΔ΄Ͳ w ݸਓతʹอक͢Δίʔυʹ໊લ͕͍ͭͯ ͍ͯΒ͍͍͚ͨΕͲɺॻ͖ࣺͯεϥΠυ ྔΛݮΒ͢ͷʹศར ύλʔϯϚονφϯύϥ
"CTUSBDU*OUFSQSFUBUJPO
CVHTSVCZMBOHPSHJTTVFT 3VCZݴޠʹ͍͔ͳΔܗͰ͋Εܕએݴ ܕऍΛಋೖ͢ΔͭΓ͋Γ·ͤΜ
w ܕΛॻ͔ͣʹɺܕͷϝϦοτΛڗड͍ͨ͠ w 3#4ͩͱΞϓϦͰ·ͩܕΛॻ͘ίετ͕ߴ͘ ࠳ં͢ΔͷΛݟ͔͚Δ %3:Ͱͳ͘ਏ͍ w 3#*ͷಋೖίʔυ3VCZʹݟ͑ͣਏ͍ w
ྫ͑3#4͕πʔϧؒͷཪଆͷϨΠϠʔݴޠ ʹͳΔະདྷʁ நղऍͱ͍͏ୈͷಓ
:+*5
w .+*5ʹՃ͑ͯ-##7ʹج͍ͮͨ4IPQJGZ +*5Ͱ͋Δ:+*5͕ಋೖ͞Εͨ w 3BJMTΞϓϦͰ༗ޮԽͨ͠ޮՌଌఆ͕ʹ ͳΔ͜ͱ͕͋Δ͚ΕͲ-41ͰΫϥΠΞϯτ ͔ΒRUBY_YJIT_ENABLED=trueͯ͠ΈΑ͏ w FHWTDPEFSVCPDPQ TUFFQWTDPEF
:+*5
3VTU:+*58"4.
w :+*5ͷ࣮͕3VTUʹͳͬͨ w 3VTU:+*5ͷϏϧυͰࠔΔͱ͍͏ΛपลͰ ฉ͔ͳ͍ w %0$,&30''*$*"-*."(&͕ΘΕ͍ͯΔ ͷ͔ɺ3VTUΠϯετʔϧڭཆͳͷ͔ɺ :+*5ແޮͰͷϏϧυͱ͍ͯ͠Δͷ͔ 3VTU:+*5
w ࠷ۙ5SZ3VCZͷσϑΥϧτ͕0QBM͔Β 8"4.ʹͳ͍ͬͯͨ ΑΓྑ͍ೖʹ 8FC"TTFNCMZ 8"4. IUUQTUSZSVCZMBOHPSHQMBZHSPVOE
w ਖ਼نදݱ·ΘΓվળʹΑΔ3F%P4߈ܸରࡦ ࣮༻త w 3FBEPOMZͷStruct.new૬ͱͯ͠ Data.define͕ಋೖ͞Εͨ w 3BDUPSͷར༻ʹؔΘ͍͖ͬͯͦ͏ ͷݸਓతਪ͠
6OJWFSTBM1BSTFS3BDJOH
-SBNBBOE:"31 6OJWFSTBM1BSTFSݖ૪ୣͷηϝϯτ
w !KVOL-SBNBίϯτϦϏϡʔλʔ w !4)QBSTFZίϯτϦϏϡʔλʔ w !LPJD1BSTFSHFNίϛολʔ w !JNB[VNJ*3#ίϛολʔ w !GVHBLLCO3#4ίϯτϦϏϡʔλʔ
ߏจղੳثݚڀ෦ IUUQTNBHB[JOFSVCZJTUOFUBSUJDMFT'PMMPX6Q,JSJTIJNB3VCZIUNM
"CPWF"MM .BLF*U'VO