Slide 1

Slide 1 text

RingoJS Philipp Naderer @botic

Slide 2

Slide 2 text

History 1998 Helma 2008 HelmaNG 2010 RingoJS - monolithic - HopObject as root prototype - objects are mapped to db tables - advanced code repository loaders - modular approach - CommonJS modules - core modules provided - CommonJS modules - Ringo-specific modules - packages (reusable modules) - hot code reloading

Slide 3

Slide 3 text

What is RingoJS? “Ringo is a JavaScript platform built on the JVM and optimized for server-side applications. It takes a non- dogmatic stance on things like I/O paradigms.”

Slide 4

Slide 4 text

What is RingoJS? ● multi-threaded JavaScript ● CommonJS compatible ● ES5 + some ES6 ● code repository manager ● optimized to run scalable web application

Slide 5

Slide 5 text

What Ringo is not … ● copying node / io.js ● compatible with npm ● the fastest async io framework ● used by thousands of devs ● JEE or similar enterprise stuff ● single-threaded

Slide 6

Slide 6 text

What we know so far … ● Ringo has a history back to 1998 ● its running on the JVM ● uses multiple threads in parallel ● supports blocking and non-blocking I/O ● is not enterprise JavaScript

Slide 7

Slide 7 text

So it’s time to get started! ● Install OpenJDK or Oracle’s JRE ● Download Ringo ○ ZIP / tarball: download and extract, add /bin to PATH ○ Homebrew: brew install ringojs ● Run ringo

Slide 8

Slide 8 text

Demo …

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Internals

Slide 11

Slide 11 text

Ringo’s Java part is small and compact JavaScript 61.4% Java 38.3% Shell 0.3%

Slide 12

Slide 12 text

JVM JRE Rhino JavaScript Engine RhinoEngine Class Module Loaders Workers Code Repositories Java parts of Ringo Ringo JsgiServlet

Slide 13

Slide 13 text

JavaScript parts ● CommonJS modules ○ io, fs, binary, assert, gobals, system, net, … ● Ringo modules ○ daemon, engine, logging, promise, term, worker, httpserver, httpclient, … ● Ringo utility modules ○ strings, dates, objects, numbers, files, …

Slide 14

Slide 14 text

Workers?

Slide 15

Slide 15 text

Workers solve this “cute” problem: Multithreading Theory Practice

Slide 16

Slide 16 text

Let’s say we have to build a house …

Slide 17

Slide 17 text

Avoid concurrency at all … One single worker, but powerful and the worker never has to wait for resources. This is node & io.js

Slide 18

Slide 18 text

… or assign every worker a special task Multiple workers, but no shared resources. This is Ringo’s approach!

Slide 19

Slide 19 text

Web Apps?

Slide 20

Slide 20 text

Create a simple web application ringo-admin create -h Creates a Ringo application or package. Usage: ringo-admin create [options] [path] Options: -a --app-source [DIR] Copy application from [DIR] instead of skeleton -g --google-appengine Create a new Google App Engine application -p --ringo-package Create a new Ringo package -s --symlink Create symbolic links for jar and module files -w --java-webapp Create a new Java Web application (WAR)

Slide 21

Slide 21 text

Demo …

Slide 22

Slide 22 text

Ringo’s web stack

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Oh nice, but npm?

Slide 25

Slide 25 text

rp package manager ● ringo-admin install grob/rp ● find & publish packages at packages.ringojs.org ● rp is the command line tool ○ download, install & publish packages ○ packages are downloaded into a packages directory ○ to get help: rp help [install | publish | ...]

Slide 26

Slide 26 text

rp package manager ● rp install ● rp install -g ringo-sqlstore ● rp install ringo-sqlstore // loads the installed package var sqlst = require("ringo-sqlstore");

Slide 27

Slide 27 text

Popular packages ● stick – web application framework ● reinhardt – Django-like templating ● ringo-sqlstore – JavaScript-based ORM ● gestalt – easy configuration management

Slide 28

Slide 28 text

but still …

Slide 29

Slide 29 text

Haters gonna hate …

Slide 30

Slide 30 text

“java guys doing something stupid”

Slide 31

Slide 31 text

“ringojs created because the java guys believe java and want to integrate javascript with java on the server side.” True! We want to use the power of the JVM to run JavaScript on the server.

Slide 32

Slide 32 text

Why JavaScript on the JVM? ● Interpreted language → hot code reloading! ● JVM is a very stable and fast technology ● A huge ecosystem exists (Java & JavaScript) ● Web developers know JavaScript ● Server admins know the JVM

Slide 33

Slide 33 text

“Java guys believe in Java …”

Slide 34

Slide 34 text

“Java guys believe in Java …” ● Enterprise-proven money representation? ○ Joda-Money instead of 0.1 + 0.2 = 0.30000000000000004 ● Timezones? Timezone updates? ○ Joda-Time or java.time (Java SE 8) ● An alternative if your company is JEE hell? ○ Ringo runs seamless in servlet containers

Slide 35

Slide 35 text

“nodejs created because Ryan want a effective way to create net app no I/O blocking. He choose javascript because js has no old/outdated libs, which usually are the main problem of your I/O blocking.”

Slide 36

Slide 36 text

JSON.parse is provided by V8 and synchronous!

Slide 37

Slide 37 text

And till the end, we've found js is so beautiful and java IS SO UGLY. If you look at Ringo’s Java core, you find a lot of beautiful and amazing Java code. Hannes, the creator of Ringo, worked on it for years.

Slide 38

Slide 38 text

Only stupid guy want to use java to rebuild js. JavaScript → language, JVM → abstract machine There are a lot of JVM-languages available: Java, Scala, JavaScript, Clojure, Groovy, …

Slide 39

Slide 39 text

That’s it! Resources: ringobeta.hoffburg.at ringojs.org