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
node.js in java OB
Search
Yosuke Furukawa
PRO
July 22, 2017
Programming
4
590
node.js in java OB
Java/Go OB会で話したNode.jsの話です。
Yosuke Furukawa
PRO
July 22, 2017
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
0
59
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
150
Removing Corepack
yosuke_furukawa
PRO
9
1.3k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.5k
Strip Types と Storage
yosuke_furukawa
PRO
4
340
Module Harmony について
yosuke_furukawa
PRO
3
1.5k
LTのやり方
yosuke_furukawa
PRO
16
2.2k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
700
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.3k
Other Decks in Programming
See All in Programming
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
CSC509 Lecture 09
javiergs
PRO
0
140
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
Better Code Design in PHP
afilina
PRO
0
130
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
2
140
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
イベント駆動で成長して委員会
happymana
1
340
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Featured
See All Featured
Docker and Python
trallard
40
3.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Why Our Code Smells
bkeepers
PRO
334
57k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Optimizing for Happiness
mojombo
376
70k
Being A Developer After 40
akosma
87
590k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Designing for humans not robots
tammielis
250
25k
Transcript
Node.js ୈ࢛ճ Java ݚम OB/OG ձ
Twitter: @yosuke_furukawa Github: yosuke-furukawa
Node.jsຊϢʔβʔάϧʔϓද Node.js Evangelist / Node.js Collaborator
+BWBݚमͷ࣌ͷ՝༻ͷ ΩϟϥΫλʔͰͨ͠
Why I use Node.js
ͱͱαʔόαΠυͷΤϯδχΞ 0SBDMF +BWB 40"1 MVDFOFFUD
#SPXTFS 4USVUT "1*4FSWFS 0SBDMF -VDFOF 'JMF 4ZTUFN ͱͱ͜ͷล୲
͖ͪΌͬͨ
#SPXTFS 4USVUT "1*4FSWFS 0SBDMF -VDFOF /'4 ͬͪ͜ͷํΛΓͨ͘ͳͬͨ
ཁ6*دΓͷॴΛͬͯ Έͨ͘ͳͬͨ ࣌ ࠒ ͔Β+BWB4DSJQUͷٕज़͕8FC ΞϓϦ࡞ʹඞਢʹͳ͍ͬͯͨɻ Ͱ͍͖ͳΓ+BWB4DSJQUͰ6*ͷͱ͜Ζͬͯ Α͔͘Βͳͦ͞͏ͩͱࢥͬͨɻ ͳͷͰͻͱ·ͣΑͬͯ͘ΔαʔόαΠυͰ +BWB4DSJQUֶΜͰΈΑ͏ͱɻ
None
໘നͦ͏Μ͚
HTTP Server
HTTP Server const http = require('http'); const hostname = '127.0.0.1';
const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ͜Ε͚ͩͰಈ͘खܰ͞
ָ͍͠ʂʂʂ
Realtime Server
socket.io-video
IoT
None
Desktop Application (Electron)
None
Node.js
13ษڧձͳͲͷߩݙ͕ೝΊΒΕͯ /PEFKT$PMMBCPSBUPS/PEFKT&WBOHFMJTU ʹͳΔɻ
Node.js ͱԿ͔
2001 2008 2009 2010 2011 2012 2015ʙ /PEFKTJTCPSO
3ZBO%BIM 5IF'BUIFSPG/PEF
Ryan Dahl talks about Node.js in JSConf.eu 2009
None
Node.js in brief • Server-Side JavaScript • Evented, Non-Blocking I/O
Similar to EventMachine • Built on Google’s V8
Node.js in brief • Server-Side JavaScript • Evented, Non-Blocking I/O
Similar to EventMachine • Built on Google’s V8 8IZ/PEFDIPPTFUIFTF BSDIJUFDUVSF
2001 2008 2009 2010 2011 2012 2015ʙ $,1SPCMFN
ຊͰ ʮ8FCͷઌʹ͋Δ$,ʯ ͱ͔هࣄ͕͔͔ΕΔ
$,1SPCMFNJT w ͪΐʔͨ͘͞ΜͷΫϥΠΞϯτ , ͕Ұʹଓ ͨ͠Βαʔόʔࢮ͵ΑͶ͍ͬͯ͏ w ࣌ͷϑϩϯτ"QBDIF͕ओྲྀ w "QBDIFϓϩηεεϨουϞσϧ
w ΫϥΠΞϯτ͕ଓ͢ΔʹϓϩηεPSεϨου͕ ্͕ΔͱϝϞϦ͍·͘ΒΕͯɺɺɺ ޙ͔Δͳɻ
͜ͷ࣌ͷΈΜͳͷԠ ʮͰ,͔͞Ͷʔ͠XXXXʯ
γϯϓϧͳIUUQϦΫΤετͳΒ ͦ͏ͩͱࢥ͏ɻ
8FC࣌4/4࣌
Ϣʔβʔ͕αΠτʹࡏ͢Δ ͕࣌ؒ૿͑Δ࣌ ϝοηʔδ͕དྷ·ͨ͠ ͍͍Ͷ͞Ε·ͨ͠
"KBYͱ͔9)3-POH1PMMJOH ͕ྲྀߦΓ͡Ίͨ࣌
$POOFDUJPO͕ଟ͘ͳͬͯैདྷͷΞʔΩς ΫνϟͰ·͔ͳ͖͑Εͳ͘ͳ͖ͬͯͨ
None
"QBDIFWT/HJOY "QBDIF /HJOY XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS
XPSLFS XPSLFS
"QBDIFWT/HJOY "QBDIF /HJOY XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS
XPSLFS XPSLFS ϦΫΤετͷʹXPSLFSεϨου͕ىಈ ͠ɺϝϞϦ͕ඡഭ͞ΕΔڪΕɺ·ͨεϨου ͕ଟ͍ͱεϨουΓସ͑ίετߴ͍
"QBDIFWT/HJOY "QBDIF /HJOY XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS XPSLFS
XPSLFS XPSLFS γϯάϧεϨουͳͷͰίωΫγϣϯ͕ ͨ͘͞Μ͋ͬͯXPSLFSىಈ͠ͳ͍ Ϧιʔε͕ޮత
͜Μͳײ͡Ͱ$,͕૽͕Ε͔ͯΒ Πϕϯτϧʔ ϓϞσϧ͕ྲྀߦΓͩ͢ɻ
"OZ&WFOU 1FSM &WFOU.BDIJOF 3VCZ 5XJTUFE 1ZUIPO ͜Μͳײ͡Ͱ$,͕૽͕Ε͔ͯΒ Πϕϯτϧʔ ϓϞσϧ͕ྲྀߦΓͩ͢ɻ
ͨͩ͠ɺ͜ΕΒͷݴޠ 3VCZ 1ZUIPO ʹ طʹ'JMF/FUXPSL*0ͷಉظॲཧ͕ଘࡏ͢ Δ
'JMF/FUXPSL*0ॲཧ͍
'JMF/FUXPSL*0ॲཧ͍
&WFOU-PPQ ͕͔͔࣌ؒΔϑΝΠ ϧ*0ωοτϫʔΫ ܥͷॲཧग़དྷΔݶ Γඇಉظʹ͢Δ͖ɻ
ΠϕϯτϧʔϓϞσϧྑ͍͕ɺط ଘͷ*0ಉظܥͷॲཧແ͍ͨ͘͠ɻ ඇಉظ*0ॲཧΛڧ੍͍ͤͨ͞ɻ
ඇಉظϥΠϒϥϦͱͯ͠MJCFW͕࠾༻͞Εɺ ޙʹMJCVWͱͳΓɺϚϧνϓϥοτϑΥʔ ϜͰߴͳඇಉظ*0͕࣮ݱ͞ΕΔ
2001 2008 2009 7JTCPSO 2010 2011 2012 2013 2014
function hoge() { console.log(“Hello Hello”); } function fuga() { //
fugafufa console.log(“World World”); } +BWB4DSJQU ͜Ε·Ͱ ߏจղੳ > Hello Hello > World World ࣮ߦ
function hoge() { console.log(“Hello Hello”); } function fuga() { //
fugafufa console.log(“World World”); } +BWB4DSJQU ͜Ε·Ͱ ߏจղੳ > Hello Hello > World World ࣮ߦ ͍
function hoge() { console.log(“Hello Hello”); } function fuga() { //
fugafufa console.log(“World World”); } +BWB4DSJQU 7 > Hello Hello > World World ಈతʹϚγϯޠʹม 0100101 0010010 1010101 0101010 1010100 ࣮ߦ ΊͬͪΌ͍
$,Λղܾ͢ΔΠϕϯτϧʔϓϞσϧ ߴͳඇಉظ*0ͱͦΕΛڧ੍Մೳͳݴޠ ઈ͍ॲཧܥ
$,Λղܾ͢ΔΠϕϯτϧʔϓϞσϧ ߴͳඇಉظ*0ͱͦΕΛڧ੍Մೳͳݴޠ ઈ͍ॲཧܥ 3ZBO%BIM͕ඞཁͱͯ͠ ͍ͨͷɻ
͔ͯ͘͠/PEFKTੜ
/PEFKTͱԿͳͷ͔ ඇಉظϥΠϒϥϦͱΠϕϯτϧʔϓϞσϧͰಈ͘ߴ ͔ͭলϦιʔεͳ+BWB4DSJQU࣮ߦڥ 8FC4PDLFUɺ44&ͷΑ͏ʹίωΫγϣϯΛுΓͬͺ ͳ͠ʹ͢ΔϞϊɺϦΫΤετ͕ଟ͍ΞϓϦέʔγϣ ϯͱੑ͕ߴ͍ɻ ԿʹͰ͘ϫέ͡Όͳ͍ɻવ͔ͳ͍͋Δɻ /PEFKT͚ͩͰແཧΛ͠ͳ͍ࣄॏཁɻదࡐదॴͰ ͍͚ͨํ͕ྑ͍ͱ͍͏ɻ
·ͱΊ
/PEFKTͱࢲ /PEFKTΛ৮Γ࢝Ίͯ6*ଆόοΫΤϯυଆΘ͔ΔΤ ϯδχΞʹɻ ΔͳΒͱ͜ͱΜɺͱ͍͏͜ͱͰ৽͍ٕ͠ज़͕ग़ͯ͘Δ ͨͼʹ৮͍ͬͯͨ݁Ռɺ&WBOHFMJTU$PMMBCPSBUPSʹ /PEFKTͱԿ͔ ඇಉظϥΠϒϥϦͱΠϕϯτϧʔϓϞσϧͰಈ͘ߴ͔ ͭলϦιʔεͳ+BWB4DSJQU࣮ߦڥ ·ͱΊ
JavaษڧձOBͱͯ͠
ඇৗʹษڧʹͳͬͨ ಛʹԿ͔࡞ͬͯݟͤΔ෦͘͢͝ྑ͔ͬͨ ͋ͱɺ&⒎FDUJWF+BWBͷ༰ࠓͰΑ͘ ͍·͢ +BWB4DSJQUͰֶΔॴଟ͍ ɻ ࣲా͞Μ͕+BWBͷߨࢣͱͯ͠ϦΫϧʔτςΫ ϊϩδʔζͰ৽ਓͷ໘Λݟͯ͘Εͳ͍͔ͱࢥͬ ͯͨΓɻ JavaษڧձOB