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
850
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.7k
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
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
260
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
C++26 エラー性動作
faithandbrave
2
720
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
MLOps の現場から
asei
6
640
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
260
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
31k
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
13
3.6k
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
470
Featured
See All Featured
Side Projects
sachag
452
42k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Making Projects Easy
brettharned
116
5.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Unsuck your backbone
ammeep
669
57k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Faster Mobile Websites
deanohume
305
30k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
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 • αϯϓϧιʔε