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
Concurrent SSJS on the JVM
Search
Philipp Naderer
February 19, 2014
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Concurrent SSJS on the JVM
Presentation from the Fronteers Jam Session 2012 in Amsterdam.
Philipp Naderer
February 19, 2014
More Decks by Philipp Naderer
See All by Philipp Naderer
Im Maschinenraum der Corona-Dashboards
botic
0
79
The Making of a Coronavirus Dashboard
botic
0
150
Seestadt.bot @ Demo Night: Chatbots & Voice Apps
botic
0
130
Seestadt come2gether – StadtKatalog
botic
0
75
Location-aware Documents
botic
0
120
Chatbots @ HacksHackers Munich
botic
0
100
Chatbots @ Mediencamp Vienna
botic
0
180
GEN Editors Lab Munich – BotOx / Team ORF
botic
0
310
Final Master Thesis Presentation
botic
0
190
Other Decks in Programming
See All in Programming
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
360
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
320
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
2
1.3k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.8k
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
170
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.9k
フィードバックで育てるAI開発
kotaminato
1
120
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
300
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
210
どこまでゆるくて許されるのか
tk3fftk
0
480
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Bash Introduction
62gerente
615
220k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
210
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
180
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
390
Unsuck your backbone
ammeep
672
58k
The Curious Case for Waylosing
cassininazir
1
430
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
For a Future-Friendly Web
brad_frost
183
10k
Transcript
Concurrent SSJS on the JVM Philipp Naderer / @botic
None
None
RingoJS • JavaScript on the JVM • Based on Mozilla
Rhino • Part of Java SE 6 and Java SE 7 • Successor / Rewrite of Helma • 14 years of SSJS experience!
Features • CommonJS modules & packages • Full access to
Java libraries • ECMAScript 5 and JS 1.8 support • Lots of „ringo/“ modules • dates, http, concurrency, logging, subprocesses, jsgi, command line, ...
Debugger
Threads and SSJS? • Ringo‘s concept: Workers • Implicit multithreaded
code • You can use an EventLoop • No shared global object* • Singletons instead of shared data
myWebApp Module myWebApp Module blocking running running Event Loop
webserver.js var response = require("ringo/jsgi/response"); var {Application} = require("stick"); !
var app = exports.app = new Application(); ! // Configure stick middlewares app.configure("notfound", "route"); ! app.get("/", function(request) { return response.html("<h1>Servas Amsterdam!</h1>"); }); ! if (require.main == module) { require("ringo/httpserver").main(module.id); }
webserver.js serving 10.000 HTTP requests
„Ringo Workers“ • Look like Web Workers in Browsers •
No JSON serialization needed = faster! • Send a message with postMessage(e) • React on message with onMessage(e) • Return the result to the caller with postMessage(e)
fibobuster.js 1. var {Worker} = require("ringo/worker"); 2. 3. // Create
50 Workers = 50 Threads 4. for (var i = 50; i < 100; i++) { 5. var w = new Worker(module.resolve("./fibonacci")); 6. 7. // Callback for the output 8. w.onmessage = function(returnObj) { 9. console.log("Result: " + returnObj.data.result); 10. } 11. 12. // Start with the calculation 13. w.postMessage(i); 14. }
fibonacci.js function onmessage(message) { var limit = message.data; ! console.log("Fibonacci
#" + limit); ! /* Calculate the fibonacci number */ var a = ..., b = ..., c = ...; for (...) { ... } ! message.source.postMessage({ result: c }); }
RingoJS infos • ringojs.org – basic information • github.com/ringojs –
source + examples • @ringojs – official account • @hannesw – Hannes‘ account • IRC: irc.freenode.net #ringojs
None