Harmony Highlights Proxies & Traits. Tom Van Cutsem Mark S. Miller
|
|
- Daniel Pierce Armstrong
- 5 years ago
- Views:
Transcription
1 Harmony Highlights Proxies & Traits Tom Van Cutsem Mark S. Miller 1
2 Ecmascript 5 Strict Mode: guards against common pitfalls rejects confusing features (e.g. with statement) throws exceptions instead of failing silently Object-manipulation API javascript.lang.reflect 2
3 Property Descriptors Data and accessor properties Property attributes var point = { x: 5, get y() { return this.x; } }; Object.getOwnPropertyDescriptor(point, x ); { value: 5, writable: true, enumerable: true, configurable: true } Object.getOwnPropertyDescriptor(point, y ); { get: function () { return this.x; }, set: undefined, enumerable: true, configurable: true } 3
4 Property Descriptor Maps var point = { x: 5, get y() { return this.x; } }; Object.defineProperty(point, z, { value: 0, enumerable: true, writable: false, configurable: false }); var point = Object.create( Object.prototype, { x: { value: 5, enumerable: true,... }, y: { get: function() {...}, enumerable: true,... }, z: { value: 0, enumerable: true,... } }); 4
5 Property Descriptor Maps var point = { x: 5, get y() { return this.x; } }; Object.defineProperty(point, z, { value: 0, enumerable: true, writable: false, configurable: false }); name pd x {...} var point = Object.create( Object.prototype, { x: { value: 5, enumerable: true,... }, y: { get: function() {...}, enumerable: true,... }, z: { value: 0, enumerable: true,... } }); y {...} z {...} 4
6 Tamper-proof Objects var point = { x: 5, get y() { return this.x; } }; Object.preventExtensions(point); point.z = 0; // can t add new properties Object.seal(point); delete point.x; // can t delete properties Object.freeze(point); point.x = 7; // can t assign properties 5
7 Proxies 6
8 Dynamic Proxies Generic handling of property access: Generic wrappers: access control, tracing, profiling,... Stratified form of nosuchmethod Generic handling of other operations applicable to objects: Virtual objects: persistent objects, remote objects,... Emulate host objects 7
9 Tracing: static proxies function maketracer(obj) { var proxy = Object.create(Object.getProtoypeOf(obj), {}); } Object.getOwnPropertyNames(obj).forEach(function(name) { var pd = Object.getOwnPropertyDescriptor(obj, name); Object.defineProperty(proxy, name, { get: function() { }); }); trace( get, name, obj); return obj[name]; }, set: function(v) { trace( set, name, obj, v); obj[name] = v; }, // copy attributes from pd return proxy; 8
10 Tracing: static proxies function maketracer(obj) { var proxy = Object.create(Object.getProtoypeOf(obj), {}); } Object.getOwnPropertyNames(obj).forEach(function(name) { var pd = Object.getOwnPropertyDescriptor(obj, name); Object.defineProperty(proxy, name, { get: function() { }); }); trace( get, name, obj); return obj[name]; }, set: function(v) { trace( set, name, obj, v); obj[name] = v; }, // copy attributes from pd return proxy; proxy doesn t reflect structural changes made to obj structural changes made to proxy are not reflected in obj structural changes: added/deleted properties changed property attributes 8
11 Tracing: dynamic proxies function maketracer(obj) { var proxy = Proxy.create({ } get: function(rcvr, name) { trace( get, name, obj); return obj[name]; }, set: function(rcvr, name, val) { trace( set, name, obj, val); },... obj[name] = val; return true; }, Object.getPrototypeOf(obj)); return proxy; 9
12 Tracing: dynamic proxies function maketracer(obj) { var proxy = Proxy.create({ } get: function(rcvr, name) { trace( get, name, obj); return obj[name]; }, set: function(rcvr, name, val) { trace( set, name, obj, val); },... obj[name] = val; return true; }, Object.getPrototypeOf(obj)); return proxy; base proxy handler meta 10
13 Stratified API var proxy = Proxy.create(handler, proto); handler base meta proxy 11
14 Stratified API var proxy = Proxy.create(handler, proto); handler.get(proxy, foo ) handler base proxy.foo meta proxy 11
15 Stratified API var proxy = Proxy.create(handler, proto); handler.get(proxy, foo ) handler.set(proxy, foo, 42) handler base proxy.foo proxy.foo := 42 meta proxy 11
16 Stratified API var proxy = Proxy.create(handler, proto); handler.get(proxy, foo ) handler.set(proxy, foo, 42) handler handler.get(proxy, foo ).apply(proxy,[1,2,3]) base proxy.foo proxy.foo := 42 meta proxy.foo(1,2,3) proxy 11
17 Stratified API var proxy = Proxy.create(handler, proto); handler.get(proxy, foo ) handler.set(proxy, foo, 42) handler handler.get(proxy, foo ).apply(proxy,[1,2,3]) handler.get(proxy, get ) base proxy.foo meta proxy.foo := 42 proxy.foo(1,2,3) proxy.get proxy 11
18 Stratified API var proxy = Proxy.create(handler, proto); handler.get(proxy, foo ) handler.set(proxy, foo, 42) handler handler.get(proxy, foo ).apply(proxy,[1,2,3]) handler.get(proxy, get ) base proxy.foo meta proxy.foo := 42 proxy.foo(1,2,3) proxy.get proxy proto 11
19 Not just property access var proxy = Proxy.create(handler, proto); handler base meta proxy 12
20 Not just property access var proxy = Proxy.create(handler, proto); handler.has( foo ) handler base meta foo in proxy proxy 12
21 Not just property access var proxy = Proxy.create(handler, proto); handler.has( foo ) handler.delete( foo ) handler base meta foo in proxy delete proxy.foo proxy 12
22 Not just property access var proxy = Proxy.create(handler, proto); handler.has( foo ) handler.delete( foo ) var props = handler.enumerate(); for (i=0;i<props.length;i++) { } var prop = props[i];... handler meta base foo in proxy delete proxy.foo proxy for (var prop in proxy) {... } 12
23 Not just property access var proxy = Proxy.create(handler, proto); handler.has( foo ) handler.delete( foo ) var props = handler.enumerate(); for (i=0;i<props.length;i++) { } var prop = props[i];... handler handler.defineproperty( foo, pd) meta base foo in proxy delete proxy.foo proxy for (var prop in proxy) {... } Object.defineProperty(proxy, foo, pd) 12
24 But not quite everything either var proxy = Proxy.create(handler, proto); handler base meta proxy 13
25 But not quite everything either var proxy = Proxy.create(handler, proto); handler base meta proxy === obj proxy 13
26 But not quite everything either var proxy = Proxy.create(handler, proto); handler base meta proxy === obj Object.getPrototypeOf(proxy) => proto proxy proto 13
27 But not quite everything either var proxy = Proxy.create(handler, proto); handler base meta proxy === obj Object.getPrototypeOf(proxy) => proto proxy instanceof Fun proxy proto 13
28 But not quite everything either var proxy = Proxy.create(handler, proto); handler base meta proxy === obj Object.getPrototypeOf(proxy) => proto proxy instanceof Fun typeof proxy => object proxy proto 13
29 Full Handler API handler proxy Object.getOwnPropertyDescriptor(proxy) Object.getPropertyDescriptor(proxy) Object.defineProperty(proxy,name,pd) Object.getOwnPropertyNames(proxy) delete proxy.name for (name in proxy) {... } Object.{freeze seal...}(proxy) name in proxy ({}).hasownproperty.call(proxy, name) receiver.name proxy.name = val Object.keys(proxy) handler.getownpropertydescriptor(name) handler.getpropertydescriptor(name) handler.defineproperty(name, pd) handler.getownpropertynames() handler.delete(name) handler.enumerate() handler.fix() handler.has(name) handler.hasown(name) handler.get(receiver, name) handler.set(proxy, name, val) handler.enumerateown() 14
30 Selective interception base meta object 15
31 Selective interception VM territory (C++) base meta object Javascript territory 15
32 Selective interception VM territory (C++) VM handler base meta object Javascript territory 15
33 Selective interception VM territory (C++) VM handler VM handler base meta host object object Javascript territory 15
34 Selective interception VM territory (C++) VM handler VM handler handler base meta host object object proxy Javascript territory 15
35 Selective interception VM territory (C++) VM handler VM handler handler base meta host object object proxy Javascript territory 15
36 Selective interception VM territory (C++) VM handler VM handler Self-hosted handler base meta host object object proxy Javascript territory 15
37 Selective interception VM territory (C++) VM handler VM handler Self-hosted handler base meta host object object proxy Javascript territory 15
38 Example: no-op forwarding proxy function ForwardingHandler(obj) { this.target = obj; } ForwardingHandler.prototype = { } has: function(name) { return name in this.target; }, get: function(rcvr,name) { return this.target[name]; }, set: function(rcvr,name,val) { this.target[name]=val;return true; }, delete: function(name) { return delete this.target[name]; } enumerate: function() { var props = []; },... proxy for (name in this.target) { props.push(name); }; return props; handler target var proxy = Proxy.create(new ForwardingHandler(o), Object.getPrototypeOf(o)); 16
39 Example: counting property access function makesimpleprofiler(target) { var forwarder = new ForwardingHandler(target); } var count = Object.create(null); forwarder.get = function(rcvr, name) { count[name] = (count[name] 0) + 1; return this.target[name]; }; return { } proxy: Proxy.create(forwarder, Object.getPrototypeOf(target)), get stats() { return count; } 17
40 Example: counting property access function makesimpleprofiler(target) { var forwarder = new ForwardingHandler(target); } var count = Object.create(null); forwarder.get = function(rcvr, name) { count[name] = (count[name] 0) + 1; return this.target[name]; }; return { } proxy: Proxy.create(forwarder, Object.getPrototypeOf(target)), get stats() { return count; } var subject = {... }; var profiler = makesimpleprofiler(subject); runapp(profiler.proxy); display(profiler.stats); 17
41 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); handler call construct fproxy 18
42 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); call(1,2,3) handler call construct fproxy(1,2,3) fproxy 18
43 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); call(1,2,3) construct(1,2,3) handler call construct fproxy(1,2,3) new fproxy(1,2,3) fproxy 18
44 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); call(1,2,3) construct(1,2,3) handler.get(fproxy, prototype ) handler call construct fproxy(1,2,3) new fproxy(1,2,3) fproxy.prototype fproxy 18
45 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); call(1,2,3) construct(1,2,3) handler.get(fproxy, prototype ) handler call construct fproxy(1,2,3) new fproxy(1,2,3) fproxy.prototype fproxy typeof fproxy => function 18
46 Function Proxies Javascript functions are objects. Additionally, they are also callable and constructable var call = function() {... }; var construct = function() {... }; var fproxy = Proxy.createFunction(handler, call, construct); call(1,2,3) construct(1,2,3) handler.get(fproxy, prototype ) handler call construct fproxy(1,2,3) new fproxy(1,2,3) fproxy.prototype fproxy typeof fproxy => function Object.getPrototypeOf(fproxy) => Function.prototype 18
47 Fixing a Proxy var proxy = Proxy.create(handler, proto); handler base meta proxy 19
48 Fixing a Proxy var proxy = Proxy.create(handler, proto); handler base meta Object.freeze(proxy) Object.seal(proxy) Object.preventExtensions(proxy) proxy 19
49 Fixing a Proxy var proxy = Proxy.create(handler, proto); var pdmap = handler.fix(); if (pdmap === undefined) throw TypeError(); become(proxy, Object.freeze( Object.create(proto, pdmap))); handler meta base Object.freeze(proxy) Object.seal(proxy) Object.preventExtensions(proxy) proxy 19
50 Fixing a Proxy var proxy = Proxy.create(handler, proto); var pdmap = handler.fix(); if (pdmap === undefined) throw TypeError(); become(proxy, Object.freeze( Object.create(proto, pdmap))); handler meta base Object.freeze(proxy) Object.seal(proxy) Object.preventExtensions(proxy) proxy Trapping fix Fixed 19
51 Fixing a Proxy var proxy = Proxy.create(handler, proto); var pdmap = handler.fix(); if (pdmap === undefined) throw TypeError(); become(proxy, Object.freeze( Object.create(proto, pdmap))); meta base Object.freeze(proxy) Object.seal(proxy) Object.preventExtensions(proxy) proxy Trapping fix Fixed 19
52 Status Presented at ECMA TC-39 meetings Proposal for ES-Harmony tinyurl.com/harmony-proxies Andreas Gal (Mozilla) implemented a prototype as an extension of Tracemonkey 20
53 Micro-benchmark 21
54 Proxies: summary Dynamic proxies enable: Generic wrappers: access control, profiling, adaptors,... Virtual objects: persistent objects, remote objects, emulated host objects,... API: Robust (stratified, not all operations intercepted) Secure (can t trap non-proxy or fixed objects) Performance: no overhead for non-proxy objects 22
55 Traits 23
56 Traits in a nutshell An alternative to mixins & multiple inheritance A trait provides and requires a set of methods Robust composition: Name clashes lead to conflicts that must be resolved Trait composition is commutative & associative: composition order is irrelevant First in Squeak Smalltalk (~2003), adoption in Perl 6, PLT Scheme, Fortress,... 24
57 traits.js library Motivation: More robust than existing prototypical inheritance & mixin patterns Easier creation of tamper-proof objects Based on ES5 property descriptor API Backwards-compatible with ES3 Works in browser and stand-alone 25
58 Minimal core API <script src= traits.js ></script> Trait construction var t = Trait({ a: Trait.required, b: function(){ return this.a + 1; } }) Trait composition var tc = Trait.compose(t1, t2,...) Trait resolution var tr = Trait.resolve({ a: c, b: undefined }, t) Trait instantiation var o = Trait.create(proto, t) 26
59 Enumerable trait var EnumerableTrait = Trait({ foreach: Trait.required, } }); map: function(fun) { var seq = []; this.foreach(function(e) { seq.push(fun(e)); }); return seq; }, filter: function(pred) { var seq = []; this.foreach(function(e) { if (pred(e,i)) { seq.push(e); } }); return seq; }, reduce: function(init, fun) { var result = init; this.foreach(function(e) { result = fun(result, e); }); return result; 27
60 Enumerable interval function makeinterval(min, max) { return Trait.create(Object.prototype, } Trait.compose( EnumerableTrait, Trait({ start: min, end: max, contains: function(e) { return (min <= e) && (e < max); }, foreach: function(consumer) { for (var i = min; i < max; i++) { consumer(i); } } }))); var int = makeinterval(0,5); int.reduce(0, function(a,b){return a+b;}); // 10 28
61 Trait construction Trait({ a: Trait.required, }); b: function() {...}, c: 42, get d() {...} Traits are property descriptor maps { a: { value: undefined, } required: true, enumerable: false }, b: { value: function() {...}, method: true, enumerable: true }, c: { value: 42, enumerable: true }, d: { get: function(){...}, } enumerable: true 29
62 Trait composition: conflicts T2 a b <methodp> <methodp> T1 a b c <requiredp> <methodp> <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 30
63 Trait composition: conflicts T2 a b <methodp> <methodp> Trait.compose(T1,T2) Tc a <methodp> T1 b c <conflictp> <datap> a <requiredp> b <methodp> c <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 30
64 Trait composition: conflicts T2 a b <methodp> <methodp> Trait.compose(T1,T2) Tc a <methodp> T1 b c <conflictp> <datap> a b <requiredp> <methodp> Trait.create(proto, Tc) c <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 30
65 Trait resolution T2 a b <methodp> <methodp> T1 a b c <requiredp> <methodp> <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 31
66 Trait resolution T2 Trait.resolve( {b:undefined}, T2); Tr a <methodp> a <methodp> b <methodp> b <requiredp> T1 a b c <requiredp> <methodp> <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 31
67 Trait resolution T2 Trait.resolve( {b:undefined}, T2); Tr a b <methodp> <methodp> a b <methodp> <requiredp> Tc T1 Trait.compose(T1,Tr) a b c <methodp> <methodp> <datap> a <requiredp> b <methodp> c <datap> Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 31
68 Trait resolution T2 Trait.resolve( {b:undefined}, T2); Tr a b <methodp> <methodp> a b <methodp> <requiredp> Tc T1 Trait.compose(T1,Tr) a b c <methodp> <methodp> <datap> a b c <requiredp> <methodp> <datap> Trait.create( proto, Tc) Trait({ a: Trait.required, }) b: function() {...this.a... }, c: 42 a function(){...} b function(){...} c 42 31
69 Trait instantiation Trait.create(proto, { a: { }) value: function() {... this.b... }, method: true }, b: { } value: 42 Trait instances are tamper-proof Object.create(proto, { a: { } }) }, }, value: function() {... this.b... b: { value: 42 + throws on conflict/required + binds this of methods + freezes object and methods 32
70 Traits: summary traits.js: a minimal trait composition library Traits as property descriptor maps: Object.create generates flexible objects Trait.create generates tamper-proof objects Open issue: sharing bound methods between trait instances 33
71 Conclusion ES5-strict is a robust programming language Proxies: robust metaprogramming API for ES-harmony Traits: robust composition API for ES5 Next: abstractions for robust event-driven programming es-lab.googlecode.com 34
Proxies Design Principles for Robust OO Intercession APIs
Proxies Design Principles for Robust OO Intercession APIs Tom Van Cutsem Mark S. Miller Overview Context: a new -programming API for Javascript (d on ECMAScript 5th ed.) Focus on intercession, intercepting
More informationJavascript s Meta-object Protocol. Tom Van Cutsem
Javascript s Meta-object Protocol Tom Van Cutsem Talk Outline Brief walkthrough of Javascript Proxies in ECMAScript 6 Meta-object protocols How proxies make Javascript s MOP explicit Example: membranes
More informationTradeoffs in language design: The case of Javascript proxies. Tom Van Cutsem (joint work with Mark S. Miller, with feedback from many others)
Tradeoffs in language design: The case of Javascript proxies Tom Van Cutsem (joint work with Mark S. Miller, with feedback from many others) What do these have in common? What do these have in common?
More informationtraits.js Robust Object Composition and High-integrity Objects for ECMAScript 5 Tom Van Cutsem Mark S. Miller Abstract 1.
traits.js Robust Object Composition and High-integrity Objects for ECMAScript 5 Tom Van Cutsem Software Languages Lab Vrije Universiteit Brussel, Belgium tvcutsem@vub.ac.be Mark S. Miller Google, USA erights@google.com
More informationVirtualizing the Object a.k.a. The Javascript Meta-object Protocol. Tom Van
Virtualizing the Object a.k.a. The Javascript Meta-object Protocol Tom Van Cutsem @tvcutsem A Powerful Idea: Virtualization A Powerful Idea: Virtualization Virtualization in object-oriented languages obj.property
More informationtraits.js Robust Object Composition and High-integrity Objects for ECMAScript 5 Tom Van Cutsem Mark S. Miller Abstract 1.
traits.js Robust Object Composition and High-integrity Objects for ECMAScript 5 Tom Van Cutsem Software Languages Lab Vrije Universiteit Brussel, Belgium tvcutsem@vub.ac.be Mark S. Miller Google, USA erights@google.com
More informationTrustworthy Proxies Virtualizing Objects with Invariants. Tom Van Cutsem (VUB) and Mark S. Miller (Google)
Trustworthy Proxies Virtualizing Objects with Invariants Tom Van Cutsem (VUB) and Mark S. Miller (Google) Context ECMA-262 5 th Edition / December 2009 ECMAScript Language Specification Reference number
More informationRobust Trait Composition for Javascript
Robust Trait Composition for Javascript Tom Van Cutsem a, Mark S. Miller b a Software Languages Lab, Vrije Universiteit Brussel, Belgium b Google, USA Abstract We introduce traits.js, a small, portable
More informationiwiki Documentation Release 1.0 jch
iwiki Documentation Release 1.0 jch January 31, 2014 Contents i ii Contents: Contents 1 2 Contents CHAPTER 1 Python 1.1 Python Core 1.1.1 Strings 1.1.2 Functions Argument Lists *args tuple/list **kwargs
More informationJAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)
Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 4 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA
More informationJavaScript. What s wrong with JavaScript?
JavaScript 1 What s wrong with JavaScript? A very powerful language, yet Often hated Browser inconsistencies Misunderstood Developers find it painful Lagging tool support Bad name for a language! Java
More informationChanges to JavaScript, Part 1: EcmaScript 5. Mark S. Miller, Waldemar Horwat, Mike Samuel Your EcmaScript committee representatives
Changes to JavaScript, Part 1: EcmaScript 5 Mark S. Miller, Waldemar Horwat, Mike Samuel Your EcmaScript committee representatives Brief History EcmaScript stuck at ES3 since 1999 Several attempts at feature
More informationSymbols. accessor properties, attributes, creating, adding properties, 8 anonymous functions, 20, 80
Index Symbols { } (braces) for function contents, 18 and object properties, 9 == (double equals operator), 5 === (triple equals operator), 5 [ ] (square brackets) for array literals, 10 for property access,
More informationClasses vs Simple Object Delegation In JavaScript
Classes vs Simple Object Delegation In JavaScript Things to consider... Do we want to (deeply) understand what our code is doing? Do we want encapsulation? Do we want true private variables and functions?
More informationJavaScript: Sort of a Big Deal,
: Sort of a Big Deal, But Sort of Quirky... March 20, 2017 Lisp in C s Clothing (Crockford, 2001) Dynamically Typed: no static type annotations or type checks. C-Like Syntax: curly-braces, for, semicolons,
More informationWriting robust client-side code using Modern JavaScript or JavaScript: the Good, the Bad, the Strict and the Secure Parts
Writing robust client-side code using Modern JavaScript or JavaScript: the Good, the Bad, the Strict and the Secure Parts Tom Van Cutsem @tvcutsem Talk Outline Part I: 20 years of JavaScript Part II: the
More informationNode.js Training JavaScript. Richard richardrodger.com
Node.js Training JavaScript Richard Rodger @rjrodger richardrodger.com richard.rodger@nearform.com A New Look at JavaScript Embracing JavaScript JavaScript Data Structures JavaScript Functions Functional
More informationObject Model. Object Oriented Programming Winter
Object Model Object Oriented Programming 236703 Winter 2014-5 Class Representation In Memory A class is an abstract entity, so why should it be represented in the runtime environment? Answer #1: Dynamic
More informationObject Model. Object Oriented Programming Spring 2015
Object Model Object Oriented Programming 236703 Spring 2015 Class Representation In Memory A class is an abstract entity, so why should it be represented in the runtime environment? Answer #1: Dynamic
More informationTrustworthy Proxies. Virtualizing Objects with Invariants. Tom Van Cutsem 1 and Mark S. Miller 2
Trustworthy Proxies Virtualizing Objects with Invariants Tom Van Cutsem 1 and Mark S. Miller 2 1 Vrije Universiteit Brussel, Belgium 2 Google Research, USA Abstract. Proxies are a common technique to virtualize
More informationJavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects
JavaScript CAC Noida is an ISO 9001:2015 certified training center with professional experience that dates back to 2005. The vision is to provide professional education merging corporate culture globally
More informationBoot Camp JavaScript Sioux, March 31, 2011
Boot Camp JavaScript http://rix0r.nl/bootcamp Sioux, March 31, 2011 Agenda Part 1: JavaScript the Language Short break Part 2: JavaScript in the Browser History May 1995 LiveScript is written by Brendan
More informationStatic Analysis for JavaScript
Static Analysis for JavaScript Adi Yoga Sidi Prabawa Supervisor: Associate Professor Chin Wei Ngan Department of Computer Science School of Computing National University of Singapore June 30, 2013 Abstract
More informationOverview. Elements of Programming Languages. Objects. Self-Reference
Overview Elements of Programming Languages Lecture 10: James Cheney University of Edinburgh October 23, 2017 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces
More informationThe course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.
Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA2442 Introduction to JavaScript Objectives This intensive training course
More informationADsafety. Type-based Verification of JavaScript Sandboxing. Joe Gibbs Politz Spiridon Aristides Eliopoulos Arjun Guha Shriram Krishnamurthi
ADsafety Type-based Verification of JavaScript Sandboxing Joe Gibbs Politz Spiridon Aristides Eliopoulos Arjun Guha Shriram Krishnamurthi 1 2 3 third-party ad third-party ad 4 Who is running code in your
More informationJavascript. Many examples from Kyle Simpson: Scope and Closures
Javascript Many examples from Kyle Simpson: Scope and Closures What is JavaScript? Not related to Java (except that syntax is C/Java- like) Created by Brendan Eich at Netscape later standardized through
More informationJavaScript: The Good Parts
JavaScript: The Good Parts The World's Most Misunderstood Programming Language Douglas Crockford Yahoo! Inc. A language of many contrasts. The broadest range of programmer skills of any programming language.
More informationTapestry. Code less, deliver more. Rayland Jeans
Tapestry Code less, deliver more. Rayland Jeans What is Apache Tapestry? Apache Tapestry is an open-source framework designed to create scalable web applications in Java. Tapestry allows developers to
More informationJavaScript. History. Adding JavaScript to a page. CS144: Web Applications
JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary
More informationFunctional JavaScript. Douglas Crockford Yahoo! Inc.
Functional JavaScript Douglas Crockford Yahoo! Inc. The World's Most Misunderstood Programming Language A language of many contrasts. The broadest range of programmer skills of any programming language.
More informationSebastiano
Sebastiano Armeli @sebarmeli http://html5hub.com/wp-content/uploads/2013/11/es6-hiway-sign.png Sebastiano Armeli @sebarmeli ES6 History 199 199 199 199 199 200 200 5 6 7 8 9 0 3 JSScript ECMA-262 Ed.2
More informationJScript Reference. Contents
JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript
More informationDecorators. Userland Extensions to ES6 Classes
Decorators Userland Extensions to ES6 Classes Userland Classes Class.new({ init: function(firstname, lastname) { this.firstname = firstname; this.lastname = lastname; this._super();, fullname: function()
More informationDLint and JITProf. [FSE 15] JITProf: Pinpointing JIT-unfriendly JavaScript code Liang Gong, Michael Pradel, Koushik Sen
DLint and JITProf DLint: Dynamically Checking JS Coding Practice [ISSTA 15] DLint: Dynamically Checking Bad Coding Practices in JavaScript Liang Gong, Michael Pradel, Manu Sridharan, Koushik Sen JITProf:
More informationClient-Side Web Technologies. JavaScript Part I
Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful
More informationTreating Framework Fatigue With JavaScript
Treating Framework Fatigue With JavaScript Tim Doherty Software Architect /in/timdoherty timdoherty.net ??? Hey, this one looks cool! You May Suffer From Framework Fatigue Symptoms Confusion One-way reactive
More informationStatic Analysis of JavaScript. Ben Hardekopf
Static Analysis of JavaScript Insights and Challenges Ben Hardekopf Department of Computer Science University of California, Santa Barbara Setting Expectations What this talk is about Brief introduction
More informationJavaScript Programming
JavaScript Programming Mendel Rosenblum 1 How do you program in JavaScript? From Wikipedia:... supporting object-oriented, imperative, and functional programming... Mostly programming conventions (i.e.
More informationECMAScript 2015 The Future of JavaScript is Now!
ECMAScript 2015 The Future of JavaScript is Now! Tom Van Cutsem SPLASH-I 2015 @tvcutsem Talk Outline Part I: JavaScript s origins, and the long road to ECMAScript 6 Part II: a brief tour of ECMAScript
More informationInterface evolution via public defender methods
Interface evolution via public defender methods Brian Goetz Second draft, May 2010 1. Problem statement Once published, it is impossible to add methods to an interface without breaking existing implementations.
More informationOutline. Central concepts in OO languages Objects as activation records (Simula) Dynamically-typed object-oriented languages
Objects Outline Central concepts in OO languages Objects as activation records (Simula) Dynamically-typed object-oriented languages Class-based languages (Smalltalk) Prototype-based languages (JavaScript)
More informationProgramming Languages & Paradigms PROP HT Abstraction & Modularity. Inheritance vs. delegation, method vs. message. Modularity, cont d.
Programming Languages & Paradigms PROP HT 2011 Abstraction & Modularity Lecture 6 Inheritance vs. delegation, method vs. message Beatrice Åkerblom beatrice@dsv.su.se 2 Modularity Modularity, cont d. Modular
More informationJavaScript: The Good Parts. Douglas Crockford Yahoo! Inc.
JavaScript: The Good Parts Douglas Crockford Yahoo! Inc. http://www.crockford.com/codecamp/ The World's Most Popular Programming Language The World's Most Popular Programming Language The World's Most
More informationJavaScript Lecture 1
JavaScript Lecture 1 Waterford Institute of Technology May 17, 2016 John Fitzgerald Waterford Institute of Technology, JavaScriptLecture 1 1/31 Javascript Extent of this course A condensed basic JavaScript
More informationJavaScript Module System: Exploring the Design Space
JavaScript Module System: Exploring the Design Space Junhee Cho Sukyoung Ryu KAIST {ssaljalu, sryu.cs@kaist.ac.kr Abstract While JavaScript is one of the most widely used programming languages not only
More informationOverview. Elements of Programming Languages. Objects. Self-Reference
Overview Elements of Programming Languages Lecture 11: James Cheney University of Edinburgh November 3, 2015 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces
More informationIndex. Symbols. accessor properties, 74,
Index Symbols * (asterisk), 139 142, 157, 159, 175 ** (exponentiation operator), 306 307 \ (backslash), 26 ` (backtick), 26 : (colon), 69, 88 {} (curly braces), 56 57, 88 89, 285 ${ } (substitution delimiters),
More informationSandboxing JavaScript. Lieven Desmet iminds-distrinet, KU Leuven OWASP BeNeLux Days 2012 (29/11/2012, Leuven) DistriNet
Sandboxing JavaScript Lieven Desmet iminds-distrinet, KU Leuven Lieven.Desmet@cs.kuleuven.be OWASP BeNeLux Days 2012 (29/11/2012, Leuven) DistriNet About myself Lieven Desmet @lieven_desmet Research manager
More informationFunctions. Functions in JavaScript are declared using the function keyword
JavaScript II Functions Functions in JavaScript are declared using the function keyword function function_name(args){ Functions are rst class objects, they are stored in variables like everything else
More informationObjects. Deian Stefan (Adopted from my & Edward Yang s CS242 slides)
Objects Deian Stefan (Adopted from my & Edward Yang s CS242 slides) Outline Central concepts in OO languages Objects as activation records (Simula) Dynamically-typed object-oriented languages Class-based
More informationJavaScript. History. Adding JavaScript to a page. CS144: Web Applications
JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary
More informationIn Praise of Metacircular Virtual Machine Layering. Erick Lavoie, Bruno Dufour, Marc Feeley Université de Montréal ericklavoie.com
In Praise of Metacircular Virtual Machine Layering Erick Lavoie, Bruno Dufour, Marc Feeley Université de Montréal ericklavoie.com Motivation 2 Context Program comprehension Benchmark generation Hybrid
More informationHotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon
HotPy (2) Binary Compatible High Performance VM for Python Mark Shannon Who am I? Mark Shannon PhD thesis on building VMs for dynamic languages During my PhD I developed: GVMT. A virtual machine tool kit
More informationJavaScript CS 4640 Programming Languages for Web Applications
JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation
More informationVariable Declarations
Variable Declarations Variables can be declared using var or the newer let. Note that declaration is simply var x = 1 or let x = 1; there is no type as js variables do not have types. Constant variables
More informationCase Study: Meta Classes
1 Case Study: Meta Classes Class representation in memory Class variables and methods Meta Classes 3 Level System 4 Level System 5 Level System 1 Level System Infinite Levels System Class Representation
More informationModule 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components
Module 5 JavaScript, AJAX, and jquery Module 5 Contains 2 components Both the Individual and Group portion are due on Monday October 30 th Start early on this module One of the most time consuming modules
More informationThe results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false
Test 1 Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which celebrity has not received an ACM Turing Award? A. Alan Kay B. John McCarthy C. Dennis Ritchie D. Bjarne Stroustrup
More informationB l o c k B i n d i n g s
1 Block Bindings Traditionally, the way variable declarations work has been one tricky part of programming in JavaScript. In most C-based languages, variables (more formally known as bindings, as a name
More informationA Tested Semantics for Getters, Setters, and Eval in JavaScript
A Tested Semantics for Getters, Setters, and Eval in JavaScript Joe Gibbs Politz Matthew J. Carroll Benjamin S. Lerner Justin Pombrio Shriram Krishnamurthi Brown University www.jswebtools.org Abstract
More informationMetacircular Virtual Machine Layering for Run-Time Instrumentation. Erick Lavoie, Bruno Dufour, Marc Feeley Université de Montréal ericklavoie.
Metacircular Virtual Machine Layering for Run-Time Instrumentation Erick Lavoie, Bruno Dufour, Marc Feeley Université de Montréal ericklavoie.com 1 Motivation 2 2 Context Program comprehension Benchmark
More informationIntroduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.
Preface p. xiii Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p. 5 Client-Side JavaScript: Executable Content
More informationThis document defines the ActionScript 3.0 language, which is designed to be forward- compatible with the next edition of ECMAScript (ECMA-262).
ActionScript 3.0 Language Specification This document defines the ActionScript 3.0 language, which is designed to be forward- compatible with the next edition of ECMAScript (ECMA-262). This document is
More informationPicolo: A Simple Python Framework for Introducing Component Principles
Picolo: A Simple Python Framework for Introducing Component Principles Raphaël Marvie LIFL University of Lille 1 (France) raphael.marvie@lifl.fr Abstract Components have now become a cornerstone of software
More informationModule 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component
Module 5 JavaScript, AJAX, and jquery Module 5 Contains an Individual and Group component Both are due on Wednesday October 24 th Start early on this module One of the most time consuming modules in the
More informationSemantics and Security Issues in JavaScript
Semantics and Security Issues in JavaScript Sémantique et problèmes de sécurité en JavaScript Deliverable Resilience FUI 12: 7.3.2.1 Failles de sécurité en JavaScript / JavaScript security issues Stéphane
More informationFunctions & First Class Function Values
Functions & First Class Function Values PLAI 1st ed Chapter 4, PLAI 2ed Chapter 5 The concept of a function is itself very close to substitution, and to our with form. Consider the following morph 1 {
More informationCS115 - Module 9 - filter, map, and friends
Fall 2017 Reminder: if you have not already, ensure you: Read How to Design Programs, Intermezzo 3 (Section 18); Sections 19-23. Abstraction abstraction, n. 3a.... The process of isolating properties or
More informationarxiv: v1 [cs.pl] 15 Dec 2009
JSC : A JavaScript Object System Artur Ventura artur.ventura@ist.utl.pt January 0, 018 arxiv:091.861v1 [cs.pl] 15 Dec 009 Abstract The JSC language is a superset of JavaScript designed to ease the development
More informationTransparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScript Matthias Keil 1, Omer Farooq 1, Sankha Narayan Guria 2, Andreas Schlegel 1, Manuel Geffken 1, Peter Thiemann 1 1 University of Freiburg, Germany, 2 Indian Institute
More informationINTRODUCTION TO JAVASCRIPT
INTRODUCTION TO JAVASCRIPT JAVASCRIPT OBJECT SYNTAX var empty_object = {} var student ={ "first name": "Daniel", "last name": "Graham", title: "PHD", } IT IS OK TO INCLUDE OR EXCLUDE TRAILING COMMAS JAVASCRIPT
More informationJavaScript: Features, Trends, and Static Analysis
JavaScript: Features, Trends, and Static Analysis Joonwon Choi ROPAS Show & Tell 01/25/2013 1 Contents What is JavaScript? Features Trends Static Analysis Conclusion & Future Works 2 What is JavaScript?
More informationMidterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.
First Name Last Name CSCi 90.3 March 23, 2010 Midterm Exam Instructions: For multiple choice questions, circle the letter of the one best choice unless the question explicitly states that it might have
More informationProgramming Languages
Programming Languages Dr. Michael Petter WS 2016/17 Exercise Sheet 8 Assignment 8.1 Quiz 1. Can Smalltalk Inheritance be used to model Java s inheritance? What about attribute access? 2. In a Trait-based
More informationSoftware Architecture and Engineering: Part II
Software Architecture and Engineering: Part II ETH Zurich, Spring 2016 Prof. http://www.srl.inf.ethz.ch/ Framework SMT solver Alias Analysis Relational Analysis Assertions Second Project Static Analysis
More informationDocuments and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. JavaScript. Standard
Introduction to Prof. Ing. Andrea Omicini II Facoltà di Ingegneria, Cesena Alma Mater Studiorum, Università di Bologna andrea.omicini@unibo.it Documents and computation HTML Language for the description
More informationBusy.NET Developer's Guide to ECMAScript
Busy.NET Developer's Guide to ECMAScript Ted Neward http://www.tedneward.com Level: Intermediate Credentials Who is this guy? Principal Consultant, architect, mentor BEA Technical Director, Microsoft MVP
More informationSecuring EcmaScript 5: Adventures in Strategic Compromise. Mark S. Miller and the Cajadores Thanks to many on EcmaScript committee
Securing EcmaScript 5: Adventures in Strategic Compromise Mark S. Miller and the Cajadores Thanks to many on EcmaScript committee Overview My Expression Security Constraints talk The What and Why of object-capabilities
More informationJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into Javascript Christopher Chedeau EPITA Research and Development Laboratory christopher.chedeau@lrde.epita.fr Didier Verna EPITA Research and Development Laboratory didier.verna@lrde.epita.fr
More informationLanguage Based isolation of Untrusted JavaScript
Dept. of Computer Science, Stanford University Joint work with Sergio Maffeis (Imperial College London) and John C. Mitchell (Stanford University) Outline 1 Motivation 2 Case Study : FBJS Design Attacks
More informationJavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology
JavaScript: the language of browser interactions Claudia Hauff TI1506: Web and Database Technology ti1506-ewi@tudelft.nl Densest Web lecture of this course. Coding takes time. Be friendly with Codecademy
More informationJAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)
Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 2 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA
More informationExperimental New Directions for JavaScript
Experimental New Directions for JavaScript Andreas Rossberg, V8/Google Motivation Broad need for (more) scalable JavaScript Usability, esp. maintainability Performance, esp. predictability ES6 opens up
More informationJavaScript CS 4640 Programming Languages for Web Applications
JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation
More informationISO/IEC Information technology Programming languages, their environments and system software interfaces ECMAScript language specification
INTERNATIONAL STANDARD ISO/IEC 16262 Third edition 2011-06.15 Information technology Programming languages, their environments and system software interfaces ECMAScript language specification Technologies
More informationScala, Your Next Programming Language
Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that
More informationDeveloper Entrepreneur Crazy person
Jakob Mattsson Developer Entrepreneur Crazy person @jakobmattsson jakob.mattsson@gmail.com on Forgotten funky functions Client-side JavaScript tracking Quick and easy customer feedback. touch-and-tell.se
More informationOn the (Same) Origin of Scripties Evolving a new security policy for the web
On the (Same) Origin of Scripties Evolving a new security policy for the web Jasvir Nagra and Mike Samuel Google, Inc. {jasvir,msamuel}@google.com 23 June 2010 Argument in a nutshell Social Networks compose
More informationObject Oriented JavaScript (Part the Second)
E FRE e! icl t r A FEATURE Database Versioning with Liquibase Object Oriented JavaScript (Part the Second) Jordan Kasper DisplayInfo() Related URLs: Guide to JavaScript Inheritance by Axel Rauschmeyer
More informationActionScript Coding Standards. by Michael Williams
by Michael Williams March 2002 Copyright 2002 Macromedia, Inc. All rights reserved. The information contained in this document represents the current view of Macromedia on the issue discussed as of the
More informationCaja Safe active content in sanitized JavaScript
Caja Safe active content in sanitized JavaScript Mark S. Miller Mike Samuel Ben Laurie Ihab Awad Mike Stay January 10, 2008 Abstract Using Caja, web apps can safely allow scripts in third party content.
More informationNick Senger & Jesse van den Kieboom
Using TypeScript with the ArcGIS API for JavaScript Nick Senger & Jesse van den Kieboom Live version of this presentation is available on: https://jkieboom.github.io/devsummit-palm-springs-2018/presentations/typescript-arcgis-js-api
More informationDocuments and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. Standard
Introduction to Prof. Andrea Omicini & Ing. Giulio Piancastelli II Facoltà di Ingegneria, Cesena Alma Mater Studiorum, Università di Bologna andrea.omicini@unibo.it, giulio.piancastelli@unibo.it HTML Documents
More informationlow and not larger than high. 18 points
CSE 330 Test 1 (1 point) Spring 015 Multiple Choice. Write your answer to the LEFT of each problem. 3 points each 1. Lisp was invented at: A. IBM B. MIT C. Netscape D. Stanford. In C++, what operator is
More informationJam: A Smooth Extension With Java Mixins
Jam: A Smooth Extension With Java Mixins Davide Ancona, Giovanni Lagorio, Ellena Zucca Presentation created by Left-out Jam abstract syntax Formal definitions of Jam static semantics Formal definitions
More informationAdvanced JavaScript. Konstantin Käfer. Konstantin Käfer
Advanced JavaScript Contents 1. Why JavaScript? 2. Advanced Language Features 3. Patterns and Techniques 4. Debugging and Analyzing 1. Why JavaScript? Why JavaScript? Lightweight language No static type
More informationTraits in C# Stefan Reichhart Oscar Nierstrasz, Stephane Ducasse. Software Composition Group
Traits in C# Stefan Reichhart stefan_reichhart@student.unibe.ch Software Composition Group Oscar Nierstrasz, Stephane Ducasse Roadmap Project Context / Why Traits? What s a Trait? Flattening Traits? Traits
More information[MS-ES5EX]: Internet Explorer Extensions to the ECMA-262 ECMAScript Language Specification (Fifth Edition)
[MS-ES5EX]: Internet Explorer Extensions to the ECMA-262 ECMAScript Language Specification (Fifth Edition) Intellectual Property Rights Notice for Open Specifications Documentation Technical Documentation.
More informationINF5750. Introduction to JavaScript and Node.js
INF5750 Introduction to JavaScript and Node.js Outline Introduction to JavaScript Language basics Introduction to Node.js Tips and tools for working with JS and Node.js What is JavaScript? Built as scripting
More information