Tamarin and ECMAScript 4

jeresig
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
                         ECMAScript 4


JavaScript 2         ActionScript 4      JScript       Etc.


                                        Screaming
               Tamarin                              KJS (Apple)
                                         Monkey


                                                      Opera
Tamarin
    Tamarin
✦
    ✦ New Virtual Machine from Adobe
    ✦ Perfect for ActionScript
      ✦ (a mutant cousin of JavaScript 2)

    The Three Monkeys:
✦
    ✦ ActionMonkey
    ✦ ScreamingMonkey
    ✦ IronMonkey
Three Monkies
    ActionMonkey
✦
    ✦ Integrating Tamarin into SpiderMonkey
    ✦ Powering Firefox 4 (?) + JavaScript 2

    ScreamingMonkey
✦
    ✦ Bringing Tamarin into Internet Explorer
    ✦ (Kicking and screaming?)

    IronMonkey
✦
    ✦ Bringing Python + Ruby to Tamarin
Jav
                a




1999
                 Sc
                      rip
                         t1
                            .5
            Jav
                a



2005
                 Sc
                      rip
                         t1
                            .6
            Jav
                a
2006
                 Sc
                      rip
                         t1
                            .7
            Jav
                a
2008
                 Sc
                      rip
                         t1
                            .8
            Ja
                                     Path to JavaScript 2




               va
                  S   cr
2008-2009




                        ip
                          t
                                 2
The JavaScript Language
    Current:
✦
    JavaScript 1.5 (ECMAScript 3)
    JavaScript 1.6 (Firefox 1.5)
✦

    JavaScript 1.7 (Firefox 2)
✦

    JavaScipt 1.8 (Firefox 3)
✦

    ...
✦

    JavaScript 2 (ECMAScript 4)
✦
ECMAScript 4 Goals
    Compatible with ECMAScript 3
✦

    Suitable to developing large systems
✦

    Allow for reusable libraries
✦

    Merge previous efforts (ActionScript)
✦

    Fix ECMAScript 3 bugs
✦

    Keep it usable for small programs
✦
Features
    Classes and Interfaces
✦

    Packages and Namespaces
✦

    Type Annotations
✦

    Strict Verification
✦

    Optimization
✦

    Syntax Shortcuts
✦

    Iterators and Generators
✦

    Self-hosting
✦
Classes
Classes
    class Programmer {
✦
       var name;
       var city = “Boston, MA”;
       const interest = “computers”;
       function work() {}
    }
    var p = new Programmer;
✦
    p.name = “John”;
    p.work();
    p.work.apply( someotherp );
    p.interest = “science”; // Error
Dynamic Classes
    dynamic class Programmer {
✦
      var name;
      var city = “Boston, MA”;
      const interest = “computers”;
      function work() {}
    }
    var p = new Programmer;
✦
    p.lastName = “Resig”;
    for ( var i in p )
       alert( i );
    // alert( “Resig” );
Getters and Setters
    class Programmer {
✦
       var _name;
       function get name(){ return _name; }
       function set name(value){
         _name = value + “ Resig”;
       }
    }
    var p = new Programmer;
✦
    p.name = “John”;
    alert( p.name );
    // “John Resig”
Catch-Alls
    dynamic class Programmer {
✦
      meta function get(name) { ... }
      meta function set(name, value) {
        alert(“Setting “ + name + “ to “ + value);
      }
    }
    var p = new Programmer
✦
    p.name = “John”;
    // alert(“Setting name to John”);
Inheritance
    class Artist {
✦
       function draw() { alert(“Drawing!”); }
    }
    class Designer extends Artist {
       override function draw() {
         alert(“Designing!”);
       }
    }
    var d = new Designer
✦
    d.draw();
    // alert(“Designing!”);
Inheritance (cont.)
    ‘final’ methods can’t be overriden
✦

    class Artist {
✦
       final function draw() {alert(“Drawing!”);}
    }
    class Designer extends Artist {
       // ERROR: Can’t override draw!
       override function draw() {
          alert(“Designing!”);
       }
    }
Inheritance (cont.)
    ‘final’ classes can’t be inherited from
✦

    final class Artist {
✦
      function draw() { alert(“Drawing!”); }
    }

    // ERROR: Can’t inherit from Artist
    class Designer extends Artist {
       override function draw() {
         alert(“Designing!”);
       }
    }
Metaclass
    Provide global functions and properties on
✦
    a class object
    class Users {
✦
       static function find( name ) {
         // ...
       }
    }
    Users.find( “John” );
✦
Interfaces
    Verify that a class implements another
✦

    interface Artist {
✦
       function draw();
    }
    class Designer implements Artist {
       function draw() { alert(“Designing!”); }
    }
    var d = new Designer();
✦
    if ( d is Artist )
       alert(“Designers are Artists!”);
Types
Numbers
    Numbers are now broken down into:
✦
    ✦ byte
    ✦ int
    ✦ uint
    ✦ double (ECMAScript 3-style Number)
    ✦ decimal
Type Annotations
    var name : string = “John”;
✦

    let x : double = 5.3;
✦

    function stuff( x: int, obj: Object ) :
✦
    boolean {}
Function Types
    Only return specific types:
✦
    function isValid() : boolean { }
    Only be used on certain objects types:
✦
    function every( this: Array, value: int ) {
       for ( var i = 0; i < this.length; i++ )
          alert( this[i] );
    }
    every.call( [0,1,2], 3 );
    // alert(0); alert(1); alert(2);
    every.call({a: “b”}, 4);
    // ERROR
Rest Arguments
    function stuff( name, ...values ){
✦
      alert( values.length );
    }
    stuff( “John”, 1, 2, 3, 4 );
✦
    // alert( 4 );
    function stuff( name : string, ...values : [int] ) : void {
✦
      alert( values.length );
    }
Union and Any Types
    var test : (string, int, double) = “test”;
✦
    test = 3;
    test = false; // ERROR
    type AnyNumber = (byte, int, double, decimal, uint);
✦



    var test : AnyNumber = 3
✦

    These are equivalent:
✦
    ✦ var test : * = “test”;
    ✦ var test = “test”;
Type Definitions
    type Point = { x: int, y: int };
✦

    var p : Point = { x: 3, y: 24 };
✦
Nullability
    Prevent variables from accepting null
✦
    values
    var name : * = “John”;
✦

    var name : String! = “John”;
✦
    name = “Ted”;
    name = null; // ERROR
    function test( name: String? ) {
✦
      alert( name );
    }
Initialization
    class User {
✦
       var name : string!; // Must be initialized
       var last : string!;
       function User( n, l ) : name = n, last = l {
          // ...
       }
    }
“like”
    type Point = { x: int, y: int };
✦

    if ( { x: 3, y: 5 } like Point )
✦
       alert( “That looks like a point to me!” );
    if ( !({ x: 3 } like Point) )
✦
       alert( “Not a point!” );
    // Loop over array-like things:
✦
    function every( a: like { length: uint } ) {
       for ( var i = 0; i < a.length; i++ )
         alert( a[i] );
    }
“wrap”
    Force a type if compatible one doesn’t
✦
    exist
    type Point = { x: int, y: int };
✦
    var p: wrap Point = { x: 3, y: 8 };
    var p: Point = { x: 3, y: 8 } wrap Point;
✦

    var p: Point = { x: 3, y: 8 } : Point;
✦
Parameterized Types
    var m: Map.<Object, string>;
✦

    class Point.<T> {
✦
       var x: T, y: T;
    }
    var p = new Point.<double>;
✦
    p.x = 3.0;
    p.y = 5.0;
Structure
For .. Each
    For each loops through values
✦

    let s = “”;
✦
    for each ( let n in [“a”,”b”,”c”] )
        s += n;
    alert(s);
    // “abc”
let statements
    for ( let i = 0; i < a.length; i++ )
✦
        alert( a[i] );
    // i is undefined
    Using block statements:
✦
    {
        let x = 5;
        {
           let x = 6;
           alert( x ); // 6
        }
        alert( x ); // 5
    }
let (cont.)
    let expressions:
✦
    var a = 5;
    var x = 10 + (let (a=3) a) + a*a;
    // x == 19
    let blocks:
✦
    let ( a=3 ) {
       alert( a ); // 3
    }
    // a is undefined
    let a = function(){ };
✦
Packages
    package simple.tracker {
✦
      internal var count: int = 0;
      public function add(){
        return ++count;
      }
    }
    import simple.tracker.*
✦
    alert( add() ); // alert(“1”)
    count // ERROR, undefined
Namespaces
    namespace extra = “extra”;
✦

    Pre-defined namespaces:
✦
    ✦ __ES4__
      ✦ intrinsic
      ✦ iterator
      ✦ meta

    import dojo.query;
✦
    import jquery.query;
    dojo::query(“#foo”)
    jquery::query(“div > .foo”)
Namespaces (cont.)
    import dojo.query;
✦
    import jquery.query;
    use namespace dojo;
    query(“#foo”) // using dojo

    use namespace jquery;
    query(“div > .foo”) // using jquery
Multimethods
    generic function intersect(s1, s2);
✦
    generic function intersect(s1: Shape, s2: Shape ) {
      // ...
    }
    generic function intersect(s1: Rect, s2: Rect ) {
      // ...
    }
Program Units
    use unit jQuery “http://jquery.com/jQuery”
✦
    import com.jquery.*;
    new jQuery();
    unit jQuery {
✦
      use unit Selectors “lib/Selectors”;
      package com.jquery {
         class jQuery {
            function find() : jQuery {}
         }
      }
    }
Operator Overloading
    class Complex! { ... }
✦


    generic intrinsic function +(a: Complex, b: Complex)
      new Complex( a.real + b.real, a.imag + b.imag )

    generic intrinsic function +(a: Complex, b: AnyNumber)
      a + Complex(b)

    generic intrinsic function +(a: AnyNumber, b: Complex)
      Complex(a) + b
Self-Hosting
Map.es
    The reference implementation’s classes are
✦
    written in ECMAScript
    package
✦
    {
      use namespace intrinsic;
      use default namespace public;
      intrinsic class Map.<K,V>
      {
        static const length = 2;
        function Map(equals=intrinsic::===, hashcode=intrinsic::hashcode)
            : equals = equals
            , hashcode = hashcode
            , element_count = 0
        {
        }
        // ...
    }
More Info
    ECMAScript site:
✦
    http://ecmascript.org/
    ECMAScript 4 White Paper Overview:
✦
    http://www.ecmascript.org/es4/spec/overview.pdf

    Blogging:
✦
    http://ejohn.org/
1 of 44

Recommended

ES6 in Production [JSConfUY2015] by
ES6 in Production [JSConfUY2015]ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]Guillermo Paz
1.7K views119 slides
The Future of JavaScript (Ajax Exp '07) by
The Future of JavaScript (Ajax Exp '07)The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)jeresig
1.2K views45 slides
Swift 2 by
Swift 2Swift 2
Swift 2Jens Ravens
1K views21 slides
An introduction to JVM performance by
An introduction to JVM performanceAn introduction to JVM performance
An introduction to JVM performanceRafael Winterhalter
7.3K views49 slides
A topology of memory leaks on the JVM by
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVMRafael Winterhalter
7.1K views36 slides
The algebra of library design by
The algebra of library designThe algebra of library design
The algebra of library designLeonardo Borges
600 views76 slides

More Related Content

What's hot

Java Generics - by Example by
Java Generics - by ExampleJava Generics - by Example
Java Generics - by ExampleGanesh Samarthyam
767 views49 slides
Monitoring distributed (micro-)services by
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)servicesRafael Winterhalter
1.8K views43 slides
A Re-Introduction to JavaScript by
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScriptSimon Willison
6.8K views111 slides
Advanced Debugging Using Java Bytecodes by
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
8.4K views60 slides
How do you create a programming language for the JVM? by
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?Federico Tomassetti
145 views55 slides

What's hot(20)

A Re-Introduction to JavaScript by Simon Willison
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison6.8K views
Advanced Debugging Using Java Bytecodes by Ganesh Samarthyam
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam8.4K views
How do you create a programming language for the JVM? by Federico Tomassetti
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
What's new in Scala 2.13? by Hermann Hueck
What's new in Scala 2.13?What's new in Scala 2.13?
What's new in Scala 2.13?
Hermann Hueck2.5K views
Denis Lebedev, Swift by Yandex
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
Yandex38.4K views
Understanding Java byte code and the class file format by Rafael Winterhalter
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
Rafael Winterhalter4.2K views
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014 by Susan Potter
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Susan Potter2.9K views
Java Keeps Throttling Up! by José Paumard
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
José Paumard1.2K views
Cocoa Design Patterns in Swift by Michele Titolo
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in Swift
Michele Titolo9.1K views
Kotlin Bytecode Generation and Runtime Performance by intelliyole
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
intelliyole10.8K views
Joe Bew - Apprendi un nuovo linguaggio sfruttando il TDD e il Clean Code - Co... by Codemotion
Joe Bew - Apprendi un nuovo linguaggio sfruttando il TDD e il Clean Code - Co...Joe Bew - Apprendi un nuovo linguaggio sfruttando il TDD e il Clean Code - Co...
Joe Bew - Apprendi un nuovo linguaggio sfruttando il TDD e il Clean Code - Co...
Codemotion335 views

Viewers also liked

Ethan b the green tree pythons by
Ethan b the green tree pythonsEthan b the green tree pythons
Ethan b the green tree pythonsginageo65
916 views8 slides
Bk by
BkBk
Bknkevern
527 views13 slides
Lily o golden lion tamarin monkey by
Lily o golden lion tamarin monkeyLily o golden lion tamarin monkey
Lily o golden lion tamarin monkeyginageo65
2K views9 slides
Cass t the golden lion tamarin by
Cass t the golden lion tamarinCass t the golden lion tamarin
Cass t the golden lion tamaringinageo65
562 views9 slides
Martin_L_Gold lion tamarin monkey by
Martin_L_Gold lion tamarin monkeyMartin_L_Gold lion tamarin monkey
Martin_L_Gold lion tamarin monkeyginageo65
901 views9 slides
Plant adaptations by
Plant adaptationsPlant adaptations
Plant adaptationsVivek Srivastava
307.4K views45 slides

Viewers also liked(6)

Ethan b the green tree pythons by ginageo65
Ethan b the green tree pythonsEthan b the green tree pythons
Ethan b the green tree pythons
ginageo65916 views
Bk by nkevern
BkBk
Bk
nkevern527 views
Lily o golden lion tamarin monkey by ginageo65
Lily o golden lion tamarin monkeyLily o golden lion tamarin monkey
Lily o golden lion tamarin monkey
ginageo652K views
Cass t the golden lion tamarin by ginageo65
Cass t the golden lion tamarinCass t the golden lion tamarin
Cass t the golden lion tamarin
ginageo65562 views
Martin_L_Gold lion tamarin monkey by ginageo65
Martin_L_Gold lion tamarin monkeyMartin_L_Gold lion tamarin monkey
Martin_L_Gold lion tamarin monkey
ginageo65901 views

Similar to Tamarin and ECMAScript 4

Tamarin And Ecmascript 4 by
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4elliando dias
276 views44 slides
JavaScript 1.5 to 2.0 (TomTom) by
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)jeresig
17.7K views53 slides
What's up with Prototype and script.aculo.us? by
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?Christophe Porteneuve
972 views57 slides
ECMAScript 6 by
ECMAScript 6ECMAScript 6
ECMAScript 6偉格 高
2K views109 slides
Javascript status 2016 by
Javascript status 2016Javascript status 2016
Javascript status 2016Arshavski Alexander
180 views60 slides
javascript teach by
javascript teachjavascript teach
javascript teachguest3732fa
1.2K views155 slides

Similar to Tamarin and ECMAScript 4(20)

Tamarin And Ecmascript 4 by elliando dias
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
elliando dias276 views
JavaScript 1.5 to 2.0 (TomTom) by jeresig
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
jeresig17.7K views
javascript teach by guest3732fa
javascript teachjavascript teach
javascript teach
guest3732fa1.2K views
JSBootcamp_White by guest3732fa
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
guest3732fa907 views
Functional Javascript by guest4d57e6
Functional JavascriptFunctional Javascript
Functional Javascript
guest4d57e61.9K views
History of jQuery by jeresig
History of jQueryHistory of jQuery
History of jQuery
jeresig9.9K views
JavaScript and UI Architecture Best Practices by Siarhei Barysiuk
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk8.9K views
Building a JavaScript Library by jeresig
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
jeresig11.7K views
Groovy and Grails talk by desistartups
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
desistartups577 views
Migrating To Ruby1.9 by tomaspavelka
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
tomaspavelka372 views
Programming Android Application in Scala. by Brian Hsu
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
Brian Hsu2.4K views
MiamiJS - The Future of JavaScript by Caridy Patino
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
Caridy Patino762 views
Game Design and Development Workshop Day 1 by Troy Miles
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles494 views
Introduction to Scala for Java Developers by Michael Galpin
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
Michael Galpin5.8K views
Shibuya.js Lightning Talks by jeresig
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talks
jeresig1.5K views
JSUG - Tech Tips1 by Christoph Pickl by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph Pickl
Christoph Pickl481 views

More from jeresig

Does Coding Every Day Matter? by
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?jeresig
3K views19 slides
Accidentally Becoming a Digital Librarian by
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarianjeresig
1.3K views72 slides
2014: John's Favorite Thing (Neo4j) by
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)jeresig
847 views42 slides
Computer Vision as Art Historical Investigation by
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigationjeresig
1K views89 slides
Hacking Art History by
Hacking Art HistoryHacking Art History
Hacking Art Historyjeresig
925 views107 slides
Using JS to teach JS at Khan Academy by
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academyjeresig
1K views25 slides

More from jeresig(20)

Does Coding Every Day Matter? by jeresig
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?
jeresig3K views
Accidentally Becoming a Digital Librarian by jeresig
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarian
jeresig1.3K views
2014: John's Favorite Thing (Neo4j) by jeresig
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)
jeresig847 views
Computer Vision as Art Historical Investigation by jeresig
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigation
jeresig1K views
Hacking Art History by jeresig
Hacking Art HistoryHacking Art History
Hacking Art History
jeresig925 views
Using JS to teach JS at Khan Academy by jeresig
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academy
jeresig1K views
Applying Computer Vision to Art History by jeresig
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
jeresig826 views
NYARC 2014: Frick/Zeri Results by jeresig
NYARC 2014: Frick/Zeri ResultsNYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri Results
jeresig2.1K views
EmpireJS: Hacking Art with Node js and Image Analysis by jeresig
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysis
jeresig18.5K views
Applying Computer Vision to Art History by jeresig
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
jeresig3.1K views
JavaScript Libraries (Ajax Exp 2006) by jeresig
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
jeresig3.1K views
Introduction to jQuery (Ajax Exp 2006) by jeresig
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
jeresig2.4K views
jQuery Recommendations to the W3C (2011) by jeresig
jQuery Recommendations to the W3C (2011)jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)
jeresig1.7K views
jQuery Open Source Process (RIT 2011) by jeresig
jQuery Open Source Process (RIT 2011)jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)
jeresig1.7K views
jQuery Open Source Process (Knight Foundation 2011) by jeresig
jQuery Open Source Process (Knight Foundation 2011)jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)
jeresig2.2K views
jQuery Mobile by jeresig
jQuery MobilejQuery Mobile
jQuery Mobile
jeresig1.5K views
jQuery Open Source (Fronteer 2011) by jeresig
jQuery Open Source (Fronteer 2011)jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)
jeresig4K views
Holistic JavaScript Performance by jeresig
Holistic JavaScript PerformanceHolistic JavaScript Performance
Holistic JavaScript Performance
jeresig4K views
New Features Coming in Browsers (RIT '09) by jeresig
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
jeresig1.5K views
Introduction to jQuery (Ajax Exp 2007) by jeresig
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
jeresig1.3K views

Recently uploaded

Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...ShapeBlue
101 views17 slides
NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
365 views30 slides
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
50 views35 slides
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...ShapeBlue
88 views13 slides
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
179 views7 slides
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
385 views86 slides

Recently uploaded(20)

Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue101 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu365 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue88 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue179 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software385 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely78 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue146 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue154 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue98 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE69 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue197 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue210 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue176 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue103 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue181 views

Tamarin and ECMAScript 4

  • 1. Tamarin and ECMAScript 4 John Resig (ejohn.org) Mozilla Corporation
  • 2. The Big Picture ECMAScript 3 JavaScript 1.5 ActionScript 2 JScript Etc. SpiderMonkey AVM JScript Engine KJS (Apple) Rhino Opera
  • 3. The Direction ECMAScript 4 JavaScript 2 ActionScript 4 JScript Etc. Screaming Tamarin KJS (Apple) Monkey Opera
  • 4. Tamarin Tamarin ✦ ✦ New Virtual Machine from Adobe ✦ Perfect for ActionScript ✦ (a mutant cousin of JavaScript 2) The Three Monkeys: ✦ ✦ ActionMonkey ✦ ScreamingMonkey ✦ IronMonkey
  • 5. Three Monkies ActionMonkey ✦ ✦ Integrating Tamarin into SpiderMonkey ✦ Powering Firefox 4 (?) + JavaScript 2 ScreamingMonkey ✦ ✦ Bringing Tamarin into Internet Explorer ✦ (Kicking and screaming?) IronMonkey ✦ ✦ Bringing Python + Ruby to Tamarin
  • 6. Jav a 1999 Sc rip t1 .5 Jav a 2005 Sc rip t1 .6 Jav a 2006 Sc rip t1 .7 Jav a 2008 Sc rip t1 .8 Ja Path to JavaScript 2 va S cr 2008-2009 ip t 2
  • 7. The JavaScript Language Current: ✦ JavaScript 1.5 (ECMAScript 3) JavaScript 1.6 (Firefox 1.5) ✦ JavaScript 1.7 (Firefox 2) ✦ JavaScipt 1.8 (Firefox 3) ✦ ... ✦ JavaScript 2 (ECMAScript 4) ✦
  • 8. ECMAScript 4 Goals Compatible with ECMAScript 3 ✦ Suitable to developing large systems ✦ Allow for reusable libraries ✦ Merge previous efforts (ActionScript) ✦ Fix ECMAScript 3 bugs ✦ Keep it usable for small programs ✦
  • 9. Features Classes and Interfaces ✦ Packages and Namespaces ✦ Type Annotations ✦ Strict Verification ✦ Optimization ✦ Syntax Shortcuts ✦ Iterators and Generators ✦ Self-hosting ✦
  • 11. Classes class Programmer { ✦ var name; var city = “Boston, MA”; const interest = “computers”; function work() {} } var p = new Programmer; ✦ p.name = “John”; p.work(); p.work.apply( someotherp ); p.interest = “science”; // Error
  • 12. Dynamic Classes dynamic class Programmer { ✦ var name; var city = “Boston, MA”; const interest = “computers”; function work() {} } var p = new Programmer; ✦ p.lastName = “Resig”; for ( var i in p ) alert( i ); // alert( “Resig” );
  • 13. Getters and Setters class Programmer { ✦ var _name; function get name(){ return _name; } function set name(value){ _name = value + “ Resig”; } } var p = new Programmer; ✦ p.name = “John”; alert( p.name ); // “John Resig”
  • 14. Catch-Alls dynamic class Programmer { ✦ meta function get(name) { ... } meta function set(name, value) { alert(“Setting “ + name + “ to “ + value); } } var p = new Programmer ✦ p.name = “John”; // alert(“Setting name to John”);
  • 15. Inheritance class Artist { ✦ function draw() { alert(“Drawing!”); } } class Designer extends Artist { override function draw() { alert(“Designing!”); } } var d = new Designer ✦ d.draw(); // alert(“Designing!”);
  • 16. Inheritance (cont.) ‘final’ methods can’t be overriden ✦ class Artist { ✦ final function draw() {alert(“Drawing!”);} } class Designer extends Artist { // ERROR: Can’t override draw! override function draw() { alert(“Designing!”); } }
  • 17. Inheritance (cont.) ‘final’ classes can’t be inherited from ✦ final class Artist { ✦ function draw() { alert(“Drawing!”); } } // ERROR: Can’t inherit from Artist class Designer extends Artist { override function draw() { alert(“Designing!”); } }
  • 18. Metaclass Provide global functions and properties on ✦ a class object class Users { ✦ static function find( name ) { // ... } } Users.find( “John” ); ✦
  • 19. Interfaces Verify that a class implements another ✦ interface Artist { ✦ function draw(); } class Designer implements Artist { function draw() { alert(“Designing!”); } } var d = new Designer(); ✦ if ( d is Artist ) alert(“Designers are Artists!”);
  • 20. Types
  • 21. Numbers Numbers are now broken down into: ✦ ✦ byte ✦ int ✦ uint ✦ double (ECMAScript 3-style Number) ✦ decimal
  • 22. Type Annotations var name : string = “John”; ✦ let x : double = 5.3; ✦ function stuff( x: int, obj: Object ) : ✦ boolean {}
  • 23. Function Types Only return specific types: ✦ function isValid() : boolean { } Only be used on certain objects types: ✦ function every( this: Array, value: int ) { for ( var i = 0; i < this.length; i++ ) alert( this[i] ); } every.call( [0,1,2], 3 ); // alert(0); alert(1); alert(2); every.call({a: “b”}, 4); // ERROR
  • 24. Rest Arguments function stuff( name, ...values ){ ✦ alert( values.length ); } stuff( “John”, 1, 2, 3, 4 ); ✦ // alert( 4 ); function stuff( name : string, ...values : [int] ) : void { ✦ alert( values.length ); }
  • 25. Union and Any Types var test : (string, int, double) = “test”; ✦ test = 3; test = false; // ERROR type AnyNumber = (byte, int, double, decimal, uint); ✦ var test : AnyNumber = 3 ✦ These are equivalent: ✦ ✦ var test : * = “test”; ✦ var test = “test”;
  • 26. Type Definitions type Point = { x: int, y: int }; ✦ var p : Point = { x: 3, y: 24 }; ✦
  • 27. Nullability Prevent variables from accepting null ✦ values var name : * = “John”; ✦ var name : String! = “John”; ✦ name = “Ted”; name = null; // ERROR function test( name: String? ) { ✦ alert( name ); }
  • 28. Initialization class User { ✦ var name : string!; // Must be initialized var last : string!; function User( n, l ) : name = n, last = l { // ... } }
  • 29. “like” type Point = { x: int, y: int }; ✦ if ( { x: 3, y: 5 } like Point ) ✦ alert( “That looks like a point to me!” ); if ( !({ x: 3 } like Point) ) ✦ alert( “Not a point!” ); // Loop over array-like things: ✦ function every( a: like { length: uint } ) { for ( var i = 0; i < a.length; i++ ) alert( a[i] ); }
  • 30. “wrap” Force a type if compatible one doesn’t ✦ exist type Point = { x: int, y: int }; ✦ var p: wrap Point = { x: 3, y: 8 }; var p: Point = { x: 3, y: 8 } wrap Point; ✦ var p: Point = { x: 3, y: 8 } : Point; ✦
  • 31. Parameterized Types var m: Map.<Object, string>; ✦ class Point.<T> { ✦ var x: T, y: T; } var p = new Point.<double>; ✦ p.x = 3.0; p.y = 5.0;
  • 33. For .. Each For each loops through values ✦ let s = “”; ✦ for each ( let n in [“a”,”b”,”c”] ) s += n; alert(s); // “abc”
  • 34. let statements for ( let i = 0; i < a.length; i++ ) ✦ alert( a[i] ); // i is undefined Using block statements: ✦ { let x = 5; { let x = 6; alert( x ); // 6 } alert( x ); // 5 }
  • 35. let (cont.) let expressions: ✦ var a = 5; var x = 10 + (let (a=3) a) + a*a; // x == 19 let blocks: ✦ let ( a=3 ) { alert( a ); // 3 } // a is undefined let a = function(){ }; ✦
  • 36. Packages package simple.tracker { ✦ internal var count: int = 0; public function add(){ return ++count; } } import simple.tracker.* ✦ alert( add() ); // alert(“1”) count // ERROR, undefined
  • 37. Namespaces namespace extra = “extra”; ✦ Pre-defined namespaces: ✦ ✦ __ES4__ ✦ intrinsic ✦ iterator ✦ meta import dojo.query; ✦ import jquery.query; dojo::query(“#foo”) jquery::query(“div > .foo”)
  • 38. Namespaces (cont.) import dojo.query; ✦ import jquery.query; use namespace dojo; query(“#foo”) // using dojo use namespace jquery; query(“div > .foo”) // using jquery
  • 39. Multimethods generic function intersect(s1, s2); ✦ generic function intersect(s1: Shape, s2: Shape ) { // ... } generic function intersect(s1: Rect, s2: Rect ) { // ... }
  • 40. Program Units use unit jQuery “http://jquery.com/jQuery” ✦ import com.jquery.*; new jQuery(); unit jQuery { ✦ use unit Selectors “lib/Selectors”; package com.jquery { class jQuery { function find() : jQuery {} } } }
  • 41. Operator Overloading class Complex! { ... } ✦ generic intrinsic function +(a: Complex, b: Complex) new Complex( a.real + b.real, a.imag + b.imag ) generic intrinsic function +(a: Complex, b: AnyNumber) a + Complex(b) generic intrinsic function +(a: AnyNumber, b: Complex) Complex(a) + b
  • 43. Map.es The reference implementation’s classes are ✦ written in ECMAScript package ✦ { use namespace intrinsic; use default namespace public; intrinsic class Map.<K,V> { static const length = 2; function Map(equals=intrinsic::===, hashcode=intrinsic::hashcode) : equals = equals , hashcode = hashcode , element_count = 0 { } // ... }
  • 44. More Info ECMAScript site: ✦ http://ecmascript.org/ ECMAScript 4 White Paper Overview: ✦ http://www.ecmascript.org/es4/spec/overview.pdf Blogging: ✦ http://ejohn.org/