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
React meets Nashorn #jjug_ccc #ccc_l8 /react-me...
Search
Manabu Matsuzaki
December 03, 2016
Technology
1
840
React meets Nashorn #jjug_ccc #ccc_l8 /react-meets-nashorn-jjug-ccc-2016-fall
JJUG CCC 2016 Fall で発表したスライドです
Manabu Matsuzaki
December 03, 2016
Tweet
Share
More Decks by Manabu Matsuzaki
See All by Manabu Matsuzaki
Spring BootユーザのためのArmeria入門 #jsug / Introduce to Armeria for Spring users
matsumana
0
2.6k
Canary Release with Argo Rollouts #ふくばねてす / canary-release-with-argo-rollouts
matsumana
1
1.1k
Getting started Central Dogma with Golang #fukuokago #umedago / getting-started-central-dogma-with-golang
matsumana
0
860
Micrometer入門 #javaq / introduce-to-micrometer
matsumana
1
2.7k
ArmeriaとCentral Dogmaから学ぶ、マイクロサービスに必要な機能 #edayfuk / lean-from-armeria-and-central-dogma
matsumana
0
4.1k
SREcon19 Americas 参加レポート #srefukuoka / srecon19-americas-report
matsumana
0
830
SRE入門 & チームで取り組んでいるSRE #srefukuoka / introduce-to-sre
matsumana
0
1.2k
Introduce to Armeria and Central Dogma #GWD_Nulab / introduce-to-armeria-and-central-dogma
matsumana
0
550
Connector/JでMaster/Slave Replication構成のMySQLに接続する #mysql_casual_fukuoka /connector-j-master-slave-replication
matsumana
0
1.4k
Other Decks in Technology
See All in Technology
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
900
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
440
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
140
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
13k
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
880
AIチャットボット開発への生成AI活用
ryomrt
0
170
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
Lexical Analysis
shigashiyama
1
150
心が動くエンジニアリング ── 私が夢中になる理由
16bitidol
0
100
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
Featured
See All Featured
Fireside Chat
paigeccino
34
3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
For a Future-Friendly Web
brad_frost
175
9.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Designing for humans not robots
tammielis
250
25k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Optimizing for Happiness
mojombo
376
70k
Why Our Code Smells
bkeepers
PRO
334
57k
Building Applications with DynamoDB
mza
90
6.1k
Transcript
React meets Nashorn JJUG CCC 2016 Fall 2016/12/03 @matsumana
ࣗݾհ • ໊લɿ দ࡚ ֶ • ॴଐɿ LINE Fukuokaגࣜձࣾ ։ൃࢧԉνʔϜ
• Twitterɿ @matsumana
ΞδΣϯμ • NashornͱReactͷ؆୯ͳհ • αʔόαΠυϨϯμϦϯάͷϝϦοτ • NashornͰReactΛಈ͔͢ʹ • NashornͰReactΛαʔόαΠυϨϯμϦ ϯάͯ͠ૺ۰ͨ͠
“αʔόαΠυϨϯμϦϯά” ͍ͷͰ Ҏ߱”SSR”ͱදه͠·͢
Nashornʹ͍ͭͯ
• Java8ʹಉࠝ͞Ε͍ͯΔJavaScriptΤϯδϯ (Java7·ͰRhinoͩͬͨ) • Java8ͷNashornͰ ECMA-262 Edition 5.1 ४ڌ •
Java9ͰES6ରԠ
https://blogs.oracle.com/wlc/entry/javaee_c117 ΑΓൈਮ • JavaScriptΛɺ͍ͬͨΜAST/IRʢநߏจ ʗதؒදݱʣͱ͍͏தؒੜʹม͠ɺͦ ͔͜ΒASMΛͬͯJavaόΠτίʔυΛੜ ͢Δ (JavaScript͕JavaόΠτίʔυʹͳΔ) • ͕ͨͬͯ͠ɺJavaScript͕ωΠςΟϒʹJVM্
Ͱಈ࡞͢ΔɻύϑΥʔϚϯεʹࢧো͕ͳ͍
JDK™ 9 Early Access Releases ͷNashornͰES6Λ ࢼ͢ࣄ͕ग़དྷ·͢ • JDK™ 9
Early Access Releases https://jdk9.java.net/download/ • JEP 292 http://openjdk.java.net/jeps/292
$ jjs -h jjs [<options>] <files> [-- <arguments>] … ུ
… --language (Specify ECMAScript language version.) param: [es5|es6] default: es5 … ུ … JDK™ 9 Early Access Releases Build 146Ͱࢼͯ͠ΈΔ
$ jjs --language=es6 jjs> let hello = (name) => 'Hello,
' + name; jjs> hello('World!'); Hello, World!
jjs> class Greet { ...> constructor(v) { ...> this.v =
v; ...> } ...> hello() { ...> return this.v; ...> } ...> } java.lang.RuntimeException: <shell>:1:0 ES6 class declarations and expressions are not yet implemented class Greet { ^
·ͩES6ͷશߏจ ͑ͳ͍
ࠓޙͷES6ରԠʹ͍ͭͯ • JavaOne 2016ͰʮWhat’s New in JDK 9?ʯ ͱ͍͏ηογϣϯ͕͋Γ·ͨ͠ ެ։͞ΕͨεϥΠυʹΑΔͱɺ
"Follow ups in minor releases"ͱͷࣄ https://oracle.rainfocus.com/scripts/ catalog/oow16.jsp? event=javaone&search=nashorn&showEnr olled=false&search.event=javaone
Reactʹ͍ͭͯ
ެࣜνϡʔτϦΞϧΑΓൈਮ React is a declarative, efficient, and flexible JavaScript library
for building user interfaces. (ReactϢʔβʔΠϯλʔϑΣΠεΛߏங͢ ΔͨΊͷએݴతͰޮతͰॊೈͳJavaScript ϥΠϒϥϦͰ͢)
ެࣜνϡʔτϦΞϧΑΓൈਮ
SSRͷϝϦοτ
• ॳճͷϖʔδද͕͍ࣔɺ ද͕ࣔνϥͭ͘ͱ͍͏͕ղܾͰ͖Δ • αʔόʔαΠυͱϑϩϯτΤϯυͰ ಉ͡ίʔυΛڞ༗Ͱ͖Δ (Universal JavaScript) ※ҎલIsomorphic JavaScriptͱݺΕ͍ͯͨ
NashornͰReactΛ ಈ͔͢ʹ
• Springͩͱ؆୯ʹग़དྷΔ Spring Framework 4.2ͰScript Templating ͱ͍͏ػೳ͕Ճ͞Ε͍ͯΔ https://spring.io/blog/2016/03/15/ springone2gx-2015-replay-isomorphic- templating-with-spring-boot-nashorn-and-
react
• ϒϥβͷJavaScriptڥʹଘࡏ͢Δ͕ Nashornʹଘࡏ͠ͳ͍ͷ͕͋ΔͷͰ ػೳͷ݀ΛຒΊΔඞཁ͕͋Δ(polyfill) • windowΦϒδΣΫτͳͲ
• Java8ͷNashornES5͔͠αϙʔτͯ͠ ͳ͍ͷͰES5Ͱॻ͔͘ ES6Ͱॻ͍ͯBabelͰτϥϯεύΠϧ͢Δ
• Java࠷৽όʔδϣϯΛ͏ • Java 8u66ͰҎԼͷ͕fix͞Ε͍ͯΔ • Nashorn react.js benchmark performance
regression http://www.oracle.com/technetwork/java/ javase/2col/8u66-bugfixes-2692105.html http://bugs.java.com/view_bug.do? bug_id=8134403
ૺ۰ͨ͠
ૺ۰ͨ͠ • NashornͷॳظԽॲཧ͕͍ ͳ͍ͥͷ͔ʁ
1. ReactεϨουηʔϑͰͳ͍ͷͰɺ NashornͷΠϯελϯεΛ ThreadLocalʹอ࣋͢Δඞཁ͕͋Δ (Spring͕ThreadLocalʹอ͍࣋ͯ͠Δ) ૺ۰ͨ͠
2. JavaScriptιʔε͔ΒASTΛੜͯ͠ JavaόΠτίʔυੜͱ͍͏ॲཧ͕ APαʔόͷεϨουຖʹߦΘΕΔ ૺ۰ͨ͠
3. Nashorn͕ॳظԽ͞Εͯͳ͍εϨουͰ HTTPϦΫΤετ͕ॲཧ͞ΕΔʹ ॳظԽॲཧ͕ߦΘΕΔ ૺ۰ͨ͠
ૺ۰ͨ͠ • ϫʔΫΞϥϯυ • ։ൃ࣌APαʔόͷεϨουΛݮΒ͢ • ຊ൪ͰΞϓϦىಈޙͷΥʔϜΞοϓ ॲཧΛݕ౼͢Δ
ͦͷଞ ؾΛ͚ͭΔࣄ • componentWillMountʹϑϩϯτΤϯυͰ͠ ͔ಈ࡞͠ͳ͍ίʔυΛॻ͍͍͚ͯͳ͍ componentWillMountSSRͰݺΕΔ͕ componentDidMountݺΕͳ͍ͱ͍͏ࣄ Λҙࣝͯ͠ίʔυΛॻ͘ඞཁ͕͋Δ
·ͱΊ • NashornͷॳظԽॲཧ͕͍ (ϫʔΫΞϥϯυ͋Δ) • αʔόαΠυͱϑϩϯτΤϯυͷ྆ํͰ ಈ͘ReactΞϓϦΛॻ͘ͷ͍͠ • SSR͕ඞཁ͔Α͘ݕ౼ͨ͠ํ͕ྑ͍
ϦϯΫू • Java SE 8ͷ৽JavaScriptΤϯδϯʮNashornʯ͕࣮ݱ͢Δ࣍ੈͷ “JavaScript in Java”ڥ • JEP
292 • What’s New in JDK 9? • Tutorial: Intro To React • SpringOne2GX 2015 replay: Isomorphic templating with Spring Boot, Nashorn and React • JDK 8u66 Bug Fixes • JDK-8134403 : Nashorn react.js benchmark performance regression • αϯϓϧιʔε