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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
AGAWA Koji
May 27, 2016
Programming
320
0
Share
scala-native 試してみた
社内 Scala Meetup 2016-05-26
AGAWA Koji
May 27, 2016
More Decks by AGAWA Koji
See All by AGAWA Koji
Software Architecture in an AI-Driven World
atty303
79
46k
PipeCDプラグインへの期待 / Anticipating PipeCD Plugins
atty303
0
120
EmscriptenでC/C++アプリをWASM化してブラウザで動かしてみた
atty303
0
650
良いソフトウェアとコードレビュー / Good software and code review
atty303
38
18k
Scala + Caliban で作るGraphQL バックエンド / Making GraphQL Backend with Scala + Caliban
atty303
0
590
Scala.jsとAndroidでドメイン層を共有しよう / Scala.js and Android
atty303
0
810
もう一つのビルドツール mill で作る Docker イメージ / Build docker image with mill the yet another build tool
atty303
2
2.6k
Case of Ad Delivery System is Implemented by Scala and DDD
atty303
4
3.7k
ログのメトリックを取ってみる話
atty303
0
1k
Other Decks in Programming
See All in Programming
3Dシーンの圧縮
fadis
1
460
Claspは野良GASの夢をみるか
takter00
0
130
Swiftのレキシカルスコープ管理
kntkymt
0
200
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
2.4k
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
430
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
1.5k
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
6
1.3k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
240
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
660
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
310
Modding RubyKaigi for Myself
yui_knk
0
750
分析エージェント精度向上における データアナリストの役割
oura_shoya
0
130
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Designing Powerful Visuals for Engaging Learning
tmiket
1
380
Navigating Weather and Climate Data
rabernat
0
200
GitHub's CSS Performance
jonrohan
1033
470k
Test your architecture with Archunit
thirion
1
2.3k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
380
The Pragmatic Product Professional
lauravandoore
37
7.3k
How to make the Groovebox
asonas
2
2.2k
Marketing to machines
jonoalderson
1
5.3k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
850
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
270
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