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
580
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
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
130
Removing Corepack
yosuke_furukawa
PRO
9
1.2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.4k
Strip Types と Storage
yosuke_furukawa
PRO
4
330
Module Harmony について
yosuke_furukawa
PRO
3
1.5k
LTのやり方
yosuke_furukawa
PRO
16
2.1k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
690
Node.js v22 で変わること
yosuke_furukawa
PRO
13
5.2k
リアーキテクトと開発生産性について
yosuke_furukawa
PRO
25
9.5k
Other Decks in Programming
See All in Programming
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
4
1.5k
offers_20241022_imakiire.pdf
imakurusu
2
360
Synchronizationを支える技術
s_shimotori
1
150
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
950
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
色々なIaCツールを実際に触って比較してみる
iriikeita
0
260
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
Sidekiqで実現する 長時間非同期処理の中断と再開 / Pausing and Resuming Long-Running Asynchronous Jobs with Sidekiq
hypermkt
6
2.6k
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
Honoの来た道とこれから
yusukebe
19
3k
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Designing for humans not robots
tammielis
249
25k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Raft: Consensus for Rubyists
vanstee
136
6.6k
A Philosophy of Restraint
colly
203
16k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
For a Future-Friendly Web
brad_frost
175
9.4k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
Gamification - CAS2011
davidbonilla
80
5k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Git: the NoSQL Database
bkeepers
PRO
425
64k
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