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
DSL でナンデモプログラミング!? / dsl-programming
Search
Watson
October 13, 2016
Programming
2
9.1k
DSL でナンデモプログラミング!? / dsl-programming
TeX と Vim script を比較してみた
Watson
October 13, 2016
Tweet
Share
More Decks by Watson
See All by Watson
LaTeX News斜め読み / texconf2024-ltnews
wtsnjp
0
62
Texdocのしくみ / texconf2024-texdoc
wtsnjp
0
46
Building Dataset for Grounding of Formulae — Annotating Coreference Relations Among Math Identifiers / lrec2022
wtsnjp
0
160
MioGatto による数式グラウンディング データセットの構築 / nlp2022
wtsnjp
0
540
MioGatto: A Math Identifier-oriented Grounding Annotation Tool / mathui2021
wtsnjp
0
350
日本語化プロジェクト 〜TeX Live と learnlatex.org〜 / localize
wtsnjp
0
1.3k
Dataset Creation for Grounding of Formulae / SCIDOCA2020
wtsnjp
0
350
l3regex: TeX で実装された正規表現エンジン / l3regex
wtsnjp
1
830
A TeX-oriented Research Topic: Synthetic Analysis on Mathematical Expressions and Natural Language / tug2019
wtsnjp
0
200
Other Decks in Programming
See All in Programming
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
160
php-conference-japan-2024
tasuku43
0
240
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
Recoilを剥がしている話
kirik
5
6.6k
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
350
良いユニットテストを書こう
mototakatsu
5
2.1k
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
740
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Security_for_introducing_eBPF
kentatada
0
110
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
The Language of Interfaces
destraynor
154
24k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Mobile First: as difficult as doing things right
swwweet
222
9k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
A Tale of Four Properties
chriscoyier
157
23k
Embracing the Ebb and Flow
colly
84
4.5k
4 Signs Your Business is Dying
shpigford
181
21k
Designing for humans not robots
tammielis
250
25k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Transcript
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ʙTEX ͱ Vim script Λൺֱͯ͠Έͨʙ ϫτιϯ
(@Watson_DNA) Yokohama.vim #8 2016 10 ݄ 16 1 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ࣗݾհ ϫτιϯ (@Watson_DNA) ▶ T େֶ ཧֶ෦
ੜใՊֶՊ ˠจࣈྻॲཧֶՊʹओʹྻղੳ ▶ ߴߍ࣌ࢠੜֶΛѪ͍ͯͨ͠ ˠ͍·ֶใՊֶʹڵຯ͕Ҡߦ ▶ झຯొࢁʢΫϥΠϛϯάొΓؚΉʣ ˠࠓઇࢁߦ͖͍ͨɽ໋͕͍ͭ͋ͬͯ͘Γͳ͍ ▶ ͪΖΜϓϩάϥϛϯά͖ େ͖ͳݴޠɿTEX (on L A TEX), Ruby ͬͨ͜ͱ͋ΔݴޠɿC/C++, R, Python, Scheme, etc. ▶ Vim ઓಆྗ 315ʢ2016 10 ݄ 16 ݱࡏʣ 2 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ DSL ͱ ఆٛ C Python ͳͲͷϓϩάϥϛϯάݴޠΛʮ൚༻ݴޠʯͱݺͿͷʹ ର͠ɼ͋ΔಛఆͷछྨͷʹಛԽͨ͠ίϯϐϡʔλݴޠΛ
DSL ʢDomain Specific Language ʹυϝΠϯಛԽݴޠʣͱݺͿɽ ྫ ▶ ϋʔυΣΞهड़ɿVerilog, VHDL ▶ Ϗϧυπʔϧɿmake, Rake ▶ ͦͷଞɿAWK, HTML/CSS, SQL, yacc, VBA ͳͲͳͲ ͪΖΜɼ൛ݴޠ TEX Vim script DSL ʹؚ·ΕΔʂ DSL + φϯσϞϓϩάϥϛϯά = τϯσϞϓϩάϥϛϯάʂʁ 3 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ TEX ݴޠͱ TEXʢTeX; ςϑ, ςοΫʣ ΞϝϦΧͷֶऀ Knuth ͕ࣗஶ
The Art of Computer Programming Λ൛͢ΔͨΊ 1976 ʹߟҊͨ͠൛ιϑτΣΞɽಛʹࣜ ͷॲཧʢ ඒ͠͞ʣʹఆධ͕͋Δɽ ζ(s) = ∞ ∑ n=1 1 ns = ∏ p:prime 1 1 − p−s ▶ Ұൠʹ L A TEX ͷϚΫϩύοέʔδΛಡΈࠐ·ͤͯ͏ ▶ εϥΠυ༻ͷ Beamer ͱ͍͏จॻΫϥεʢຊࢿྉ͕࣮ྫʣ ˠ Vim ͰεϥΠυ࡞Մೳʂ Vimmer ͷօ͞ΜʹΦεεϝʂ ▶ ൛ʹಛԽͨ͠ DSLʢTEX ݴޠʣͷΠϯλϓϦλͰ͋Δ ▶ TEX ݴޠνϡʔϦϯάશੑΛͭ 4 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ Vim script ͱʢऍՠʹઆ๏ʣ VimʢVi IMproved; ϰΟϜ, ϰΟΞΠΤϜʣ ΦϥϯμͷϓϩάϥϚ
Moolenaar ʹΑͬͯ 1980 ʹ։ൃ͞ΕͨςΩετΤσΟλɽ ಛʹϓϩάϥϚͷؒͰ͘Ѫ͞Ε͍ͯΔɽ ߴ͍ΧελϚΠζੑͦͷಛͷ 1 ͭɽ ▶ Vim script ͱ͍͏ಈతܕ͚ݴޠ͕Έࠐ·Ε͍ͯΔ ˠઃఆϑΝΠϧϓϥάΠϯʹෳࡶͳॲཧΛهड़Մೳ ▶ Vim script νϡʔϦϯάશ ˠͦͦ vi ͷΩʔόΠϯυࣗମ͕νϡʔϦϯάશʁ ▶ “VimScript” “VimL” ͳͲਖ਼͘͠ͳ͍දه ˠͳ͔ͳ͔ “TeX” ͱॻ͍ͯΒ͑ͳ͍ TEX ͱࣅ͍ͯΔʁ 5 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ΫΠοΫιʔτΛ࣮ͯ͠Έͨ TEX ࣮ Vim script ࣮ ιʔείʔυɿhttps://git.io/vPu97 6
/ 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ϕϯνϚʔΫ ଌఆ݅ ▶ 10 ສཁૉ·ͰͷྻΛιʔτ͢Δͷʹ͔͔ͬͨ࣌ؒ ▶ ೖྗҎԼͷϫϯϥΠφʔͰ࡞ (n
= 3, 4, 5) $ ruby -e "puts Array(1..10**n).shuffle" ▶ ֤αΠζʹ͖ͭ 10 ճͣͭܭଌͨ͠ฏۉͱͯ͠ࢉग़ ▶ ٕज़తʹΑΓೖྗͷಡΈࠐΈؚ࣌ؒΉ ଌఆ݁Ռʢ୯Ґɿmsʣ ཁૉ C ݴޠ TEX ݴޠ Vim script 1,000 3.75 × 10−1 1.45 × 102 2.53 × 102 10,000 3.49 × 100 3.19 × 102 1.90 × 103 100,000 3.65 × 101 3.96 × 103 4.37 × 104 7 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ײͳͲ ▶ ࣮ߦ͕ͱ͍ͯ ˠ C ݴޠ ≫ ʢӽ͑ΒΕͳ͍นʣ
≫ TEX ݴޠ ≥ Vim script ▶ ݴޠ༷͕ͱͯΞϨ ▶ TEX ݴޠɿϨδελͷ্ݶɼ੍ޚ௲ͷཏྻɼల։ͱධՁ ▶ Vim scriptɿه߸|"ͷڍಈɼίϚϯυͷཏྻɼ໊ؔ ˠͦΕͧΕྺ࢙తࣄ͕͋ΔͷͰɼ͋Δఔํͳ͍ ▶ Vim script ʢTEX ݴޠͱൺֱ͢ΔͱʣαΫοͱॻ͚Δ ▶ ϕϯνϚʔΫΛऔΔࡍͷγΣϧ͕ܳҰ൪ਏ͔ͬͨ ˠ Vim ͷىಈ࣌Φϓγϣϯଟ͗͢Ͱʂʁʢศར͚ͩͲʣ ࠷ޙʹͬͨͷʜʜ ָ͍͠ʋ (ɾ˲ɾ) ůʋ (ɾ˲ɾ) ůʋ (ɾ˲ɾ) ůͱ͍͏ؾ࣋ͪ 8 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ຊʹ͓͚Δαϙʔτମ੍ TEX ίϛϡχςΟ ▶ TEX Forum ͕த৺ http://oku.edu.mie-u.ac.jp/tex
▶ Q&A ܗࣜ ▶ ࣭ͷํʹίπ͕ඞཁ ▶ TEX Ϣʔβͷू͍ 2016 11 ݄ 5 ˏभେֶ ▶ T େʹѪձ͕ଘࡏ Vim ίϛϡχςΟ ▶ Lingr ͷ Vim ෦͕த৺ http://lingr.com/room/vim ▶ ৗ࣌ٞ ▶ ࣭ͯ͠ྑ͍ͷ͔ ▶ VimConf 2016 11 ݄ 5 ˏϛΫγΟʢौ୩ʣ ▶ ༷ʑͳॴͰ {city}.vim ։࠵ ͍ͣΕ Twitter Ͱαϙʔτͯ͠Β͑Δ͜ͱ͕͋Δʂ 9 / 10
DSL ͰφϯσϞϓϩάϥϛϯάʂʁ ຊʹ DSL + φϯσϞϓϩάϥϛϯά = τϯσϞϓϩάϥϛϯά true
ਅͩΖ͏͔ʁ ▶ DSL ιϑτΣΞར༻ऀͷ͙ͦ͢ʹ͍Δଘࡏ ˠϑϩϯτΤϯυͷརΛଘʹ׆͔ͤΔ ▶ ͔ͤͬ͘ॻ͍ͨϓϩάϥϜɼ୭͔ʹͬͯΒ͍͍ͨ ˠχον͔ͩΒɼϥΠόϧগͳ͍ ▶ ϚΠφʔͰɼॿ͚ͯ͘ΕΔਓ͍Δ ˠ͕͍ؒΕɼಆ͍͚ͬͯΔ Բͤͣॻ͚ɼ͖ͬͱͤʹͳΕΔʂ 10 / 10