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
Scala製インタプリタをブラウザで動かす3分クッキング
Search
Rikito Taniguchi
September 09, 2017
Technology
250
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Scala製インタプリタをブラウザで動かす3分クッキング
Rikito Taniguchi
September 09, 2017
More Decks by Rikito Taniguchi
See All by Rikito Taniguchi
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
250
Capture Checking / Separation Checking 入門
tanishiking
0
760
Implementing and Evaluating a High-Level Language with WasmGC and the Wasm Component Model: Scala’s Case
tanishiking
0
850
Scala meets WebAssembly
tanishiking
0
1.1k
Why Wasm+WASI for Scala
tanishiking
0
160
Scala to WebAssembly: Exploring the How and Why
tanishiking
1
2k
Scala to WebAssembly #scala_waiwai
tanishiking
0
2k
Scala Days Madrid 2023 参加レポート
tanishiking
0
120
Tooling for Scala3
tanishiking
0
460
Other Decks in Technology
See All in Technology
AIで選択肢が広がった組織設計の理想と現実
konifar
16
7.7k
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
210
Active Directory と Entra ID のむむむな関係
murachiakira
PRO
2
960
`go get`したらELFが降ってきた件
taiyow
0
170
AIエージェントの監視、思考を見るか行動を見るか / Monitoring AI Agents: Thoughts or Actions
yusukeshimizu
1
120
Consistency for mere mortals - A gentle guide to consistency
ufried
0
120
20261031_IoTLT_vol140_kitazaki_v1.pdf
kitazaki
0
170
kaonavi Tech Night#2
kaonavi
0
110
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
500
AIコーディングはじめました
miso
0
150
Building Audio Plugin Ecosystem for Android in 2026
atsushieno
2
140
Patterns in AI Driven Software Development
akosma
PRO
0
480
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
RailsConf 2023
tenderlove
30
1.6k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
460
Prompt Engineering for Job Search
mfonobong
0
570
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
970
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
620
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
560
Transcript
Scala 製インタプリタをブラウザで動かす 3 分クッ キング id:tanishiking24 Scala 関西 Summit2017 1
こんにちは • • twitter @tanishiking • id:tanishiking24 • Web アプリケーションエンジニア@はてな
• 主に Scala、たまに TypeScript/Perl 2
今日作るもの • https://github.com/tanishiking/MLScala 3
手順 • インタプリタを作る • Scala.js でビルドする • UI を書く •
完成! 4
インタプリタを作る このあたりを参考に頑張る • https://github.com/ksuenaga/IoPLMaterials • http://esumii.github.io/min-caml/ パーサコンビネータに fastparse 使った 5
インタプリタを作る こちらにあらかじめ作ったものが 6
Scala.js でビルドする 公式ドキュメントを参考に build.sbt をいじる • crossProject で shared,js,jvm 用にプロジェクト分ける
• コアロジックは shared 以下につっこむ、雑に全部ごっちゃに すると sbt test が動かなくなったり • https://github.com/scala-js/scala-js/issues/739 7
Scala.js でビルドする • export するモジュールやメソッドを annotation で指定 • プログラムの文字列を入力として print
メソッドに渡した値の 文字列を返す簡素な API import scalajs.js.annotation._ @JSExportTopLevel(”ML”) object Interpreter { @JSExport def interpret(input: String): String = { // ... 8
UI を作る • ビルド成果物の JS を雑に読み込んで、さっき export したメ ソッドを実行したらなんか動く •
標準出力は console に出てくる ... <script src=”./js/target/scala-2.12/mlscala-fastopt.js”></scrip ... <script> const result = ML.interpret('let x = 1 in print x;;'); </script> 評価結果を適当な div につっこんで表示する感じで 9
完成!! http://tanishiking.github.io/MLScala/ 10
まとめ • 普通に動いてすごい • 面白 AltJS くらいの印象だったけど Scala 製モジュールのデモ に良さそう
• ブラウザで動かしたいけど JS で書きたくないモジュールある よね 11