SlideShare a Scribd company logo
頑皮工坊
Sleepnova Inc. 創
 辦人暨執行長
     周立瑋
自我介紹

頑皮工坊 Sleepnova Inc. 創辦人暨執行長,KKBOX Android
技術顧問。
(Android 與雲端技術顧問公司)

感興趣的領域:
- 敏捷開發,尋找更符合人性的程式設計典範。
- 可應付高承載的延展性架構。
- 思考資訊人為社會做點什麼?
過去經歷

Talks:
 ● Javascript take-off to the clouds - Server-side Javascript

   @ COSCUP 2009
 ● The NoSQL movement: CouchDB as an example @

   COSCUP 2010
Projects:
 ● 東森大選即時開票系統,締造兩千兩百萬 req / 4 hr 記錄
最近 node.js 來勢洶洶, 怎麼辦? 別
 怕, 我們也有秘密武器 RingoJS!
簡介



簡介 RingoJS 的特色,如何使用 RingoJS 在 JVM
上面快速開發,以及如何在專案中同時保有
scripting 的靈活度以及使用既有的 Java Library。
Why JavaScript
The native language of
       the web
JavaScript 到底是不是個語言?
About JavaScript

●   Javascript vs. Java <恩怨情仇>
●   JavaScript 不能拿來寫大系統?
●   CommonJS module system
RingoJS overview

●   Developed by Hannes Wallnöfer (hns.github.com)
●   Based on Mozilla Rhino
●   Runs on JVM
●   Orignal named HelmaNG
●   Follow CommonJS
Node.js vs RingoJS

1.   VM maturaty
2.   Community size
3.   Library base
4.   Java interopability
5.   Single-thread vs. Multi-thread
Node.js vs RingoJS

●   VM optimize for browser          ●   Quite mature enterprise grade VM
●   Young community                  ●   Big community
●   Not much library but will grow   ●   Lots of Java library
●   No Java interoperability         ●   Very good Java interoperability
●   Single thread                    ●   Multi-thread
Rhino JavaScript Engine

●   JavaScript <-> Java inter-operation
     ○ Access Java packages and classes

     ○ Working with Java objects

     ○ Inherit class/interface

●   E4X
Accessing Java packages and
classes
js> Packages.java
[JavaPackage java]

js> java
[JavaPackage java]

js> java.io.File
[JavaClass java.io.File]

js> importPackage(java.io)
js> File
[JavaClass java.io.File]
Working with Java objects


js> new java.util.Date()
Thu Jan 24 16:18:17 EST 2002

var File = java.io.File;
var myfile = new File("sample.txt");
Working with Java objects


js> f = new java.io.File("test.txt")
test.txt
js> f.exists()
true
js> f.getName()
test.txt
Implementing Java Interfaces

js> obj = { run: function () { print("nrunning"); } }
[object Object]
js> obj.run()

running

js> r = new java.lang.Runnable(obj);
[object JavaObject]
Implementing Java Interfaces



js> r = new java.lang.Runnable({
   run: function () { print("nrunning"); }
   });
[object JavaObject]
Working with Java objects


  js> for (i in f) { print(i) }
  exists
  parentFile
  mkdir
  toString
  wait
特異功能 E4X
var sales = <sales vendor="John">
  <item type="peas" price="4" quantity="6"/>
  <item type="carrot" price="3" quantity="10"/>
  <item type="chips" price="5" quantity="3"/>
 </sales>;

alert( sales.item.(@type == "carrot").@quantity );
alert( sales.@vendor );
for each( var price in sales..@price ) {
  alert( price );
}
delete sales.item[0];
sales.item += <item type="oranges" price="4"/>;
sales.item.(@type == "oranges").@quantity = 4;
RingoJS


●   Minimal web app
●   Packages
●   Storage
●   AppEngine
Hello World!
exports.app = function(req) {
   return {
      status: 200,
      headers: {"Content-Type": "text/plain"},
      body: ["Hello World!"]
   };
};

if (require.main == module)
    require("ringo/httpserver").main(module.id);
Ringo Shell



>> var fs = require('fs');
>> var file = fs.open('README.md');
>> var lines = [line for (line in file)];
Handle HTTP Request
// actions.js
var Response = require('ringo/webapp/response');
var model = require('./model');

exports.index = function(req) {
   var posts = model.Post.query().select().slice(0,10);
   return Response.skin('skins/index.html', {
       posts: posts,
   });
};
Skins


// in a skin
<% for post in <% posts %> render 'postOverview' %>

<% subskin 'postOverview' %>
  <h2><% post.title %></h2>
URL mapping



// config.js
exports.urls = [
    ['/', './actions'],
];
Database


●   ringo-sqlstore
●   berkeleystore
●   cassandrastore
●   mongodbstore
●   redis-ringojs-client
●   Google App Engine Datastore API
Mongodbstore
Initializing the store:
include('ringo/storage/mongodbstore');
store = new Store('server', 27017, 'dbName');

Creating a new Storable class:
Book = store.defineEntity('book');

Creating and saving a new Storable instance:
var b = new Book({title: "DBs for dummies"});
b.save();
Mongodbstore
Retrieving all objects from a db:
var books = Book.all();

Retrieving an object by id:
var book = Book.get(id);

Deleting an object from the db:
book.remove();

Running a query on the database:
Book.query().equals('prop', value).select();
Berkeleystore
Initializing the store:
include('ringo/storage/berkeleystore');
store = new Store(dbpath);

Creating a new Storable class:
Book = store.defineEntity('book');

Creating and saving a new Storable instance:
var b = new Book({title: "DBs for dummies"});
b.save();
天下沒有白痴的午餐
天下沒有白吃的午餐
Performance characteristic

●   Translation to JVM bytecode
●   JVM is not a perfect dynamic language VM
    yet!
Performance characteristic

$ node v8bench.js
19 Aug 16:13:33 - Score (version 5): 4090

$ java -Xmx265m -jar js.jar run.js
Score (version 5): 120

[larger is better]
~1/34
Node.js vs RingoJS GC Benchmark




                   http://hns.github.com/2010/09/29/benchmark2.html
Future of JavaScript Engine

JavaScript engine
● Nashorn, dyn.js
● InvokeDynamic
JavaScript territory

●   Titanium
●   CouchDB
●   Unity
●   node.js + webkit
●   RingoJS + SWT
●   ES operating system
●   Ubuntu Desktop
Stay Hungry, Stay Foolish!

More Related Content

What's hot

MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
Dave Stokes
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
Johannes Hoppe
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Alex Bilbie
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
Johannes Hoppe
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik
 
Drupal 7: What's In It For You?
Drupal 7: What's In It For You?Drupal 7: What's In It For You?
Drupal 7: What's In It For You?
karschsp
 
Latinoware
LatinowareLatinoware
Latinoware
kchodorow
 
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
Dave Stokes
 
Sequel
SequelSequel
Building Your First MongoDB App
Building Your First MongoDB AppBuilding Your First MongoDB App
Building Your First MongoDB App
Henrik Ingo
 
Seedhack MongoDB 2011
Seedhack MongoDB 2011Seedhack MongoDB 2011
Seedhack MongoDB 2011
Rainforest QA
 
London MongoDB User Group April 2011
London MongoDB User Group April 2011London MongoDB User Group April 2011
London MongoDB User Group April 2011
Rainforest QA
 
MongoDB
MongoDBMongoDB
CouchDB Open Source Bridge
CouchDB Open Source BridgeCouchDB Open Source Bridge
CouchDB Open Source Bridge
Chris Anderson
 
Dynamic SQL in doobie
Dynamic SQL in doobieDynamic SQL in doobie
Dynamic SQL in doobie
chibochibo
 
Vanilla JS*
Vanilla JS*Vanilla JS*
Vanilla JS*
Théodore Biadala
 
Getting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG DenmarkGetting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG Denmark
Mauricio (Salaboy) Salatino
 
nodecalgary1
nodecalgary1nodecalgary1
nodecalgary1
Eric Kryski
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
Scott Hernandez
 

What's hot (20)

MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
MySQL Without the SQL - Oh My! -> MySQL Document Store -- Confoo.CA 2019
 
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
2012-03-20 - Getting started with Node.js and MongoDB on MS Azure
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and GrailsPhilip Stehlik at TechTalks.ph - Intro to Groovy and Grails
Philip Stehlik at TechTalks.ph - Intro to Groovy and Grails
 
Drupal 7: What's In It For You?
Drupal 7: What's In It For You?Drupal 7: What's In It For You?
Drupal 7: What's In It For You?
 
Latinoware
LatinowareLatinoware
Latinoware
 
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
MySQL Without the SQL - Oh My! August 2nd presentation at Mid Atlantic Develo...
 
Sequel
SequelSequel
Sequel
 
Building Your First MongoDB App
Building Your First MongoDB AppBuilding Your First MongoDB App
Building Your First MongoDB App
 
Seedhack MongoDB 2011
Seedhack MongoDB 2011Seedhack MongoDB 2011
Seedhack MongoDB 2011
 
London MongoDB User Group April 2011
London MongoDB User Group April 2011London MongoDB User Group April 2011
London MongoDB User Group April 2011
 
MongoDB
MongoDBMongoDB
MongoDB
 
CouchDB Open Source Bridge
CouchDB Open Source BridgeCouchDB Open Source Bridge
CouchDB Open Source Bridge
 
Dynamic SQL in doobie
Dynamic SQL in doobieDynamic SQL in doobie
Dynamic SQL in doobie
 
Vanilla JS*
Vanilla JS*Vanilla JS*
Vanilla JS*
 
Getting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG DenmarkGetting Started With #Drools 6 Slides - JBUG Denmark
Getting Started With #Drools 6 Slides - JBUG Denmark
 
nodecalgary1
nodecalgary1nodecalgary1
nodecalgary1
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
 

Viewers also liked

吳宗泓個人簡歷
吳宗泓個人簡歷吳宗泓個人簡歷
吳宗泓個人簡歷
宗泓 Brian Wu 吳
 
Patent Management Along Its Life Cycle
Patent Management Along Its Life CyclePatent Management Along Its Life Cycle
Patent Management Along Its Life Cycle
Hsien-Yung Yi
 
洪毅昕Openmic 理念說明
洪毅昕Openmic 理念說明洪毅昕Openmic 理念說明
洪毅昕Openmic 理念說明
宜璇 蔡
 
2016 【CMoney實習生計畫】
2016 【CMoney實習生計畫】2016 【CMoney實習生計畫】
2016 【CMoney實習生計畫】
tzu hsuan Yang
 
創人物Vol.1 - 兩分鐘自我介紹
創人物Vol.1 - 兩分鐘自我介紹創人物Vol.1 - 兩分鐘自我介紹
創人物Vol.1 - 兩分鐘自我介紹交點
 
Robot 解析
Robot 解析Robot 解析
Robot 解析
Hongwei Huang
 
1、第一堂課 自我介紹
1、第一堂課 自我介紹1、第一堂課 自我介紹
1、第一堂課 自我介紹
芊如 賴
 
交點聚會2分鐘自我介紹範本
交點聚會2分鐘自我介紹範本交點聚會2分鐘自我介紹範本
交點聚會2分鐘自我介紹範本
典雅 古
 
英文面試自我介紹
英文面試自我介紹英文面試自我介紹
英文面試自我介紹
Hsien-Yung Yi
 
[資管系 業界講師]演講題目:我的It人生
[資管系 業界講師]演講題目:我的It人生[資管系 業界講師]演講題目:我的It人生
[資管系 業界講師]演講題目:我的It人生
MIS2000 Lab.
 
吳崑榮 自我介紹
吳崑榮 自我介紹吳崑榮 自我介紹
吳崑榮 自我介紹
吳崑榮
 

Viewers also liked (11)

吳宗泓個人簡歷
吳宗泓個人簡歷吳宗泓個人簡歷
吳宗泓個人簡歷
 
Patent Management Along Its Life Cycle
Patent Management Along Its Life CyclePatent Management Along Its Life Cycle
Patent Management Along Its Life Cycle
 
洪毅昕Openmic 理念說明
洪毅昕Openmic 理念說明洪毅昕Openmic 理念說明
洪毅昕Openmic 理念說明
 
2016 【CMoney實習生計畫】
2016 【CMoney實習生計畫】2016 【CMoney實習生計畫】
2016 【CMoney實習生計畫】
 
創人物Vol.1 - 兩分鐘自我介紹
創人物Vol.1 - 兩分鐘自我介紹創人物Vol.1 - 兩分鐘自我介紹
創人物Vol.1 - 兩分鐘自我介紹
 
Robot 解析
Robot 解析Robot 解析
Robot 解析
 
1、第一堂課 自我介紹
1、第一堂課 自我介紹1、第一堂課 自我介紹
1、第一堂課 自我介紹
 
交點聚會2分鐘自我介紹範本
交點聚會2分鐘自我介紹範本交點聚會2分鐘自我介紹範本
交點聚會2分鐘自我介紹範本
 
英文面試自我介紹
英文面試自我介紹英文面試自我介紹
英文面試自我介紹
 
[資管系 業界講師]演講題目:我的It人生
[資管系 業界講師]演講題目:我的It人生[資管系 業界講師]演講題目:我的It人生
[資管系 業界講師]演講題目:我的It人生
 
吳崑榮 自我介紹
吳崑榮 自我介紹吳崑榮 自我介紹
吳崑榮 自我介紹
 

Similar to 最近 node.js 來勢洶洶, 怎麼辦? 別怕, 我們也有秘密武器 RingoJS!

Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
Pascal Rettig
 
Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDB
Jeff Yemin
 
Brightstar DB
Brightstar DBBrightstar DB
Brightstar DB
Connected Data World
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
MongoDB
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
MongoDB APAC
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010
Christian Heilmann
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
Marcelo Ochoa
 
How to React Native
How to React NativeHow to React Native
How to React Native
Dmitry Ulyanov
 
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
Hazelcast
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache sling
Sergii Fesenko
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
Marcus Lagergren
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with Morphia
MongoDB
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB App
MongoDB
 
Webinar: Simplifying Persistence for Java and MongoDB
Webinar: Simplifying Persistence for Java and MongoDBWebinar: Simplifying Persistence for Java and MongoDB
Webinar: Simplifying Persistence for Java and MongoDB
MongoDB
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
MongoDB
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
Gil Fink
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
Simon Willison
 

Similar to 最近 node.js 來勢洶洶, 怎麼辦? 別怕, 我們也有秘密武器 RingoJS! (20)

Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDB
 
Brightstar DB
Brightstar DBBrightstar DB
Brightstar DB
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010Using YQL Sensibly - YUIConf 2010
Using YQL Sensibly - YUIConf 2010
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
 
RESTFul development with Apache sling
RESTFul development with Apache slingRESTFul development with Apache sling
RESTFul development with Apache sling
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with Morphia
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB App
 
Webinar: Simplifying Persistence for Java and MongoDB
Webinar: Simplifying Persistence for Java and MongoDBWebinar: Simplifying Persistence for Java and MongoDB
Webinar: Simplifying Persistence for Java and MongoDB
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 

Recently uploaded

How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 

Recently uploaded (20)

How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 

最近 node.js 來勢洶洶, 怎麼辦? 別怕, 我們也有秘密武器 RingoJS!

  • 1. 頑皮工坊 Sleepnova Inc. 創 辦人暨執行長 周立瑋
  • 2. 自我介紹 頑皮工坊 Sleepnova Inc. 創辦人暨執行長,KKBOX Android 技術顧問。 (Android 與雲端技術顧問公司) 感興趣的領域: - 敏捷開發,尋找更符合人性的程式設計典範。 - 可應付高承載的延展性架構。 - 思考資訊人為社會做點什麼?
  • 3. 過去經歷 Talks: ● Javascript take-off to the clouds - Server-side Javascript @ COSCUP 2009 ● The NoSQL movement: CouchDB as an example @ COSCUP 2010 Projects: ● 東森大選即時開票系統,締造兩千兩百萬 req / 4 hr 記錄
  • 4. 最近 node.js 來勢洶洶, 怎麼辦? 別 怕, 我們也有秘密武器 RingoJS!
  • 5. 簡介 簡介 RingoJS 的特色,如何使用 RingoJS 在 JVM 上面快速開發,以及如何在專案中同時保有 scripting 的靈活度以及使用既有的 Java Library。
  • 7. The native language of the web
  • 9. About JavaScript ● Javascript vs. Java <恩怨情仇> ● JavaScript 不能拿來寫大系統? ● CommonJS module system
  • 10. RingoJS overview ● Developed by Hannes Wallnöfer (hns.github.com) ● Based on Mozilla Rhino ● Runs on JVM ● Orignal named HelmaNG ● Follow CommonJS
  • 11. Node.js vs RingoJS 1. VM maturaty 2. Community size 3. Library base 4. Java interopability 5. Single-thread vs. Multi-thread
  • 12. Node.js vs RingoJS ● VM optimize for browser ● Quite mature enterprise grade VM ● Young community ● Big community ● Not much library but will grow ● Lots of Java library ● No Java interoperability ● Very good Java interoperability ● Single thread ● Multi-thread
  • 13. Rhino JavaScript Engine ● JavaScript <-> Java inter-operation ○ Access Java packages and classes ○ Working with Java objects ○ Inherit class/interface ● E4X
  • 14. Accessing Java packages and classes js> Packages.java [JavaPackage java] js> java [JavaPackage java] js> java.io.File [JavaClass java.io.File] js> importPackage(java.io) js> File [JavaClass java.io.File]
  • 15. Working with Java objects js> new java.util.Date() Thu Jan 24 16:18:17 EST 2002 var File = java.io.File; var myfile = new File("sample.txt");
  • 16. Working with Java objects js> f = new java.io.File("test.txt") test.txt js> f.exists() true js> f.getName() test.txt
  • 17. Implementing Java Interfaces js> obj = { run: function () { print("nrunning"); } } [object Object] js> obj.run() running js> r = new java.lang.Runnable(obj); [object JavaObject]
  • 18. Implementing Java Interfaces js> r = new java.lang.Runnable({ run: function () { print("nrunning"); } }); [object JavaObject]
  • 19. Working with Java objects js> for (i in f) { print(i) } exists parentFile mkdir toString wait
  • 20. 特異功能 E4X var sales = <sales vendor="John"> <item type="peas" price="4" quantity="6"/> <item type="carrot" price="3" quantity="10"/> <item type="chips" price="5" quantity="3"/> </sales>; alert( sales.item.(@type == "carrot").@quantity ); alert( sales.@vendor ); for each( var price in sales..@price ) { alert( price ); } delete sales.item[0]; sales.item += <item type="oranges" price="4"/>; sales.item.(@type == "oranges").@quantity = 4;
  • 21. RingoJS ● Minimal web app ● Packages ● Storage ● AppEngine
  • 22. Hello World! exports.app = function(req) { return { status: 200, headers: {"Content-Type": "text/plain"}, body: ["Hello World!"] }; }; if (require.main == module) require("ringo/httpserver").main(module.id);
  • 23. Ringo Shell >> var fs = require('fs'); >> var file = fs.open('README.md'); >> var lines = [line for (line in file)];
  • 24. Handle HTTP Request // actions.js var Response = require('ringo/webapp/response'); var model = require('./model'); exports.index = function(req) { var posts = model.Post.query().select().slice(0,10); return Response.skin('skins/index.html', { posts: posts, }); };
  • 25. Skins // in a skin <% for post in <% posts %> render 'postOverview' %> <% subskin 'postOverview' %> <h2><% post.title %></h2>
  • 26. URL mapping // config.js exports.urls = [ ['/', './actions'], ];
  • 27. Database ● ringo-sqlstore ● berkeleystore ● cassandrastore ● mongodbstore ● redis-ringojs-client ● Google App Engine Datastore API
  • 28. Mongodbstore Initializing the store: include('ringo/storage/mongodbstore'); store = new Store('server', 27017, 'dbName'); Creating a new Storable class: Book = store.defineEntity('book'); Creating and saving a new Storable instance: var b = new Book({title: "DBs for dummies"}); b.save();
  • 29. Mongodbstore Retrieving all objects from a db: var books = Book.all(); Retrieving an object by id: var book = Book.get(id); Deleting an object from the db: book.remove(); Running a query on the database: Book.query().equals('prop', value).select();
  • 30. Berkeleystore Initializing the store: include('ringo/storage/berkeleystore'); store = new Store(dbpath); Creating a new Storable class: Book = store.defineEntity('book'); Creating and saving a new Storable instance: var b = new Book({title: "DBs for dummies"}); b.save();
  • 33. Performance characteristic ● Translation to JVM bytecode ● JVM is not a perfect dynamic language VM yet!
  • 34. Performance characteristic $ node v8bench.js 19 Aug 16:13:33 - Score (version 5): 4090 $ java -Xmx265m -jar js.jar run.js Score (version 5): 120 [larger is better]
  • 35. ~1/34
  • 36. Node.js vs RingoJS GC Benchmark http://hns.github.com/2010/09/29/benchmark2.html
  • 37. Future of JavaScript Engine JavaScript engine ● Nashorn, dyn.js ● InvokeDynamic
  • 38. JavaScript territory ● Titanium ● CouchDB ● Unity ● node.js + webkit ● RingoJS + SWT ● ES operating system ● Ubuntu Desktop
  • 39. Stay Hungry, Stay Foolish!