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
TypedCoffeeScriptって、あったらよくないですか
Search
Koutarou Chikuba
June 08, 2014
Technology
7
11k
TypedCoffeeScriptって、あったらよくないですか
altjs武闘会
Koutarou Chikuba
June 08, 2014
Tweet
Share
More Decks by Koutarou Chikuba
See All by Koutarou Chikuba
CI/CD 改善の勘所
mizchi
0
110
極限環境で最終ビルドを絞るためのフロントエンド設計
mizchi
16
5.5k
Server Side JavaScript のためのバンドル最適化
mizchi
5
7.2k
V8 as a container on CDN Edge worker
mizchi
6
2.3k
Edge Side Frontend という新領域
mizchi
35
14k
バンドル最適化マニアクス at tfconf
mizchi
8
4.4k
「たかがJavaScript」のその先 #TECHPLAY
mizchi
47
20k
Deno Node 両刀
mizchi
7
2.5k
「フロントエンド領域」を再定義する
mizchi
50
37k
Other Decks in Technology
See All in Technology
Rubyの国のPerlMonger
anatofuz
3
730
【CEDEC2025】『ウマ娘 プリティーダービー』における映像制作のさらなる高品質化へ!~ 豊富な素材出力と制作フローの改善を実現するツールについて~
cygames
PRO
0
240
SRE新規立ち上げ! Hubbleインフラのこれまでと展望
katsuya0515
0
170
2025新卒研修・HTML/CSS #弁護士ドットコム
bengo4com
3
13k
いかにして命令の入れ替わりについて心配するのをやめ、メモリモデルを愛するようになったか(改)
nullpo_head
6
2.3k
Lambda management with ecspresso and Terraform
ijin
2
150
LLM 機能を支える Langfuse / ClickHouse のサーバレス化
yuu26
7
780
Amazon Q Developerを活用したアーキテクチャのリファクタリング
k1nakayama
2
200
Kiroから考える AIコーディングツールの潮流
oikon48
4
680
【CEDEC2025】『Shadowverse: Worlds Beyond』二度目のDCG開発でゲームをリデザインする~遊びやすさと競技性の両立~
cygames
PRO
1
300
反脆弱性(アンチフラジャイル)とデータ基盤構築
cuebic9bic
3
170
dipにおけるSRE変革の軌跡
dip_tech
PRO
1
240
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
KATA
mclloyd
32
14k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.2k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Unsuck your backbone
ammeep
671
58k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
GraphQLとの向き合い方2022年版
quramy
49
14k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Transcript
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!͋ͳͨͷ ߩݙΛ͍ͬͯ·͢ʂ