Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lightweight Languages Workshop 2002 9 November 2002 © 2002 IBM Corporation IBM Lightweight Services Implementing persistent server-side JavaScript Christopher.

Similar presentations


Presentation on theme: "Lightweight Languages Workshop 2002 9 November 2002 © 2002 IBM Corporation IBM Lightweight Services Implementing persistent server-side JavaScript Christopher."— Presentation transcript:

1 Lightweight Languages Workshop 2002 9 November 2002 © 2002 IBM Corporation IBM Lightweight Services Implementing persistent server-side JavaScript Christopher Vincent crv@us.ibm.com

2 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 2 Agenda Scenario Goals Compromises Conclusions

3 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 3 Scenario: script-based components Metadata configures environment Address space per instance

4 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 4 Goals Robust code, minimal effort High-level, dynamic environment Patch live code, interactive debugging (REPL) Asynchronous / event-driven APIs Application types Avoid deadlock, cancel operations Transparent persistence, transactions Program state rollbacks Survive container restart / failure

5 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 5 Simple JavaScript example No arbitrary serialization Only checkpoint when idle Single-threaded Event-handlers provide predictable boundaries var fib1 = 0; var fib2 = 1; function nextFibonacci() { var fib3 = fib1 + fib2; fib1 = fib2; fib2 = fib3; return fib3; }

6 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 6 Non-transactional resources Managed access to the non-transactional world Queue operations until event-handler / transaction succeeds Script APIs wrapper message-passing var session = new InstantMessaging.Session(); session.onMessage = onMessage; session.login(im.ibm.com, userId, password); function onMessage(session, from, text) { session.send(from, You said: + text);... throw new Error(darn.); }

7 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 7 Container restart / failure Complete transparency impractical Consider late failures vs. explicit resume Minimize effort to restore resources var session =... session.login(im.ibm.com, userId, password); Host.onResume = onResume; function onResume() { session.login(); }

8 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 8 Conclusions Practical results Real-world examples in 75-100 lines of JavaScript Implementing the container is hard Underlying message-passing system, resource management Custom-tailored extension APIs Applies to other languages with object serialization

9 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 9 More information IBM Lightweight Services http://alphaworks.ibm.com/tech/lws/ Introduction to IBM Lightweight Services http://ibm.com/developerworks/ibm/library/i-lws1/ Extending J2EE with script-based agents http://ibm.com/developerworks/ibm/library/i-lws2/ Mozilla Rhino JavaScript engine http://mozilla.org/rhino/ ECMAScript language specification http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM

10 LL2: IBM Lightweight Services 9 November 2002 | crv@us.ibm.com © 2002 IBM Corporation 10 Changes to environment Discard changes to built-in objects Simplifies serializer, saves space Could detect modifications Array.prototype.peek = function () { return this[this.length – 1]; }; x = [1, 2, 3]; x.peek(); var re = /foo(\d+)bar/i; re.exec(foo123bar); var match = RegExp.$1;


Download ppt "Lightweight Languages Workshop 2002 9 November 2002 © 2002 IBM Corporation IBM Lightweight Services Implementing persistent server-side JavaScript Christopher."

Similar presentations


Ads by Google