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
scala-native 試してみた
Search
AGAWA Koji
May 27, 2016
Programming
0
270
scala-native 試してみた
社内 Scala Meetup 2016-05-26
AGAWA Koji
May 27, 2016
Tweet
Share
More Decks by AGAWA Koji
See All by AGAWA Koji
EmscriptenでC/C++アプリをWASM化してブラウザで動かしてみた
atty303
0
250
良いソフトウェアとコードレビュー / Good software and code review
atty303
36
17k
Scala + Caliban で作るGraphQL バックエンド / Making GraphQL Backend with Scala + Caliban
atty303
0
450
Scala.jsとAndroidでドメイン層を共有しよう / Scala.js and Android
atty303
0
670
もう一つのビルドツール mill で作る Docker イメージ / Build docker image with mill the yet another build tool
atty303
2
2.2k
Case of Ad Delivery System is Implemented by Scala and DDD
atty303
4
3.3k
ログのメトリックを取ってみる話
atty303
0
900
ADC2016: Axion meets HashiCorp
atty303
0
740
Why Docker?
atty303
3
180
Other Decks in Programming
See All in Programming
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
1k
DMMオンラインサロンアプリのSwift化
hayatan
0
190
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
6k
HTML/CSS超絶浅い説明
yuki0329
0
190
PicoRubyと暮らす、シェアハウスハック
ryosk7
0
220
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
300
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.3k
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
300
return文におけるstd::moveについて
onihusube
1
1.4k
Azure AI Foundryのご紹介
qt_luigi
1
210
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
390
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Unsuck your backbone
ammeep
669
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Music & Morning Musume
bryan
46
6.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Fireside Chat
paigeccino
34
3.1k
Typedesign – Prime Four
hannesfritz
40
2.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
Code Reviewing Like a Champion
maltzj
521
39k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Transcript
scala-native ࢼͯ͠Έͨ @atty303
scala-native ͱ? 4 ωΠςΟϒόΠφϦΛు͘ Scala ίϯύΠϥ 4 LLVM ϕʔε 4
LLVM ͷ Scala ϑϩϯτΤϯυ 4 ϝϞϦཧ Bohem GC
LLVM IR Λు͘·Ͱ
LLVM IR Ҏ߱
ϥϯλΠϜϥΠϒϥϦ 4 scala-native/javalib 4 scala-js ͔Β͖࣋ͬͯͨ Java API ࣮ 4
io, lang, math, util ͙Β͍ 4 scala-native/nativelib 4 scala-native ϥϯλΠϜ 4 Annotation ఆٛϙΠϯλܕͳͲ 4 scala-native/scalalib 4 Scala ϥϯλΠϜϥΠϒϥϦ 4 scala-native/clib 4 C ͷඪ४ϥΠϒϥϦ (stdlib.h, stdio.h ͱ͔)
ϥϯλΠϜϥΠϒϥϦ 4 ࠓͷͱ͜Ζ .a .so ࡞Εͳ͍Α͏Ͱɺશ෦ιʔε͔ΒϏϧυ͠ ͯϦϯΫͯ͠Δ 4 Java
API ͕جૅతͳͷ͔͠ͳ͍ → طଘͷ Java ࢿ࢈͑ͳ͍ 4 JVM Ͱͳ͍ͷͰ .class ͑ͳ͍ → .jar ͑ͳ͍ 4 Pure Scala ͷϥΠϒϥϦ͑Δ 4 C ͷϥΠϒϥϦ͑ΔͷͰؤுΔ 4 ঢ়گతʹ scala-js ͱಉ͡?
ݴޠ༷ 4 ΄ͱΜͲ Scala ͱಉ͡ 4 ωΠςΟϒͷͨΊͷ֦ு͕͋Δ
ߏମએݴ @struct class Vec( val x: Double, val y: Double,
val z: Double ) 4 C ͷ struct ͱͷ૬ޓӡ༻ͷͨΊ ? 4 ελοΫʹஔͰ͖Δ class Λએݴ͢ΔͨΊ ? 4 C# ͷ class(ࢀরܕ)/struct(ܕ) ͷΑ͏ͳৼ͍?
ελοΫͱϙΠϯλ @struct class Rect(val w: Double, val h: Double) {
def area: Double = w * h } def main(args: Array[String]): Unit = { val p: Ptr[Rect] = stackalloc[Rect] // ελοΫׂΓͯͷϙΠϯλ !p = new Rect(2, 3) // ϙΠϯλ͕ࢦ͢ϝϞϦͷ֨ೲ fprintf(stdout, c"%f\n", (!p).area) // ϙΠϯλͷࢀর֎͠ } 4 Scala ͰϙΠϯλૢ࡞!!!
C ؔͷݺͼग़͠ @extern object stdio { def printf(format: CString, args:
Vararg*): CInt = extern } def main(args: Array[String]): Unit = { stdio.printf(c"hello, world!") } 4 CString = Ptr[Byte] ͳͲͷΑ͏ʹ C ͷܕͱޓੑͷ͋Δ Scala ܕ͕͋Δ
ಈ͔͢ scala-native ͷ demo ϓϩδΣΫτ ͷ࣮ߦ࣌ؒΛൺֱͯ͠ΈΔ 4 ϨΠτϨʔγϯάͷϓϩάϥϜ
Ϗϧυ $ git clone
[email protected]
:scala-native/scala-native.git $ cd scala-native/docker $ ./manage.sh
build $ ./manage.sh run 4 scala ϥΠϒϥϦͷ git clone ʹࣦഊͨ͠Γͨ͠ͷͰ build.sbt ͷ༰ΛखಈͰ࣮ߦͨ͠Γ…
࣮ߦ࣌ؒ native | 12.2008 clang | 10.9654 jvm | 10.7632
gcc | 7.3218 4 time ίϚϯυͰ 5 ճܭଌͨ͠ͱ͖ͷฏۉ 4 ࣮ߦॳظஈ֊ͷׂʹ݈ಆ͍ͯ͠Δ 4 LLVM ͍͢͝!
ىಈ࣌ؒ jvm | 0.2758 native | 0.004 4 ىಈ͍࣌ؒ! 4
͚Ͳ JVM ͷ 0.3 ඵऑผʹ͍ͱ͍͏΄ͲͰͳ͍…
͍Ͳ͜Ζ 4 PC (Desktop / Server) ʹඞཁͳͦ͞͏͔ͳ… 4 ARM ʹϏϧυͰ͖ΔΑ͏ʹͳΕ…
4 JVM Λಈ͔͢΄ͲϦιʔεͷͳ͍Ϛγϯ(IoT)͚ͷϓ ϩάϥϜΛ Scala Ͱॻ͚Δͱ͔ 4 iOS ͷωΠςΟϒΞϓϦΛ Scala Ͱॻ͚ΔՄೳੑ?
ࢀߟ 4 ࡞ऀ Denys Shabalin ࢯͷϓϨθϯ https://github.com/densh/talks/blob/ 517b20c30dd4aaf390785039cdd002f623eaa91e/ 2016-05-11-scala-goes-native.pdf