Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TypedCoffeeScriptって、あったらよくないですか
Search
Koutarou Chikuba
June 08, 2014
Technology
11k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypedCoffeeScriptって、あったらよくないですか
altjs武闘会
Koutarou Chikuba
June 08, 2014
Transcript
24 slides
TypedCoffeeScriptͬͯɺ͋ͬͨΒΑ ͘ͳ͍Ͱ͔͢ @mizchi altjsಆձ
About&me • @mizchi • ओʹϑϩϯτΤϯυΤϯδχΞ • AltJSϚχΞ • ࠷ۙLLVMphaser.js(WebGLͷ2dήʔϜΤϯδϯ)ʹڵຯ
TypedCoffeeScript ͱ
ͳʹ͜Ε? • mizchi/TypedCoffeeScript • ʮܕ͖ʯCoffeeScript • CoffeeScriptͷεʔύʔηοτ(ݩͷcoffeeશ෦௨͢) • CoffeeScriptͷจ๏.+.TypeScript෩Subtyping •
൵؍తܕਪ(ޙड़) • ੩తղੳ
CoffeeScript:,એݴ n = 42 p = x: 1, y: 2
TypeCoffeeScript:.એݴ n :: Number = 42 struct Point x ::
Int y :: Int p :: Point = x: 1, y: 2
TypedCoffeeScriptԿΛ͔ͨ͠ʁ • ܕΞϊςʔγϣϯͷղऍ • ߏମએݴ • ೖ࣌ܕνΣοΫ • ΦϒδΣΫτϦςϥϧͷਪ •
Int%&>%NumberͷμϯΩϟετ(Number%:>%Float%:>%Int)
CoffeeScript:,ؔ {sqrt, pow} = Math distance = (from, to) ->
sqrt pow(from.x - to.x, 2) + pow(from.y - to.y, 2) console.log distance {x: 0, y: 0}, {x: 3, y: 4} #=> 5
TypedCoffeeScript:/ؔ sqrt :: Number * Number -> Float pow ::
(Number, Number) -> Float {sqrt, pow} = Math distance :: Point * Point -> Float distance = (from, to) -> sqrt pow(from.x - to.x, 2) + pow(from.y - to.y, 2) console.log distance {x: 0, y: 0}, {x: 3, y: 4} #=> 5
TypedCoffeeScript:/ؔ foo = Int -> Int -> Int foo =
(m) -> (n) -> m * n n :: Int = foo(3)(2) ͜Μͳ͜ͱ
TypedCoffeeScriptԿΛ͔ͨ͠ʁ • લஔܕΞϊςʔγϣϯ • BinaryOperatorͷਪ:.(+.Float.Float).4>.Float • ؔࣜͷܕνΣοΫ • ؔద༻ͷܕνΣοΫ •
ະఆٛγϯϘϧͷAnyܕͷϑΥʔϧόοΫ(consoleະఆٛ)
Structual(Subtyping struct Point {x :: Int, y :: Int} p
:: Point = {x: 1, y: 2, z: 3} n :: Int = p.z # type error p3d :: {x :: Int, y :: Int, z :: Int} = p # type error • ೖઌ͕αϒΫϥεͰ͋Δ͜ͱΛཁٻ͢Δ • ܕΞϊςʔγϣϯ͕એݴ͞ΕͨγϯϘϧ(ม)Ҏ߱ͦͷΠϯλ ʔϑΣʔεͰৼΔ͏
൵؍తܕਪ • ͯ͢ͷࣜimplicitଐੑͩͱԾఆ͢Δ • implicitଐੑಉ࢜ͰܕਪΛࢼΈࣦͯഊͨ͠߹" implicitଐੑͷAnyܕʹϑΥʔϧόοΫ͢Δ • Ϣʔβʔ͕ΞϊςʔγϣϯΛهड़ͨࣜ͠ඇimplicitଐੑ • ඇimplicitଐੑ͕ؔΘͬͯܕਪ͕ࣦഊͨ͠߹ɺΤϥʔͱ
ͳΔ
ͦͷଞͷػೳ • array • nullable • class͔ࣜΒͷߏମࣗಈநग़ • generics(wip) •
TypeScript5importer(wip)
ͳͥ࡞͔ͬͨ • CoffeeScriptͰϥΠϒϥϦΛࢼͭͭ͠ϓϩτλΠϓΛ࡞Γ·͘Δ • ݎ࿚ͳઃܭΛࢦ͢ͱΓܕ͕΄͘͠ͳΔ • TypeScriptͰॻ͖ͳ͓͢ͱܕఆٛΛॻ͍ͯҰ͕ऴΘΔ • CoffeeScriptͷତམͨ͠จ๏ͷ··Ͱɺܕ͕ͳ͍ঢ়ଶ͔Βɺஈ֊ తʹҠߦͰ͖ΔΑ͏ͳݴޠ͕΄͍͠ͳΝ…
ݱ࣮తͳधཁ • HTML5ΞϓϦέʔγϣϯͷڊେԽ • ͱ͘ʹγϯάϧϖʔδΞϓϦέʔγϣϯ(SPA)ͷधཁ • ֤͕ࣾେنCoffeeScriptͷϦιʔεΛ๊͑ͯΔͬΆ͍ • εʔύʔηοτͳίϯύΠϥஔ͖͑Ͱஈ֊తʹܕڥͷҠߦ
ओ؍ʹجͮ͘coffeeͱtypescriptͷൺֱ • CoffeeScriptͷϝϦοτ • ͔͍͍ͬ͜ • CoffeeScriptͷσϝϦοτ • ܕ͕ͳ͍ •
TypeScriptͷϝϦοτ • ܕ͕͋Δ
CoffeeScript+++TypeScript Զ͕ߟ͑ͨ࠷ڧͷAltJS
࠷ۙͷਐḿ • CoffeeScriptReduxͷsuper࣮ • TypeScriptͷܕఆٛϑΝΠϧͷύʔαΛ࡞ͬͨ(mizchi/dts8 parser) • ↑ʹରԠ͢ΔͨΊʹ෦ASTΛ΄΅θϩ͔Βॻ͖ͨ͠
ݱࡏͷϓϩδΣΫτͷ՝ • झຯ࣌ؒͰ࡞Δʹ։ൃ͔͔࣌ؒΓ͗͢ • ΫϥυϑΝϯσΟϯάͰ͖ͳ͍͔ߟҊத • ύτϩϯืूதɻͷͷϞνϕʔγϣϯΛۚͰങ͍·ͤΜ ͔?#$>#اۀ༷ • ʮΔؾʯ͕͋ͬͨΒSublimeText/VimͷΠϯςϦηϯε͙Β͍
·Ͱ࡞ΕΔ͔Ͷ??? • ֎ਓ͔Β͍Ζ͍Ζཁ͕͘Δ
ྺ࢙ • ࡢ8݄:$jashkenas/coffeescript$ͷίʔυಡΈ࢝ΊΔ • ࡢ10݄:$ϩϯυϯग़ுதͷඈߦػͷதͰϓϩτλΠϓΛ࡞Δ • ࡢ12݄:$ܕਪΛҰ௨Γ࡞Δ • ࠓ1~3݄:$ଔ͗͢͠ϫϩλ •
ࠓ5݄:$altjsಆձͰcoffeeҎ֎ͷൃද͢Δʁ • ։ൃ࠶։͢Δ͔ʂ
ઃܭࢦ • ܕΞϊςʔγϣϯߏจΛՃ • ੩తղੳ • ίϯύΠϥʹۃྗखΛೖΕͳ͍(Ϛʔδ͕ࠔʹͳΔͨΊ) • ίϯύΠϥͱผʹAST'TraverserΛॻ͘ •
ϊʔυ͝ͱʹtypeAnnota2onΛղܾ͢ΔܕਪثΛ࡞Δ ઃܭํ:"ݎ࿚ͳઃܭ"<"طଘίʔυ͔ΒͷҠߦίετ࠷খԽ
ϚΠϧετʔϯ • v0.11 • return,,ׂೖ,,δΣωϦΫε,,super,ͷਪ • ΤϥʔϨϙʔτͷվળ • v0.12 •
module • typealias • typescript,d.ts,importer
͓ΘΓ mizchi/TypedCoffeeScript!͋ͳͨͷ ߩݙΛ͍ͬͯ·͢ʂ
More Decks by Koutarou Chikuba
See All by Koutarou Chikuba
技術記事、 専門家としてのプログラマ、 言語化
mizchi
16
8.9k
CI/CD 改善の勘所
mizchi
0
300
極限環境で最終ビルドを絞るためのフロントエンド設計
mizchi
16
6.4k
Server Side JavaScript のためのバンドル最適化
mizchi
5
8.2k
V8 as a container on CDN Edge worker
mizchi
6
2.7k
Edge Side Frontend という新領域
mizchi
35
15k
バンドル最適化マニアクス at tfconf
mizchi
8
4.8k
「たかがJavaScript」のその先 #TECHPLAY
mizchi
47
21k
Deno Node 両刀
mizchi
7
2.7k
Other Decks in Technology
See All in Technology
Libérez Firefox et Thunderbird avec nos astuces
hellosct1
0
150
共通基盤の実装に Kotlin - Quarkus を選定した理由と採用したアーキテクチャ
nealle
1
160
リリースしたで終わらない。 観測できるフロントエンド開発
yamakenji24
4
480
ブース設計、 お前もプロダクトだったのか / So Booth Design Was a Product All Along
akihiro0038
0
150
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
20
29k
セキュリティチームは どのコンテナイメージの脆弱性対応を優先すべきか 〜CISA新指針とSCCで作る脆弱性トリアージ〜
swdtkuy
0
340
AWS Well-Arhitected Frameworkセキュリティの柱 について
miu_crescent
PRO
2
260
AIエージェントのアーキテクチャ設計
nsatoh
0
550
現地速報! Microsoft Ignite アップデートレポート
kasada
1
460
HTTP通信に使おうとすると実はめんどくさいfile_get_contents
maguroalternative
0
260
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
Platform Engineering をベースとした Agentic Software Factory の実践
110y
3
990
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
680
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
630
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
Are puppies a ranking factor?
jonoalderson
2
4.2k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
690
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Well, that’s weird…
csswizardry
1
210
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
910
Large-scale JavaScript Application Architecture
addyosmani
516
110k