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
Good interface: Command pattern as an example
Search
Masafumi Okura
June 08, 2019
Programming
1
1k
Good interface: Command pattern as an example
Masafumi Okura
June 08, 2019
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
Why did my proposals get rejected?
okuramasafumi
1
470
A suggestion for the future of RDoc
okuramasafumi
1
69
15 JSON serializers for Ruby
okuramasafumi
2
120
Tech Events, Should We See Them from the Outside or the Inside?
okuramasafumi
1
44
Creating gems 101
okuramasafumi
1
84
How NOT to make your DSL terrible
okuramasafumi
0
310
オブジェクトしこう
okuramasafumi
2
220
Debugging Alba
okuramasafumi
1
200
Learning Ruby
okuramasafumi
5
570
Other Decks in Programming
See All in Programming
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
CSC305 Lecture 26
javiergs
PRO
0
140
Recoilを剥がしている話
kirik
5
6.6k
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
1k
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
130
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
KATA
mclloyd
29
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Writing Fast Ruby
sferik
628
61k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
How to train your dragon (web standard)
notwaldorf
88
5.7k
A Philosophy of Restraint
colly
203
16k
Gamification - CAS2011
davidbonilla
80
5.1k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Transcript
ྑ͍ΠϯλʔϑΣΠεͷ୳ٻ ίϚϯυύλʔϯΛྫʹ େխ࢙ʢ@okuramasafumiʣ ໊ݹRubyձٞ04―େਢԋܳ 2019-06-08ʢʣ
ࠓͷൃද͕͋ͪͪ͜ʹ ભҠ͍͖ͯ͠·͢ɻ མޠͩͱࢥָͬͯ͠Έͳ͕Β ͓͔͚͖͍ͬͯͯͩ͘͞!
pp self • ໊લɿ͢ͱ·͞;Έʢେխ࢙ʣ • ॴଐɿϑϦʔϥϯε • ׆ಈॴɿ౦ژ • ͖ͳgemɿPry,
RSpec • ӡӦͯ͠ΔίϛϡχςΟɿGrow.rb
໊ݹRubyձٞ
໊ݹRubyձٞ
զʑͳͥRubyΛ͏ͷ͔
Rubyͷ
զʑͳͥRubyΛ͏ͷ͔ • ॻ͖͍͢ • ʮॻ͖͢͞ʯͬͯͳΜͩΖ͏ • ಡΈ͍͢ • ʮಡΈ͢͞ʯͬͯ(ry •
Rails
զʑ͕RubyΛ͏ཧ༝
ϓϩάϥϛϯάָ͕͍͠
ͳͥRubyͰϓϩάϥϛϯάΛ͢Δͱ ָ͍͠ͷͩΖ͏͔ʁ
https://www.atmarkit.co.jp/news/ 200907/24/ruby2.html
yuguiɿ ͦΕɺίϨΫγϣϯ͕͋ͬͯγϟοϑϧ ͍ͨ͠ͱࢥͬͨΒɺshuffleͱॻ͍ͯɺͦΕ Ͱಈ͔ͳ͖Ό͍͚ͳ͍ΜͰ͢Αɻ
ࢥͬͨͱ͓Γʹಈ͘ ʢৗʹಈ͘ͱݴ͍ͬͯͳ͍ʣ
ͱ͜ΖͰɿ ͳΜͰ͜ͷΛ͍ͯ͠Δͷ͔
ָ͘͠ϓϩάϥϛϯάͰ͖Δ ྖҬΛ͍͛ͨʂ
ϥΠϒϥϦΛॻ͍ͯΈΑ͏ →ॻ͖·ͨ͠
https://github.com/okuramasafumi/ neco
150ߦͪΐ͍ͷϥΠϒϥϦ
2ճ΄Ͳॻ͖͍ͯ͠Δ
ΠϯλʔϑΣΠεʹೲಘ͕͍͔ͳ͔ͬͨ
ΠϯλʔϑΣΠεʹ͍ͭͯ ͍Ζ͍Ζߟ͑ͨͷͰɺ ͦͷՌʢʁʣΛڞ༗͍ͨ͠
ͦͦɿ ΠϯλʔϑΣΠεͬͯ ͳΜ͚ͩͬʁ
Interface (MacOSͷࣙॻΑΓ) 1. a point where two systems, subjects, organizations,
etc. meet and interact 2. Computing a device or program enabling a user to communicate with a computer
ΠϯλʔϑΣΠε ίϯϐϡʔλͱͷίϛϡχέʔγϣϯ ͷͱΓํΛܾఆ͢Δͷ
ΠϯλʔϑΣΠεʹϝιου
ΠϯλʔϑΣΠεʹϝιουγάχνϟ
ʮࢥͬͨͱ͓Γʹಈ͘ʯ
Ruby ΠϯλʔϑΣΠεʢ㲓ϝιουγάχνϟʣ ͕ྑ͍͔ΒΘΕ͍ͯΔ
DSL
ҎԼɺ ʮDSLʯʮݴޠDSLʯΛࢦ͠·͢
Domain Specific Language
Ruby͕ΘΕΔཧ༝ͷҰͭ
RubyʹΑΔDSLͷ۩ମྫ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ •
HomebrewʢύοέʔδϚωʔδϟʣ
ڞ௨
DSLԿ͔Λఆ͍ٛͯ͠Δ
RubyʹΑΔDSLͷ۩ମྫʢ࠶ܝʣ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ •
HomebrewʢύοέʔδϚωʔδϟʣ
RubyʹΑΔDSLͷ۩ମྫʢఆٛྫ͖ʣ • ActiveRecordʢσʔλϞσϧͷఆٛʣ • RakeʢϏϧυϓϩηεͷఆٛʣ • RSpecʢ·ΕΔৼΔ͍ͷఆٛʣ • PuppetChefɺVagrantʢ֤छΠϯϑϥϦιʔεͷఆٛʣ •
Homebrewʢύοέʔδͷఆٛʣ
ͱ͜ΖͰɿ DSL୯ͳΔΫϥεϝιου ʢͷ߹͕ଟ͍ʣ
ͭ·Γɿ DSL·ͨΠϯλʔϑΣΠε
͜͜·Ͱͷ·ͱΊ • ΠϯλʔϑΣΠε͕ྑ͍ͱָ͘͠ϓϩάϥϛϯάͰ͖Δ • ΠϯλʔϑΣΠεͱ͍͍ͩͨϝιουγάχνϟͷ͜ͱ • ֤ॴͰΘΕ͍ͯΔDSL࣮ͨͩͷϝιου • DSLʮఆٛʯʹڧ͍ •
ΠϯλʔϑΣΠεʮ७ਮͳϝιουʯͱDSLʹ͚ΒΕΔ
https://rubykaigi.org/2019/ presentations/tanaka_akr.html
ྑ͍ΠϯλʔϑΣΠεͬͯ ͳΜͩΖ͏ʁʁʁ
⚠ ͜Εͯ͢ࢲͷ୯ͳΔҰҙݟͰ͢ Ͳ͔ͬͪͱ͍͏ͱ͕΄͍͠… ࠙ձͰ͓͠·͠ΐ͏
ྑ͍ΠϯλʔϑΣΠεͷ̏ݪଇ • ໎Θͳ͍ • ґଘ͠ͳ͍ • ͤ͗͢ͳ͍
໎Θͳ͍ • ϝιου໊ʹࡾ୯ݱͷʮsʯඞཁ͚ͩͬʁ • ͋ͷΫϥεcallͰݺͿΜ͚ͩͬɺperform͚ͩͬʁ • Πϯελϯεϝιου͚ͩͬɺΫϥεϝιου͚ͩͬʁ • Ҿͷॱংʁ
ґଘ͠ͳ͍ • ϝιουνΣʔϯΛલఏͱ͠ͳ͍ʢಛఆͷฦΓʹґଘ͠ͳ ͍ʣ • ςετ࣌ͷελϒ͕ߴʑҰͭͰࡁΉ
ͤ͗͢ͳ͍ • ΤϯυϢʔβʔ͕ࣗྗͰͰ͖Δ͜ͱΒͳ͍ • ୯७ͳόϦσʔγϣϯʹෳࡶͳDSLຊʹඞཁ͔ʁ • ΤϯυϢʔβʔ͕ࣗྗͰΓͮΒ͍͜ͱΛΔ • νΣʔϯͨ͠ϩʔϧόοΫॲཧࣗྗͰ͍͠ʢޙड़ʣ
௨ৗͷϝιου͔DSL͔ɺ ͦΕ͕ͩ
શ෦ϝιουͰ͍͍͡ΌΜɺ DSLͱ͔֮͑Δͷେมͩ͠ʂ Pure Ruby࠷ߴʂ
ͱࢥͬͯͨ࣌ظ͕ʹ͋Γ·ͨ͠…
ϝιουΠϯλʔϑΣΠεͷॴ • ҾselfͳͲ͕ࣗ໌ • ܧঝͨ͠ͱ͖ʹಈ࡞͕ཧղ͍͢͠ • ͦ͜ʹʮࠇຐज़ʯͳ͍
ϝιουΠϯλʔϑΣΠεͷॴ • ॊೈͳڍಈΛఏڙ͢ΔࡍʹϢʔβʔ͕ॻ͖͘ϝιου͕ࡶ ʹͳΓ͕ͪ • ϥΠϒϥϦ͕ϑϩʔΛίϯτϩʔϧ͠Α͏ͱ͢Δࡍʹඞཁͳ ϑοΫΛࠩ͠ڬΉͷ͕͍͠ʢϢʔβʔʹଟͷϝιουΛఆ ٛͯ͠Β͏ඞཁ͕ग़ͯ͘Δʣ
DSLͷॴ • ϒϩοΫҾϝιουҾΑΓॊೈ • దʹ໋໊͞Ε͍ͯΔ߹ɺՄಡੑ͕ߴ͍ • ϥΠϒϥϦ͕ҙͷॲཧΛϢʔβʔఆٛͷॲཧʹڬΈࠐΊΔ ʢϑοΫΩϟογϡͳͲʣ • ԿΛ͍ͨ͠ͷ͔ͷʮఆٛʯΛએݴతʹॻ͚Δ
DSLͷॴ • ʮࠇຐज़ʯ͕ଟ͘ͳΓ͕ͪͷͰɺڍಈΛਖ਼֬ʹѲ͢Δͷ͕ࠔ • దʹ໋໊͞Ε͍ͯͳ͍߹ɺՄಡੑ͕ஶ͘͠མͪΔέʔε͕ ͋Δ • ϝλϓϩάϥϛϯάΛར༻͢Δ߹ɺσόοά͕ࠔʹͳΔ
ॊೈੑͷͰDSL͕༏Ґ
͡Ό͋શ෦DSLΛ༻ҙ͠·͘Ε ͦΕͰ͍͍ͷ͔ʂʁ
ࠇຐज़͡Όͳ͍ͷͦΕʁ
DSLຐज़͕͍ ʢby Joker1007ʣ
அ͕͍͠έʔε
ྫɿ όϦσʔγϣϯఆٛͳͷͰDSLΛ͏ ͔͠͠ɺܕνΣοΫΛDSLͰߦ͏͖͔ʁ
ճྫɿ ͤ͗͢ͳ͍ݪଇʹै͍ɺ࣮ࡍͷ όϦσʔγϣϯϢʔβʔʹͤΔɺ ϥΠϒϥϦόϦσʔγϣϯఆٛͷ ϑοΫDSLͷΈఏڙ
۩ମྫ ʢࠓճͷυϝΠϯίϚϯυύλʔϯʣ
NecoϏδωεϩδοΫΛ ʮίϚϯυʯʹׂ͠ɺ ͦΕΒΛΈ߹ΘͤΔϑϩʔΛ ࢧԉ͢ΔϥΠϒϥϦ
·ͱΊ • ͔ͤͬ͘RubyͰॻ͍ͯΔΜ͔ͩΒΠϯλʔϑΣΠεʹͩ͜Θ Γ͍ͨʢָ͍ͬͯ͠ϥΠϒϥϦ͕΄͍͠ʣ • DSLRubyͷڧΈͰ͋Γɺదʹ໋໊ɾ࣮͢Ε୯७ͳϝ ιουΑΓॊೈͳఆٛΠϯλʔϑΣΠεΛఏڙͰ͖Δ • ͕Μͬͯॊೈͳ͍উखΛࢦͯ͠ΔͷͰNecoͬͯ͘ΕΑͳʢએʣ