Helma / RingoJS – Vienna.js Minitalk

688 views
588 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
688
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Helma / RingoJS – Vienna.js Minitalk

  1. 1. Helma / RingoJS Philipp Naderer / @botic
  2. 2. Helma / RingoJS• JavaScript on the JVM• Both based on Mozilla Rhino• Helma is EOF, 1998 – 2008• RingoJS is the successor of Helma
  3. 3. 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, ...
  4. 4. Debugger
  5. 5. Multithreaded JS?• Ringo‘s concept: Workers• You can still use an EventLoop• No shared global object*• Singletons instead of shared data
  6. 6. 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)
  7. 7. fibobuster.js1. var {Worker} = require("ringo/worker");2.3. // Create 50 Workers = 50 Threads4. for (var i = 50; i < 100; i++) {5. var w = new Worker(module.resolve("./fibonacci"));6.7. // Callback for the output8. w.onmessage = function(returnObj) {9. console.log("Result: " + returnObj.data.result);10. }11.12. // Start with the calculation13. w.postMessage(i);14. }
  8. 8. fibonacci.jsfunction onmessage(message) { var limit = message.data; console.log("Fibonacci #" + limit); /* Calculate the fibonacci number */ var a = ..., b = ..., c = ...; for (...) { ... } message.source.postMessage({ result: c });}
  9. 9. webserver.jsvar response = require("ringo/jsgi/response");var {Application} = require("stick");var app = exports.app = new Application();// Configure stick middlewaresapp.configure("notfound", "route");app.get("/", function(request) { return response.html("<h1>I‘m a todo app!</h1>");});if (require.main == module) { require("ringo/httpserver").main(module.id);}
  10. 10. webserver.js serving 10.000 HTTP requests
  11. 11. More infos• ringojs.org – basic information• github.com/ringojs – source + examples• @ringojs – official account• IRC: irc.freenode.net #ringojs

×