end-to-end w3c apis - tpac 2012

30
End-to-end W3C APIs By Alexandre Morgaut TPAC 2012 - Lyon, France

Upload: alexandre-morgaut

Post on 29-Aug-2014

4.275 views

Category:

Technology


4 download

DESCRIPTION

- Web Worker context compared to SSJS context - Mixte Synchronous / Asynchronous APIs - Making Existing Client-side JS APIs recommendations adaptable to the server context - Defining W3C recommendation for Server-side JavaScript APIs? - Remote debugging for Remote (Server) Workers - Potential common package/module format support (CommonJS, AMD, ECMAScript 6) - DOM Events, ProgressEvent, EventSource, Server Events (EventEmitter?), & Client Events - Feedback on previous work at CommonJS and from some SSJS implementations - Feedback on our experiences in the Wakanda implementation - start the activity of the community group

TRANSCRIPT

Page 1: End-to-end W3C APIs - tpac 2012

End-to-endW3C APIs

By Alexandre Morgaut

TPAC 2012 - Lyon, France

Page 2: End-to-end W3C APIs - tpac 2012

Agenda

• The Web & JavaScript

• W3C APIs

• Server-Side JavaScript

• Web Applications

• Now & Tomorrow

Page 3: End-to-end W3C APIs - tpac 2012

The Web & JavaScript

Page 4: End-to-end W3C APIs - tpac 2012

REST

• Representational State Transfer

• Client-Server

• Stateless, Cache, Uniform Interface

• Layered System

• Code on Demand: JavaScript

• defined in 2000 by Roy Thomas Fielding

Page 5: End-to-end W3C APIs - tpac 2012

Web Standards

Page 6: End-to-end W3C APIs - tpac 2012

W3C

• Created at the MIT in 1994

• Led by Tim Berners-Lee and Dr. Jeffrey Jaffe

• Joint agreement among three "Host Institutions"

• MIT, ERCIM, Keio University

• Working Groups

• HTML, MathML, RDF, SVG, CSS, Audio, Device...

Page 7: End-to-end W3C APIs - tpac 2012

ECMA• European Computer Manufacturers Association

• Standards

• CD-ROM, ECMAScript, C#, Office Open XML File Formats

• JavaScript

• ECMA-262 aka ECMAScript aka ISO/IEC 16262

• TC39-TG1 managed by Mr. J. Neumann

• E4X: ECMAScript for XML

• ECMAScript Internationalization API

• Test262

http://wiki.ecmascript.org

Page 8: End-to-end W3C APIs - tpac 2012

W3C on Server-Side ?

Page 9: End-to-end W3C APIs - tpac 2012

DOM

• Java

• JavaScript

• .NET

• PHP

• python

• ..;

Page 10: End-to-end W3C APIs - tpac 2012

Server-Side JavaScript

Page 11: End-to-end W3C APIs - tpac 2012

Standards

• ECMAScript

• CommonJS

More than 60 SSJS implementations

Page 12: End-to-end W3C APIs - tpac 2012

Servers

• Microsoft IIS

• Persevere

• Jaxer

• node.js

• Wakanda

• RingoJS

• SilkJS

Page 13: End-to-end W3C APIs - tpac 2012

NoSQL Databases

• CouchDB

• MongoDB

• Riak

• WakandaDB

• ArangoDB

• OrientDB

Page 14: End-to-end W3C APIs - tpac 2012

Web Application “1.0”

Page 15: End-to-end W3C APIs - tpac 2012

HTML5 APIs

• XMLHttpRequest 2

• Blob

• File / FileSystem

• Web SQL

• Web Storage

• Web Workers

• Web Sockets

• Web Cryptography

• ImageData

• Typed Arrays

• Storage Quota

• System Information

• URL

• WebCL

Page 16: End-to-end W3C APIs - tpac 2012

WebCL

“This section proposes mechanisms for transferring pixel data between WebCL memory objects and HTML media elements. Server-side or Web Worker based implementations of WebCL will not be required to support these features.”

https://cvs.khronos.org/svn/repos/registry/trunk/public/webcl/spec/latest/index.html#4

Page 17: End-to-end W3C APIs - tpac 2012

Web SQL

“This document was on the W3C Recommendation track but specification work has stopped. The specification reached an impasse: all interested implementors have used the same SQL backend (Sqlite), but we need multiple independent implementations to proceed along a standardisation path.”

http://www.w3.org/TR/webdatabase/

Page 18: End-to-end W3C APIs - tpac 2012

Async “and” Sync

• XMLHttpRequest(method, url, async)

• FileReaderSync()

• requestFileSystemSync()

• openDatabaseSync()

• indexedDBSync.open()

• localStorage.getItem()

Page 19: End-to-end W3C APIs - tpac 2012

IndexedDB

“The synchronous database API methods provide a blocking access pattern to IndexedDB databases. Since they block the calling thread they are only available from workers.”

http://www.w3.org/TR/IndexedDB/#sync-database

Page 20: End-to-end W3C APIs - tpac 2012

Web Workers

• Dedicated or Shared

• No Window, No Document

• WorkerGlobal, WorkerUtils

• WorkerNavigator, WorkerLocation

• postMessage(), onmessage(), onerror()

• importScripts()

Page 21: End-to-end W3C APIs - tpac 2012

Concept

• Server JS contexts == Workers

• multi-threaded -> Dedicated Workers

• single threaded EventLoop -> Shared

• Server JS contexts === Remote JS Workers

Page 22: End-to-end W3C APIs - tpac 2012

Now & Tomorrow

Page 23: End-to-end W3C APIs - tpac 2012

RingoJS

• W3C

• Web Worker

• CommonJS

• Modules

• System, fs, binary, IO, Unit Test

• Other: console

Page 24: End-to-end W3C APIs - tpac 2012

SilkJS

• W3C

• XMLHttpRequest

• CommonJS

• Modules

Page 25: End-to-end W3C APIs - tpac 2012

node.js

• W3C via modules

• XMLHttpRequest (node-xmlhttprequest)

• Web Sockets (node-websocket-client)

• DOM (node-o3-fastxml), IndexedDB (perstore)

• CommonJS

• Modules, Packages

• Other: console

Page 26: End-to-end W3C APIs - tpac 2012

Wakanda

• W3C

• XMLHttpRequest, WindowTimer,

• Web Storage, Web Worker,

• File, FileSystem, Blob, ...

• CommonJS

• Modules, System, Unit Test

• Other: console

Page 27: End-to-end W3C APIs - tpac 2012

Wakanda

• Web Storage

• sessionStorage, user.storage, storage

• Web Workers

• Worker, SharedWorker, SystemWorker

Page 28: End-to-end W3C APIs - tpac 2012

Wakanda

• Server-side JS context

• CommonJS (module.id, require, ...)

• Worker (importScripts, WindowTimer, ...)

Page 29: End-to-end W3C APIs - tpac 2012

Summary• ECMAScript is already everywhere

• Modules: CommonJS already standard, AMD, ECMAScript 6

• Many W3C APIs already applicable server-side

• Same APIs means

• better learning curve

• more shared libraries / modules

• DRY -> shared Model work Offline

Page 30: End-to-end W3C APIs - tpac 2012

Client and Server JavaScript APIs W3C Community Group

http://www.w3.org/community/jseverywhere/

Let’s start!