Proxies Design Principles for Robust OO Intercession APIs

Size: px
Start display at page:

Download "Proxies Design Principles for Robust OO Intercession APIs"

Transcription

1 Proxies Design Principles for Robust OO Intercession APIs Tom Van Cutsem Mark S. Miller

2 Overview Context: a new -programming API for Javascript (d on ECMAScript 5th ed.) Focus on intercession, intercepting -level operations on proxies Paper: generalized design principles for messaged OO -programming APIs

3 Ecmascript 5 New reflection API exposes property attributes var point = { x: 5, get y() { return this.x; } }; Object.defineProperty(point, z, { value: 42, writable: false, enumerable: true, configurable: true });

4 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 Proxies

6 Intercession in Javascript today non-standard nosuchmethod hook in Firefox modelled after Smalltalk s doesnotunderstand: function makeproxy(target) { return { } } }; nosuchmethod : function(name, args) { return target[name].apply(target, args);

7 nosuchmethod not stratified (defined as a regular application-level method) limited intercession (intercepts only missing method calls) var p = makeproxy({foo: 42}); foo in p // false p. nosuchmethod // reveals the method for (var name in p) { } // reveals nosuchmethod but not foo

8 Dynamic Proxies Objects that look and feel like normal objects, but whose behavior is controlled by another Javascript object Some use cases: Generic wrappers around existing objects: access control, tracing, profiling, contracts,... Virtual objects: remote objects, mock objects,...

9 Tracing: dynamic proxies function maketracer(obj) { var = 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 ;

10 Tracing: dynamic proxies function maketracer(obj) { var = 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 ;

11 Stratified API var = Proxy.create(, proto);

12 Stratified API var = Proxy.create(, proto);.get(, foo ).foo

13 Stratified API var = Proxy.create(, proto);.get(, foo ).set(, foo, 42).foo.foo = 42

14 Stratified API var = Proxy.create(, proto);.get(, foo ).set(, foo, 42).get(, foo ).apply(,[1,2,3]).foo.foo = 42.foo(1,2,3)

15 Stratified API var = Proxy.create(, proto);.get(, foo ).set(, foo, 42).get(, foo ).apply(,[1,2,3]).get(, get ).foo.foo = 42.foo(1,2,3).get

16 Stratified API var = Proxy.create(, proto);.get(, foo ).set(, foo, 42).get(, foo ).apply(,[1,2,3]).get(, get ).foo.foo = 42.foo(1,2,3).get proto

17 Not just property access var = Proxy.create(, proto);

18 Not just property access var = Proxy.create(, proto);.has( foo ) foo in

19 Not just property access var = Proxy.create(, proto);.has( foo ).delete( foo ) foo in delete.foo

20 Not just property access var = Proxy.create(, proto);.has( foo ).delete( foo ) var props =.enumerate(); for (i=0;i<props.length;i++) { } var prop = props[i];... foo in delete.foo for (var prop in ) {... }

21 Not just property access var = Proxy.create(, proto);.has( foo ).delete( foo ) var props =.enumerate(); for (i=0;i<props.length;i++) { } var prop = props[i];....defineproperty( foo, pd) foo in delete.foo for (var prop in ) {... } Object.defineProperty(, foo, pd)

22 But not quite everything either var = Proxy.create(, proto);

23 But not quite everything either var = Proxy.create(, proto); === obj

24 But not quite everything either var = Proxy.create(, proto); === obj Object.getPrototypeOf() => proto proto

25 But not quite everything either var = Proxy.create(, proto); === obj Object.getPrototypeOf() => proto instanceof Fun proto

26 But not quite everything either var = Proxy.create(, proto); === obj Object.getPrototypeOf() => proto instanceof Fun typeof => object proto

27 Example: no-op forwarding function ForwardingHandler(obj) { this.target = obj; } target 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]; }... var = Proxy.create(new ForwardingHandler(o), Object.getPrototypeOf(o));

28 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.create(forwarder, Object.getPrototypeOf(target)), get stats() { return count; }

29 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.create(forwarder, Object.getPrototypeOf(target)), get stats() { return count; } var subject = {... }; var profiler = makesimpleprofiler(subject); runapp(profiler.); display(profiler.stats);

30 Selective interception object

31 Selective interception VM territory (C++) object Javascript territory

32 Selective interception VM territory (C++) VM object Javascript territory

33 Selective interception VM territory (C++) Host VM host object object Javascript territory

34 Selective interception VM territory (C++) Host VM host object object Javascript territory

35 Selective interception VM territory (C++) Host VM host object object Javascript territory

36 Selective interception VM territory (C++) Host VM host object object Javascript territory

37 Fixing a Proxy (temporary intercession) var = Proxy.create(, proto);

38 Fixing a Proxy (temporary intercession) var = Proxy.create(, proto); Object.freeze() Object.seal() Object.preventExtensions()

39 Fixing a Proxy (temporary intercession) var = Proxy.create(, proto); var desc =.fix(); if (desc === undefined) throw TypeError(); become(, Object.freeze( Object.create(proto, desc))); Object.freeze() Object.seal() Object.preventExtensions()

40 Fixing a Proxy (temporary intercession) var = Proxy.create(, proto); var desc =.fix(); if (desc === undefined) throw TypeError(); become(, Object.freeze( Object.create(proto, desc))); Object.freeze() Object.seal() Object.preventExtensions() Trapping fix Fixed

41 Fixing a Proxy (temporary intercession) var = Proxy.create(, proto); var desc =.fix(); if (desc === undefined) throw TypeError(); become(, Object.freeze( Object.create(proto, desc))); Object.freeze() Object.seal() Object.preventExtensions() Trapping fix Fixed

42 Status Accepted proposal for ES-Harmony Draft specification at tinyurl.com/harmony-proxies Andreas Gal (Mozilla) prototyped an implementation in Tracemonkey

43 Status Available in Firefox 4 Betas today:

44 Summary Dynamic proxies enable: Generic wrappers: access control, profiling, adaptors,... Virtual objects: remote objects, mock objects, emulated host objects,... API: Robust (stratified, not all operations intercepted) Secure (can t trap non- or fixed objects) Performance: no overhead for non- objects es-lab.googlecode.com

Harmony Highlights Proxies & Traits. Tom Van Cutsem Mark S. Miller

Harmony Highlights Proxies & Traits. Tom Van Cutsem Mark S. Miller Harmony Highlights Proxies & Traits Tom Van Cutsem Mark S. Miller 1 Ecmascript 5 Strict Mode: guards against common pitfalls rejects confusing features (e.g. with statement) throws exceptions instead of

More information

Tradeoffs 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) 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 information

Javascript s Meta-object Protocol. Tom Van Cutsem

Javascript 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 information

Virtualizing 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 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 information

Trustworthy 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) 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 information

iwiki Documentation Release 1.0 jch

iwiki 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 information

Symbols. accessor properties, attributes, creating, adding properties, 8 anonymous functions, 20, 80

Symbols. 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 information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT 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 information

traits.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 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 information

traits.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 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 information

Changes 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 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 information

Trustworthy 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 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 information

Writing 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 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 information

JavaScript. What s wrong with JavaScript?

JavaScript. 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 information

Sebastiano

Sebastiano 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 information

Classes vs Simple Object Delegation In JavaScript

Classes 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 information

Robust Trait Composition for Javascript

Robust 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 information

ECMAScript 2015 The Future of JavaScript is Now!

ECMAScript 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 information

Classical Object-Oriented Programming with ECMAScript. Abstract. 1 Class-Like Objects in ECMA- Script. Contents

Classical Object-Oriented Programming with ECMAScript. Abstract. 1 Class-Like Objects in ECMA- Script. Contents Classical Object-Oriented Programming with ECMAScript Abstract Mike Gerwitz May 2012 ECMAScript (more popularly known by the name Java- Script ) is the language of the web. In the decades past, it has

More information

Index. Symbols. accessor properties, 74,

Index. 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 information

Static Analysis for JavaScript

Static 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 information

JavaScript: Sort of a Big Deal,

JavaScript: 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 information

Today. Continue our very basic intro to JavaScript. Lambda calculus

Today. Continue our very basic intro to JavaScript. Lambda calculus JavaScript (cont) Today Continue our very basic intro to JavaScript Lambda calculus Last lecture recap JavaScript was designed in 10 days Lots of unsatisfactory parts (in retrospect); many due due to the

More information

Securing 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 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 information

ADsafety. 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 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 information

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Maxime Chevalier-Boisvert joint work with Marc Feeley ECOOP - July 20th, 2016 Overview Previous work: Lazy Basic Block Versioning

More information

A Tested Semantics for Getters, Setters, and Eval in JavaScript

A 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 information

JavaScript Module System: Exploring the Design Space

JavaScript 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 information

Transparent Object Proxies for JavaScript

Transparent 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 information

Expressing Security Constraints using capabilities. Mark S. Miller and the Cajadores

Expressing Security Constraints using capabilities. Mark S. Miller and the Cajadores Expressing Security Constraints using capabilities Mark S. Miller and the Cajadores Overview This talk The What and Why of object-capabilities (ocaps) My Securing EcmaScript 5 talk tomorrow The How of

More information

JavaScript Lecture 1

JavaScript 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 information

Functions & First Class Function Values

Functions & 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 information

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

Midterm 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 information

JavaScript: 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 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 information

Developer Entrepreneur Crazy person

Developer 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 information

JScript Reference. Contents

JScript 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 information

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

The 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 information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. 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 information

Variable Declarations

Variable 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 information

Semantics and Security Issues in JavaScript

Semantics 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 information

DLint: Dynamically Checking Bad Coding Practices in JavaScript

DLint: Dynamically Checking Bad Coding Practices in JavaScript DLint: Dynamically Checking Bad Coding Practices in JavaScript Liang Gong 1, Michael Pradel 2, Manu Sridharan 3 and Koushik Sen 1 1 UC Berkeley 2 TU Darmstadt 3 Samsung Research America Why JavaScript?

More information

Understanding and Verifying JavaScript Programs

Understanding and Verifying JavaScript Programs Understanding and Verifying JavaScript Programs Philippa Gardner Imperial College London LFCS 30th Anniversary 1/31 JavaScript at Imperial Philippa Gardner José Fragoso Santos Petar Maksimović Daiva Naudˇziūnienė

More information

Functional JavaScript. Douglas Crockford Yahoo! Inc.

Functional 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 information

DLint: Dynamically Checking Bad Coding Practices in JavaScript

DLint: Dynamically Checking Bad Coding Practices in JavaScript DLint: Dynamically Checking Bad Coding Practices in JavaScript Liang Gong 1, Michael Pradel 2, Manu Sridharan 3 and Koushik Sen 1 1 UC Berkeley 2 TU Darmstadt 3 Samsung Research America Why JavaScript?

More information

ECMAScript 6 The Future of JavaScript is Now!

ECMAScript 6 The Future of JavaScript is Now! ECMAScript 6 The Future of JavaScript is Now! Tom Van Cutsem JOIN 15 @tvcutsem My involvement in JavaScript PhD on programming language technology 2010: Visiting Faculty at Google, Caja team Joined ECMA

More information

JavaScript Programming

JavaScript 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 information

JavaScript: The Good Parts

JavaScript: 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 information

Outline. Central concepts in OO languages Objects as activation records (Simula) Dynamically-typed object-oriented languages

Outline. 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 information

Objects. Deian Stefan (Adopted from my & Edward Yang s CS242 slides)

Objects. 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 information

Run-time characteristics of JavaScript

Run-time characteristics of JavaScript Run-time characteristics of JavaScript http://d3s.mff.cuni.cz CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Part I Introduction On paper An analysis of the Dynamic Behavior of the JavaScript

More information

NodeSentry: Security Architecture for Server-Side JavaScript

NodeSentry: Security Architecture for Server-Side JavaScript 1 / 21 NodeSentry: Security Architecture for Server-Side JavaScript Willem De Groef Fabio Massacci Frank Piessens iminds-distrinet, KU Leuven (BE) University of Trento (IT) ACSAC'14 - December 12th, 2014

More information

Javascript. Many examples from Kyle Simpson: Scope and Closures

Javascript. 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 information

Object Model. Object Oriented Programming Spring 2015

Object 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 information

Boot Camp JavaScript Sioux, March 31, 2011

Boot 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 information

HotPy (2) Binary Compatible High Performance VM for Python. Mark Shannon

HotPy (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 information

JSPP: Morphing C++ into Javascript

JSPP: 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 information

Object Orientation. Chapter Sixteen Modern Programming Languages, 2nd ed. 1

Object Orientation. Chapter Sixteen Modern Programming Languages, 2nd ed. 1 Object Orientation Chapter Sixteen Modern Programming Languages, 2nd ed. 1 Definitions Give definitions for the following: Object-oriented language Object-oriented programming Then again, why bother? Chapter

More information

The Eval that Men Do

The Eval that Men Do The Eval that Men Do Gregor Richard Christian Hammer Brian Burg Jan Vitek Vincent Foley-Bourgon COMP-621 - Winter 2014 McGill University February 2014 The paper Information 3 authors from Purdue University

More information

Node.js Training JavaScript. Richard richardrodger.com

Node.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 information

Ruby: Objects and Dynamic Types

Ruby: Objects and Dynamic Types Ruby: Objects and Dynamic Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 5 Primitive vs Reference Types Recall Java type dichotomy: Primitive: int, float,

More information

Object Model. Object Oriented Programming Winter

Object 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 information

Modern JavaScript. Keith Donald - SpringSource SpringOne 2GX All rights reserved. Do not distribute without permission.

Modern JavaScript. Keith Donald - SpringSource SpringOne 2GX All rights reserved. Do not distribute without permission. Modern JavaScript Keith Donald - SpringSource 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission. Agenda A look at Modern JavaScript Application Engineering Core Language

More information

Language Based isolation of Untrusted JavaScript

Language 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 information

INTRODUCTION TO JAVASCRIPT

INTRODUCTION 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 information

In 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 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 information

ECMAScript 2015 and beyond The Future of JavaScript is Now!

ECMAScript 2015 and beyond The Future of JavaScript is Now! ECMAScript 2015 and beyond The Future of JavaScript is Now! Tom Van Cutsem JS.BE Meetup @tvcutsem Talk Outline Part I: 20 years of JavaScript (or, the long road to ECMAScript 6) Part II: a brief tour of

More information

Secure Distributed Programming with Object-capabilities in JavaScript. Mark S. Miller and the Cajadores

Secure Distributed Programming with Object-capabilities in JavaScript. Mark S. Miller and the Cajadores Secure Distributed Programming with Object-capabilities in JavaScript Mark S. Miller and the Cajadores Overview Why object-capability (ocap) security? Local ocap security in JavaScript Flexible secure

More information

Attacking ECMAScript Engines with Redefinition. Natalie

Attacking ECMAScript Engines with Redefinition. Natalie Attacking ECMAScript Engines with Redefinition Natalie Silvanovich @natashenka About me Security Engineer on Project Zero Flash Enthusiast Redefinition Vulnerabilities ECMAScript allows anything to be

More information

JavaScript: Fundamentals, Concepts, Object Model

JavaScript: Fundamentals, Concepts, Object Model JavaScript: Fundamentals, Concepts, Object Model Prof. Ing. Andrea Omicini Ingegneria Due, Università di Bologna a Cesena andrea.omicini@unibo.it 2006-2007 JavaScript A scripting language: interpreted,

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript 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 information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. 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 information

JavaScript for PHP Developers

JavaScript for PHP Developers JavaScript for PHP Developers Ed Finkler @funkatron coj@funkatron.com May 18, 2010 #tekx #js4php http://joind.in/1564 What is this? 2 A practical overview of JS for the PHP developer Stop c+p'ing, start

More information

JavaScript Lecture 3b (Some language features)

JavaScript Lecture 3b (Some language features) Lecture 3b (Some language features) Waterford Institute of Technology June 10, 2016 John Fitzgerald Waterford Institute of Technology, Lecture 3b (Some language features) 1/30 Introduction Topics discussed

More information

A Structural Operational Semantics for JavaScript

A Structural Operational Semantics for JavaScript Dept. of Computer Science, Stanford University Joint work with Sergio Maffeis and John C. Mitchell Outline 1 Motivation Web Security problem Informal and Formal Semantics Related work 2 Formal Semantics

More information

JavaScript and V8 A functional-ish language and implementation in the mainstream

JavaScript and V8 A functional-ish language and implementation in the mainstream JavaScript and V8 A functional-ish language and implementation in the mainstream Andreas Rossberg, Google Munich rossberg@google.com CEFP 2011, Budapest Outline JavaScript Background Functional concepts

More information

arxiv: v1 [cs.pl] 15 Dec 2009

arxiv: 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 information

JavaScript Lecture 2

JavaScript Lecture 2 JavaScript Lecture 2 Waterford Institute of Technology May 5, 2016 John Fitzgerald Waterford Institute of Technology, JavaScriptLecture 2 1/28 JavaScript Introduction Topics discussed this presentation

More information

Static Analysis of JavaScript. Ben Hardekopf

Static 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 information

Metacircular 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. 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 information

JavaScript: The Good Parts. Douglas Crockford Yahoo! Inc.

JavaScript: 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 information

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //

More information

Functions. Functions in JavaScript are declared using the function keyword

Functions. 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 information

Using Tcl 8.5 Features to Build an OO System

Using Tcl 8.5 Features to Build an OO System Donal K. Fellows In this paper I aim to show that object-oriented programming using Tcl is better supported in the upcoming 8.5 release than at any time before. To show

More information

<Insert Picture Here> Adventures in JSR-292 or How To Be A Duck Without Really Trying

<Insert Picture Here> Adventures in JSR-292 or How To Be A Duck Without Really Trying Adventures in JSR-292 or How To Be A Duck Without Really Trying Jim Laskey Multi-language Lead Java Language and Tools Group The following is intended to outline our general product

More information

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context Types 1 / 15 Outline Introduction Concepts and terminology The case for static typing Implementing a static type system Basic typing relations Adding context 2 / 15 Types and type errors Type: a set of

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript 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 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) [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 information

The JavaScript Language

The JavaScript Language The JavaScript Language INTRODUCTION, CORE JAVASCRIPT Laura Farinetti - DAUIN What and why JavaScript? JavaScript is a lightweight, interpreted programming language with object-oriented capabilities primarily

More information

Browser Based Defenses

Browser Based Defenses Browser Based Defenses Introducing x06d james@bluenotch.com Browser Based Defenses - (c) 2010 All Rights Reserved 1 The Problem: Re-Anonymizing You! Overall State of the Web Client/Browser issues Hard

More information

GUARDIA: specification and enforcement of JavaScript security policies without VM modifications

GUARDIA: specification and enforcement of JavaScript security policies without VM modifications GUARDIA: specification and enforcement of JavaScript security policies without VM modifications Angel Luis Scull Pupo Vrije Universiteit Brussel Brussels, Belgium angel.luis.scull.pupo@vub.be Jens Nicolay

More information

Documents and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. Standard

Documents 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 information

Swift by Practical Example. Justin Miller

Swift by Practical Example. Justin Miller Swift by Practical Example Justin Miller Mapbox @incanus77 Introduction Mobile lead at Mapbox Eleven years of Swift experience Not really :-) But Cocoa, yes; I started with Project Builder in 10.2, pre-xcode

More information

JavaScript Basics. Mendel Rosenblum. CS142 Lecture Notes - JavaScript Basics

JavaScript Basics. Mendel Rosenblum. CS142 Lecture Notes - JavaScript Basics JavaScript Basics Mendel Rosenblum 1 What is JavaScript? From Wikipedia:... high-level, dynamic, untyped, and interpreted programming language... is prototype-based with first-class functions,... supporting

More information

JavaScript: Coercion, Functions, Arrays

JavaScript: Coercion, Functions, Arrays JavaScript: Coercion, Functions, Arrays Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 Conversion of Primitive Values String Number Boolean numbers 0 "0" false

More information

Know Your Engines How to Make Your JavaScript Fast

Know Your Engines How to Make Your JavaScript Fast Know Your Engines How to Make Your JavaScript Fast Dave Mandelin 8 November 2011 O Reilly Velocity Europe JavaScript is getting really fast and programs are getting crazy Bullet physics engine (ammo.js)

More information

Tamarin and ECMAScript 4. John Resig (ejohn.org) Mozilla Corporation

Tamarin and ECMAScript 4. John Resig (ejohn.org) Mozilla Corporation Tamarin and ECMAScript 4 John Resig (ejohn.org) Mozilla Corporation The Big Picture ECMAScript 3 JavaScript 1.5 ActionScript 2 JScript Etc. SpiderMonkey AVM JScript Engine KJS (Apple) Rhino Opera The Direction

More information

Advanced JavaScript. Konstantin Käfer. Konstantin Käfer

Advanced 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 information

Modern JavaScript: The Smalltalk Influence

Modern JavaScript: The Smalltalk Influence Modern JavaScript: The Smalltalk Influence Talk, by Allen Wirfs-Brock Mozilla Research Fellow Project Editor, Ecma-262 (The JavaScript Standard) @awbjs Smalltalks 2014 November 7, 2014 Córdoba, Argentina

More information

Principles of Programming Languages, 2

Principles of Programming Languages, 2 Principles of Programming Languages, 2 Matteo Pradella February 2015 Matteo Pradella Principles of Programming Languages, 2 February 2015 1 / 23 1 Object Oriented Programming (OO) Matteo Pradella Principles

More information

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 (These notes are very rough, and differ somewhat from what I presented in class; I am posting them here to supplemental

More information