SlideShare a Scribd company logo
1 of 45
Download to read offline
The Future of JavaScript
      John Resig (ejohn.org)
       Mozilla Corporation
The Big Picture
                     ECMAScript 3


JavaScript 1.5   ActionScript 2        JScript       Etc.


SpiderMonkey         AVM            JScript Engine


   Rhino
The Direction
                         ECMAScript 4


JavaScript 2         ActionScript 4       JScript 8      Etc.


               Tamarin                  JScript Engine
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
    ✦ Forcing 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
            Jav              .6
                a
2006
                 Sc
                      rip
                         t1
            Jav              .7
                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
✦   Types
✦   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
✦   class Artist {
       function draw() { alert(“Drawing!”); }
    }

    class Designer implements Artist {
       function draw() { alert(“Designing!”); }
    }
✦   if ( Designer 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 ) {
       for ( var i = 0; i < this.length; i++ )
          alert( this[i] );
    }
    every.call( [0,1,2] );
    // alert(0); alert(1); alert(2);
    every.call({a: “b”});
    // 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) = “test”;
    test = 3;
    test = 3.4; // ERROR
✦   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
       function User( n ) : name = n {
          // ...
       }
    }
“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: int } ) {
       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;
Parameterized Types
✦   var m: Map<string, *>;
✦   class Point<T> {
       var x: T, y: T;
    }
✦   var p: Point<double> = new Point<double>
    p.x = 3.0;
    p.y = 5.0;
Structure
let statements
✦   for ( let i = 0; i < a.length; i++ )
      alert( a[i] );
    typeof i == “undefined”
✦   Using block statements:
    {
        let x = 5;
        {
           let x = 6;
           alert( x ); // 6
        }
        alert( x ); // 5
    }
let (cont.)
✦   let expressions:
    x = 10 + let (a=3) a*a;
    // x == 19
✦   let blocks:
    let ( a=3 ) {
      alert( a ); // 3
    }
    typeof a == “undefined”
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”
✦   unit jQuery {
      use unit Selectors “lib/Selectors”;
      package com.jquery {
         class jQuery {
            function find() : jQuery {}
         }
      }
    }
Iteration
✦   class Fib {
       private var a=0, b=1;

        iterator function get(deep:boolean = false) : IteratorType.<int>
           this

        public function next(): int {
          if ( b > 100 )
              throw iterator::StopIteration;
          [a,b] = [b,a+b];
          return a;
        }
    }

✦   for ( let i in new Fib )
      alert( i );
For .. Each
✦   For each loops through values
✦   let s = “”;
    for each ( let n in [“a”,”b”,”c”] )
        s += n;
    alert(s);
    // “abc”
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 4 White Paper Overview:
    http://www.ecmascript.org/es4/spec/overview.pdf
✦   Blogging:
    http://ejohn.org/

More Related Content

What's hot

The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
 
The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)jeffz
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscexjeffz
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Raimon Ràfols
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)Yeshwanth Kumar
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahNick Plante
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScriptGarth Gilmour
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines Parashuram N
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyIván López Martín
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in GolangDan Tran
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 

What's hot (20)

The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
 
The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
 
C++11
C++11C++11
C++11
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScript
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
Day 1
Day 1Day 1
Day 1
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 

Viewers also liked

JavaScript is Real Code
JavaScript is Real CodeJavaScript is Real Code
JavaScript is Real CodeLen Smith
 
Was ein Tantra Kurs beinhalten sollte
Was ein Tantra Kurs beinhalten sollte Was ein Tantra Kurs beinhalten sollte
Was ein Tantra Kurs beinhalten sollte Me
 
ES6: The future of JavaScript
ES6: The future of JavaScriptES6: The future of JavaScript
ES6: The future of JavaScriptRob Schley
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsersjeresig
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptMohd Saeed
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJungryul Choi
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webSigma Software
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...Mark Leusink
 
node.js, javascript and the future
node.js, javascript and the futurenode.js, javascript and the future
node.js, javascript and the futureJeff Miccolis
 
jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)jeresig
 
Cottage Cell Phone In China
Cottage Cell Phone In ChinaCottage Cell Phone In China
Cottage Cell Phone In ChinaYuancheng Yang
 
Can the creative industries lead us to a sustainable future? Dan Burgess talk...
Can the creative industries lead us to a sustainable future? Dan Burgess talk...Can the creative industries lead us to a sustainable future? Dan Burgess talk...
Can the creative industries lead us to a sustainable future? Dan Burgess talk...Dan Burgess
 
JAVASCRIPT: Future of Web Development
JAVASCRIPT: Future of Web DevelopmentJAVASCRIPT: Future of Web Development
JAVASCRIPT: Future of Web DevelopmentDeepak Jha
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Viewers also liked (15)

JavaScript is Real Code
JavaScript is Real CodeJavaScript is Real Code
JavaScript is Real Code
 
Was ein Tantra Kurs beinhalten sollte
Was ein Tantra Kurs beinhalten sollte Was ein Tantra Kurs beinhalten sollte
Was ein Tantra Kurs beinhalten sollte
 
Jill 11
Jill 11Jill 11
Jill 11
 
ES6: The future of JavaScript
ES6: The future of JavaScriptES6: The future of JavaScript
ES6: The future of JavaScript
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
 
Getting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascriptGetting started with ES6 : Future of javascript
Getting started with ES6 : Future of javascript
 
JavaScript: Past, Present, Future
JavaScript: Past, Present, FutureJavaScript: Past, Present, Future
JavaScript: Past, Present, Future
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
node.js, javascript and the future
node.js, javascript and the futurenode.js, javascript and the future
node.js, javascript and the future
 
jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)jQuery Open Source Process (RIT 2011)
jQuery Open Source Process (RIT 2011)
 
Cottage Cell Phone In China
Cottage Cell Phone In ChinaCottage Cell Phone In China
Cottage Cell Phone In China
 
Can the creative industries lead us to a sustainable future? Dan Burgess talk...
Can the creative industries lead us to a sustainable future? Dan Burgess talk...Can the creative industries lead us to a sustainable future? Dan Burgess talk...
Can the creative industries lead us to a sustainable future? Dan Burgess talk...
 
JAVASCRIPT: Future of Web Development
JAVASCRIPT: Future of Web DevelopmentJAVASCRIPT: Future of Web Development
JAVASCRIPT: Future of Web Development
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similar to The Future of JavaScript (Ajax Exp '07)

Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4elliando dias
 
Shibuya.js Lightning Talks
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talksjeresig
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)jeresig
 
TypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyTypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyRalph Johnson
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Fwdays
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersRick Beerendonk
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018 Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScriptAleš Najmann
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topicsRajesh Verma
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
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?
What's up with Prototype and script.aculo.us?Christophe Porteneuve
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorovSergei Egorov
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummiessantiagoaguiar
 

Similar to The Future of JavaScript (Ajax Exp '07) (20)

Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
 
Shibuya.js Lightning Talks
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talks
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
TypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyTypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason Haffey
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018 Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScript
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
 
C++ theory
C++ theoryC++ theory
C++ theory
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
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?
What's up with Prototype and script.aculo.us?
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
Haxe by sergei egorov
Haxe by sergei egorovHaxe by sergei egorov
Haxe by sergei egorov
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 

More from jeresig

Does Coding Every Day Matter?
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?jeresig
 
Accidentally Becoming a Digital Librarian
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarianjeresig
 
2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)jeresig
 
Computer Vision as Art Historical Investigation
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigationjeresig
 
Hacking Art History
Hacking Art HistoryHacking Art History
Hacking Art Historyjeresig
 
Using JS to teach JS at Khan Academy
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academyjeresig
 
Applying Computer Vision to Art History
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art Historyjeresig
 
NYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri ResultsNYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri Resultsjeresig
 
EmpireJS: Hacking Art with Node js and Image Analysis
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 Analysisjeresig
 
Applying Computer Vision to Art History
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art Historyjeresig
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)jeresig
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)jeresig
 
jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)jeresig
 
jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)jeresig
 
jQuery Mobile
jQuery MobilejQuery Mobile
jQuery Mobilejeresig
 
jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)jeresig
 
Holistic JavaScript Performance
Holistic JavaScript PerformanceHolistic JavaScript Performance
Holistic JavaScript Performancejeresig
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)jeresig
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)jeresig
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)jeresig
 

More from jeresig (20)

Does Coding Every Day Matter?
Does Coding Every Day Matter?Does Coding Every Day Matter?
Does Coding Every Day Matter?
 
Accidentally Becoming a Digital Librarian
Accidentally Becoming a Digital LibrarianAccidentally Becoming a Digital Librarian
Accidentally Becoming a Digital Librarian
 
2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)2014: John's Favorite Thing (Neo4j)
2014: John's Favorite Thing (Neo4j)
 
Computer Vision as Art Historical Investigation
Computer Vision as Art Historical InvestigationComputer Vision as Art Historical Investigation
Computer Vision as Art Historical Investigation
 
Hacking Art History
Hacking Art HistoryHacking Art History
Hacking Art History
 
Using JS to teach JS at Khan Academy
Using JS to teach JS at Khan AcademyUsing JS to teach JS at Khan Academy
Using JS to teach JS at Khan Academy
 
Applying Computer Vision to Art History
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
 
NYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri ResultsNYARC 2014: Frick/Zeri Results
NYARC 2014: Frick/Zeri Results
 
EmpireJS: Hacking Art with Node js and Image Analysis
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
 
Applying Computer Vision to Art History
Applying Computer Vision to Art HistoryApplying Computer Vision to Art History
Applying Computer Vision to Art History
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
 
jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)jQuery Recommendations to the W3C (2011)
jQuery Recommendations to the W3C (2011)
 
jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)jQuery Open Source Process (Knight Foundation 2011)
jQuery Open Source Process (Knight Foundation 2011)
 
jQuery Mobile
jQuery MobilejQuery Mobile
jQuery Mobile
 
jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)jQuery Open Source (Fronteer 2011)
jQuery Open Source (Fronteer 2011)
 
Holistic JavaScript Performance
Holistic JavaScript PerformanceHolistic JavaScript Performance
Holistic JavaScript Performance
 
New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)New Features Coming in Browsers (RIT '09)
New Features Coming in Browsers (RIT '09)
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
 

The Future of JavaScript (Ajax Exp '07)

  • 1. The Future of JavaScript John Resig (ejohn.org) Mozilla Corporation
  • 2. The Big Picture ECMAScript 3 JavaScript 1.5 ActionScript 2 JScript Etc. SpiderMonkey AVM JScript Engine Rhino
  • 3. The Direction ECMAScript 4 JavaScript 2 ActionScript 4 JScript 8 Etc. Tamarin JScript Engine
  • 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 ✦ Forcing 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 Jav .6 a 2006 Sc rip t1 Jav .7 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 ✦ Types ✦ 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 ✦ class Artist { function draw() { alert(“Drawing!”); } } class Designer implements Artist { function draw() { alert(“Designing!”); } } ✦ if ( Designer 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 ) { for ( var i = 0; i < this.length; i++ ) alert( this[i] ); } every.call( [0,1,2] ); // alert(0); alert(1); alert(2); every.call({a: “b”}); // 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) = “test”; test = 3; test = 3.4; // ERROR ✦ 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 function User( n ) : name = n { // ... } }
  • 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: int } ) { 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;
  • 31. Parameterized Types ✦ var m: Map<string, *>; ✦ class Point<T> { var x: T, y: T; } ✦ var p: Point<double> = new Point<double> p.x = 3.0; p.y = 5.0;
  • 33. let statements ✦ for ( let i = 0; i < a.length; i++ ) alert( a[i] ); typeof i == “undefined” ✦ Using block statements: { let x = 5; { let x = 6; alert( x ); // 6 } alert( x ); // 5 }
  • 34. let (cont.) ✦ let expressions: x = 10 + let (a=3) a*a; // x == 19 ✦ let blocks: let ( a=3 ) { alert( a ); // 3 } typeof a == “undefined”
  • 35. Packages ✦ package simple.tracker { internal var count: int = 0; public function add(){ return ++count; } } ✦ import simple.tracker.* alert( add() ); // alert(“1”) count // ERROR, undefined
  • 36. Namespaces ✦ namespace extra = “extra”; ✦ Pre-defined namespaces: ✦ __ES4__ ✦ intrinsic ✦ iterator ✦ meta ✦ import dojo.query; import jquery.query; dojo::query(“#foo”) jquery::query(“div > .foo”)
  • 37. Namespaces (cont.) ✦ import dojo.query; import jquery.query; use namespace dojo; query(“#foo”) // using dojo use namespace jquery; query(“div > .foo”) // using jquery
  • 38. Multimethods ✦ generic function intersect(s1, s2); generic function intersect(s1: Shape, s2: Shape ) { // ... } generic function intersect(s1: Rect, s2: Rect ) { // ... }
  • 39. Program Units ✦ use unit jQuery “http://jquery.com/jQuery” ✦ unit jQuery { use unit Selectors “lib/Selectors”; package com.jquery { class jQuery { function find() : jQuery {} } } }
  • 40. Iteration ✦ class Fib { private var a=0, b=1; iterator function get(deep:boolean = false) : IteratorType.<int> this public function next(): int { if ( b > 100 ) throw iterator::StopIteration; [a,b] = [b,a+b]; return a; } } ✦ for ( let i in new Fib ) alert( i );
  • 41. For .. Each ✦ For each loops through values ✦ let s = “”; for each ( let n in [“a”,”b”,”c”] ) s += n; alert(s); // “abc”
  • 42. 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
  • 44. 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 { } // ... }
  • 45. More Info ✦ ECMAScript 4 White Paper Overview: http://www.ecmascript.org/es4/spec/overview.pdf ✦ Blogging: http://ejohn.org/