SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
SpiderNode, V8Monkey, and You




                                          mozilla

          1


Thursday, May 5, 2011
What?




                        mozilla

          2


Thursday, May 5, 2011
What?




           In which we put a v8 API on top of spidermonkey without futzing with a separate build
           system. Prep work for spidernode. (from an autoupdated unofcial mozilla-central clone)




                                                                                             mozilla

          2


Thursday, May 5, 2011
Why?




                        mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)




                                                                                  mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)


          • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey],
            2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” -
            Heathers) really needs a better API




                                                                                      mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)


          • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey],
            2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” -
            Heathers) really needs a better API


          • V8 has a nice “C++ the good parts” API




                                                                                      mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)


          • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey],
            2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” -
            Heathers) really needs a better API


          • V8 has a nice “C++ the good parts” API


               • Template types, RAII storage class auto helpers, GC all the way down




                                                                                        mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)


          • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey],
            2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” -
            Heathers) really needs a better API


          • V8 has a nice “C++ the good parts” API


               • Template types, RAII storage class auto helpers, GC all the way down


          • JS the language is evolving -- Harmony coming in ES.next


                                                                                        mozilla

          3


Thursday, May 5, 2011
Why?

          • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much)


          • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey],
            2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” -
            Heathers) really needs a better API


          • V8 has a nice “C++ the good parts” API


               • Template types, RAII storage class auto helpers, GC all the way down


          • JS the language is evolving -- Harmony coming in ES.next


          • Node is a great testbed for new JS features
                                                                                        mozilla

          3


Thursday, May 5, 2011
Approved for ES.next




                                 mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope




                                                  mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()




                                                                       mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}




                                                                       mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}

          • rest, spread: function g(i, j, ...r) { return r.slice(i, j); }
                          let a = [0,1,2,3],
                              o = new any_constructor(...a)




                                                                       mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}

          • rest, spread: function g(i, j, ...r) { return r.slice(i, j); }
                          let a = [0,1,2,3],
                              o = new any_constructor(...a)


          • proxies, weak maps: Proxy.create(handler, proto), new WeakMap




                                                                       mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}

          • rest, spread: function g(i, j, ...r) { return r.slice(i, j); }
                          let a = [0,1,2,3],
                              o = new any_constructor(...a)


          • proxies, weak maps: Proxy.create(handler, proto), new WeakMap

          • modules: module M { export function fast_sin(x) {...} }


                                                                       mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}

          • rest, spread: function g(i, j, ...r) { return r.slice(i, j); }
                          let a = [0,1,2,3],
                              o = new any_constructor(...a)


          • proxies, weak maps: Proxy.create(handler, proto), new WeakMap

          • modules: module M { export function fast_sin(x) {...} }

          • iterators, generators: function* gen() { yield 1; yield 2; }
                                                                           mozilla

          4


Thursday, May 5, 2011
Approved for ES.next

          • let, const, function in block scope

          • destructuring: let {x, y} = pt; let [s, v, o] = triple()

          • parameter default values: function f(x, y=1, z=0) {...}

          • rest, spread: function g(i, j, ...r) { return r.slice(i, j); }
                          let a = [0,1,2,3],
                              o = new any_constructor(...a)


          • proxies, weak maps: Proxy.create(handler, proto), new WeakMap

          • modules: module M { export function fast_sin(x) {...} }

          • iterators, generators: function* gen() { yield 1; yield 2; }
                                                                           mozilla
          • comprehensions: return [a+b for (a in A) for (b in B)]

          4


Thursday, May 5, 2011
Yet more approved for ES.next




                                          mozilla

          5


Thursday, May 5, 2011
Yet more approved for ES.next

          • Binary data:




                                          mozilla

          5


Thursday, May 5, 2011
Yet more approved for ES.next

          • Binary data:

               • const Point2D = new StructType({ x: uint32, y: uint32 }),
                       Color = new StructType({ r: uint8, g: uint8,
                                                b: uint8 }),
                       Pixel = new StructType({ point: Point2D,
                                                color: Color });




                                                                      mozilla

          5


Thursday, May 5, 2011
Yet more approved for ES.next

          • Binary data:

               • const Point2D = new StructType({ x: uint32, y: uint32 }),
                       Color = new StructType({ r: uint8, g: uint8,
                                                b: uint8 }),
                       Pixel = new StructType({ point: Point2D,
                                                color: Color });

               • const Triangle = new ArrayType(Pixel, 3);




                                                                      mozilla

          5


Thursday, May 5, 2011
Yet more approved for ES.next

          • Binary data:

               • const Point2D = new StructType({ x: uint32, y: uint32 }),
                       Color = new StructType({ r: uint8, g: uint8,
                                                b: uint8 }),
                       Pixel = new StructType({ point: Point2D,
                                                color: Color });

               • const Triangle = new ArrayType(Pixel, 3);

               • new Triangle([{ point:   {   x:   0, y: 0 },
                                 color:   {   r:   255, g: 255, b: 255 } },
                               { point:   {   x:   5, y: 5 },
                                 color:   {   r:   128, g: 0, b: 0 } },
                               { point:   {   x:   10, y: 0 },
                                 color:   {   r:   0, g: 0, b: 128 } }]);
                                                                              mozilla

          5


Thursday, May 5, 2011
Hot, but not yet in Harmony




                                        mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)




                                                                                      mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)

               • Just like CoffeeScript: let identity = (x) -> x




                                                                                      mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)

               • Just like CoffeeScript: let identity = (x) -> x

               • Expression body: const square = (x) -> (x * x)




                                                                                      mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)

               • Just like CoffeeScript: let identity = (x) -> x

               • Expression body: const square = (x) -> (x * x)

               • Statement body: let countUsed = (str) -> {
                                   if (str in usedWords)
                                     usedWords[str]++;
                                   else
                                     usedWords[str] = 1;
                                 }




                                                                                      mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)

               • Just like CoffeeScript: let identity = (x) -> x

               • Expression body: const square = (x) -> (x * x)

               • Statement body: let countUsed = (str) -> {
                                   if (str in usedWords)
                                     usedWords[str]++;
                                   else
                                     usedWords[str] = 1;
                                 }


          • Fat arrow too: callback = (msg) => ( this.vmail.push(msg) )


                                                                                      mozilla

          6


Thursday, May 5, 2011
Hot, but not yet in Harmony

          • Arrow function syntax, instead of λ, ƒ, or # (want to save # for later)

               • Just like CoffeeScript: let identity = (x) -> x

               • Expression body: const square = (x) -> (x * x)

               • Statement body: let countUsed = (str) -> {
                                   if (str in usedWords)
                                     usedWords[str]++;
                                   else
                                     usedWords[str] = 1;
                                 }


          • Fat arrow too: callback = (msg) => ( this.vmail.push(msg) )

          • Binding forms: let f() -> “writable”
                          const K() -> “readonly”                                     mozilla

          6


Thursday, May 5, 2011
What else?




                        mozilla

          7


Thursday, May 5, 2011
What else?

          • CoffeeScript classes, for prototypal inheritance sugar

               • Or a different classes as closure pattern sugar proposal?

               • Or (and this is somewhat Coffee-like) extended object initialisers?




                                                                                       mozilla

          7


Thursday, May 5, 2011
What else?

          • CoffeeScript classes, for prototypal inheritance sugar

               • Or a different classes as closure pattern sugar proposal?

               • Or (and this is somewhat Coffee-like) extended object initialisers?

          • Coffee’s @foo for this.foo

               • Or some private names or “soft fields” @ usage?




                                                                                       mozilla

          7


Thursday, May 5, 2011
What else?

          • CoffeeScript classes, for prototypal inheritance sugar

               • Or a different classes as closure pattern sugar proposal?

               • Or (and this is somewhat Coffee-like) extended object initialisers?

          • Coffee’s @foo for this.foo

               • Or some private names or “soft fields” @ usage?

          • Paren-free syntax: if x > y return x
                               while i < n { a.push(i++); }



                                                                                       mozilla

          7


Thursday, May 5, 2011
What else?

          • CoffeeScript classes, for prototypal inheritance sugar

               • Or a different classes as closure pattern sugar proposal?

               • Or (and this is somewhat Coffee-like) extended object initialisers?

          • Coffee’s @foo for this.foo

               • Or some private names or “soft fields” @ usage?

          • Paren-free syntax: if x > y return x
                               while i < n { a.push(i++); }


          • More operators: ?? ??= div mod divmod is isnt
                                                                                       mozilla

          7


Thursday, May 5, 2011
Demo: generators for callback-free i/o

          • https://github.com/dherman/taskjs

              var {task} = require('./taskjs/lib/task.js');
              var fs = require('fs');
              function readFile(path) {
                return new NodeReadFile(path);
              }
              function NodeReadFile(path) {
                this.path = path;
                var wait = this;
                fs.readFile(path, function (err, data) {
                  if (err) {
                    wait.throw(err);
                  } else {
                    wait.return(data);
                  }

              }
                });                                           mozilla

          8


Thursday, May 5, 2011
Demo: generators, continued

          • NodeReadFile.prototype = new task.Wait();

              task.spawn(function () {
                try {
                  var data = yield readFile('gen.js');
                  console.log(data.toString('ascii'));
                } catch (e) {
                  console.log(e);
                }
              });

          • You have to write yield a bit (don’t forget it!)


          • But you don’t have to write function(){...} nests

                                                                mozilla

          9


Thursday, May 5, 2011
Even shorter generator anti-nesting demo

          • let {Wait, spawn, choose} = require('./taskjs/lib/task.js').task;
            let newRequest = new Wait();
            require('http').createServer(function (req, res) {
              newRequest.return([req, res]);
            }).listen(10337, "127.0.0.1");
            spawn(function () {
              let i = 0;
              while (true) {
                let [req, res] = yield newRequest;
                if (req.url === '/') {
                  res.writeHead(200, {'Content-Type': 'text/plain'});
                  res.end('Hello World: ' + i + 'n');
                  i++;
                }
              }
            })                                                                  mozilla
            console.log('Server running at http://127.0.0.1:10337/');

          10


Thursday, May 5, 2011
Thanks, contact, more demos, Q&A

          • Thanks to @robarnold @sdwilsh @zpao @john_h_ford and @andreasgal


          • irc.mozilla.org #spidernode


          • spidernode@mozilla.org (mailman subscribe request)


          • More demos


               • NodeChat running at SSID spidernode 169.254.64.209


          • Questions?


                                                                               mozilla

          11


Thursday, May 5, 2011

Weitere ähnliche Inhalte

Andere mochten auch

JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS ResponsibilitiesBrendan Eich
 
My dotJS Talk
My dotJS TalkMy dotJS Talk
My dotJS TalkBrendan Eich
 
Taysom seminar
Taysom seminarTaysom seminar
Taysom seminarBrendan Eich
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party TalkBrendan Eich
 
Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Brendan Eich
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptBrendan Eich
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressBrendan Eich
 
The Same-Origin Saga
The Same-Origin SagaThe Same-Origin Saga
The Same-Origin SagaBrendan Eich
 

Andere mochten auch (16)

Capitol js
Capitol jsCapitol js
Capitol js
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
 
Fluent15
Fluent15Fluent15
Fluent15
 
My dotJS Talk
My dotJS TalkMy dotJS Talk
My dotJS Talk
 
Taysom seminar
Taysom seminarTaysom seminar
Taysom seminar
 
JSLOL
JSLOLJSLOL
JSLOL
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party Talk
 
dotJS 2015
dotJS 2015dotJS 2015
dotJS 2015
 
Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
 
Splash
SplashSplash
Splash
 
Txjs talk
Txjs talkTxjs talk
Txjs talk
 
The Same-Origin Saga
The Same-Origin SagaThe Same-Origin Saga
The Same-Origin Saga
 
Int64
Int64Int64
Int64
 

Ähnlich wie Mozilla's NodeConf talk

Javascript Performance
Javascript PerformanceJavascript Performance
Javascript Performanceolivvv
 
Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Payara
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"Stephen Donner
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)Eduard TomĂ s
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016Codemotion
 
The State of JavaScript
The State of JavaScriptThe State of JavaScript
The State of JavaScriptDomenic Denicola
 
Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010Guillaume Laforge
 
Mozilla: Mozmill meets L10n
Mozilla: Mozmill meets L10nMozilla: Mozmill meets L10n
Mozilla: Mozmill meets L10nHenrik Skupin
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to pythonActiveState
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010John Woodell
 
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser WorkshopTaro Matsuzawa
 
How I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHow I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHajime Morrita
 
Introduction to XPConnect
Introduction to XPConnectIntroduction to XPConnect
Introduction to XPConnectAnant Narayanan
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & HowGraham Tackley
 
Odnoklassniki.ru Architecture
Odnoklassniki.ru ArchitectureOdnoklassniki.ru Architecture
Odnoklassniki.ru ArchitectureDmitry Buzdin
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Peter Kofler
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jeresig
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-goikailan
 

Ähnlich wie Mozilla's NodeConf talk (20)

ES.next
ES.nextES.next
ES.next
 
Sync considered unethical
Sync considered unethicalSync considered unethical
Sync considered unethical
 
Javascript Performance
Javascript PerformanceJavascript Performance
Javascript Performance
 
Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8Cloud-ready Micro Java EE 8
Cloud-ready Micro Java EE 8
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
The State of JavaScript
The State of JavaScriptThe State of JavaScript
The State of JavaScript
 
Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010Groovy 1 7 Update, past, present, future - S2G Forum 2010
Groovy 1 7 Update, past, present, future - S2G Forum 2010
 
Mozilla: Mozmill meets L10n
Mozilla: Mozmill meets L10nMozilla: Mozmill meets L10n
Mozilla: Mozmill meets L10n
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop
(元)コミュニティメンバーから見たMozilla / Firefoxの歴史と展望@Browser Workshop
 
How I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHow I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTree
 
Introduction to XPConnect
Introduction to XPConnectIntroduction to XPConnect
Introduction to XPConnect
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 
Odnoklassniki.ru Architecture
Odnoklassniki.ru ArchitectureOdnoklassniki.ru Architecture
Odnoklassniki.ru Architecture
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-go
 

KĂźrzlich hochgeladen

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

KĂźrzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Mozilla's NodeConf talk

  • 1. SpiderNode, V8Monkey, and You mozilla 1 Thursday, May 5, 2011
  • 2. What? mozilla 2 Thursday, May 5, 2011
  • 3. What? In which we put a v8 API on top of spidermonkey without futzing with a separate build system. Prep work for spidernode. (from an autoupdated unofcial mozilla-central clone) mozilla 2 Thursday, May 5, 2011
  • 4. Why? mozilla 3 Thursday, May 5, 2011
  • 5. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) mozilla 3 Thursday, May 5, 2011
  • 6. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey], 2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” - Heathers) really needs a better API mozilla 3 Thursday, May 5, 2011
  • 7. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey], 2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” - Heathers) really needs a better API • V8 has a nice “C++ the good parts” API mozilla 3 Thursday, May 5, 2011
  • 8. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey], 2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” - Heathers) really needs a better API • V8 has a nice “C++ the good parts” API • Template types, RAII storage class auto helpers, GC all the way down mozilla 3 Thursday, May 5, 2011
  • 9. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey], 2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” - Heathers) really needs a better API • V8 has a nice “C++ the good parts” API • Template types, RAII storage class auto helpers, GC all the way down • JS the language is evolving -- Harmony coming in ES.next mozilla 3 Thursday, May 5, 2011
  • 10. Why? • We at Mozilla <3 V8 (we <3 WebKit/JavaScriptCore too; Chakra not so much) • SpiderMonkey (born 1996, reborn 2008 [TraceMonkey], 2010 [JaegerMonkey], 2011 [TypeInferenceMonkey], 2012 [IonMonkey] -- “My afterlife is *so* boring!” - Heathers) really needs a better API • V8 has a nice “C++ the good parts” API • Template types, RAII storage class auto helpers, GC all the way down • JS the language is evolving -- Harmony coming in ES.next • Node is a great testbed for new JS features mozilla 3 Thursday, May 5, 2011
  • 11. Approved for ES.next mozilla 4 Thursday, May 5, 2011
  • 12. Approved for ES.next • let, const, function in block scope mozilla 4 Thursday, May 5, 2011
  • 13. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() mozilla 4 Thursday, May 5, 2011
  • 14. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} mozilla 4 Thursday, May 5, 2011
  • 15. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} • rest, spread: function g(i, j, ...r) { return r.slice(i, j); } let a = [0,1,2,3], o = new any_constructor(...a) mozilla 4 Thursday, May 5, 2011
  • 16. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} • rest, spread: function g(i, j, ...r) { return r.slice(i, j); } let a = [0,1,2,3], o = new any_constructor(...a) • proxies, weak maps: Proxy.create(handler, proto), new WeakMap mozilla 4 Thursday, May 5, 2011
  • 17. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} • rest, spread: function g(i, j, ...r) { return r.slice(i, j); } let a = [0,1,2,3], o = new any_constructor(...a) • proxies, weak maps: Proxy.create(handler, proto), new WeakMap • modules: module M { export function fast_sin(x) {...} } mozilla 4 Thursday, May 5, 2011
  • 18. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} • rest, spread: function g(i, j, ...r) { return r.slice(i, j); } let a = [0,1,2,3], o = new any_constructor(...a) • proxies, weak maps: Proxy.create(handler, proto), new WeakMap • modules: module M { export function fast_sin(x) {...} } • iterators, generators: function* gen() { yield 1; yield 2; } mozilla 4 Thursday, May 5, 2011
  • 19. Approved for ES.next • let, const, function in block scope • destructuring: let {x, y} = pt; let [s, v, o] = triple() • parameter default values: function f(x, y=1, z=0) {...} • rest, spread: function g(i, j, ...r) { return r.slice(i, j); } let a = [0,1,2,3], o = new any_constructor(...a) • proxies, weak maps: Proxy.create(handler, proto), new WeakMap • modules: module M { export function fast_sin(x) {...} } • iterators, generators: function* gen() { yield 1; yield 2; } mozilla • comprehensions: return [a+b for (a in A) for (b in B)] 4 Thursday, May 5, 2011
  • 20. Yet more approved for ES.next mozilla 5 Thursday, May 5, 2011
  • 21. Yet more approved for ES.next • Binary data: mozilla 5 Thursday, May 5, 2011
  • 22. Yet more approved for ES.next • Binary data: • const Point2D = new StructType({ x: uint32, y: uint32 }), Color = new StructType({ r: uint8, g: uint8, b: uint8 }), Pixel = new StructType({ point: Point2D, color: Color }); mozilla 5 Thursday, May 5, 2011
  • 23. Yet more approved for ES.next • Binary data: • const Point2D = new StructType({ x: uint32, y: uint32 }), Color = new StructType({ r: uint8, g: uint8, b: uint8 }), Pixel = new StructType({ point: Point2D, color: Color }); • const Triangle = new ArrayType(Pixel, 3); mozilla 5 Thursday, May 5, 2011
  • 24. Yet more approved for ES.next • Binary data: • const Point2D = new StructType({ x: uint32, y: uint32 }), Color = new StructType({ r: uint8, g: uint8, b: uint8 }), Pixel = new StructType({ point: Point2D, color: Color }); • const Triangle = new ArrayType(Pixel, 3); • new Triangle([{ point: { x: 0, y: 0 }, color: { r: 255, g: 255, b: 255 } }, { point: { x: 5, y: 5 }, color: { r: 128, g: 0, b: 0 } }, { point: { x: 10, y: 0 }, color: { r: 0, g: 0, b: 128 } }]); mozilla 5 Thursday, May 5, 2011
  • 25. Hot, but not yet in Harmony mozilla 6 Thursday, May 5, 2011
  • 26. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) mozilla 6 Thursday, May 5, 2011
  • 27. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) • Just like CoffeeScript: let identity = (x) -> x mozilla 6 Thursday, May 5, 2011
  • 28. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) • Just like CoffeeScript: let identity = (x) -> x • Expression body: const square = (x) -> (x * x) mozilla 6 Thursday, May 5, 2011
  • 29. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) • Just like CoffeeScript: let identity = (x) -> x • Expression body: const square = (x) -> (x * x) • Statement body: let countUsed = (str) -> { if (str in usedWords) usedWords[str]++; else usedWords[str] = 1; } mozilla 6 Thursday, May 5, 2011
  • 30. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) • Just like CoffeeScript: let identity = (x) -> x • Expression body: const square = (x) -> (x * x) • Statement body: let countUsed = (str) -> { if (str in usedWords) usedWords[str]++; else usedWords[str] = 1; } • Fat arrow too: callback = (msg) => ( this.vmail.push(msg) ) mozilla 6 Thursday, May 5, 2011
  • 31. Hot, but not yet in Harmony • Arrow function syntax, instead of Îť, ƒ, or # (want to save # for later) • Just like CoffeeScript: let identity = (x) -> x • Expression body: const square = (x) -> (x * x) • Statement body: let countUsed = (str) -> { if (str in usedWords) usedWords[str]++; else usedWords[str] = 1; } • Fat arrow too: callback = (msg) => ( this.vmail.push(msg) ) • Binding forms: let f() -> “writable” const K() -> “readonly” mozilla 6 Thursday, May 5, 2011
  • 32. What else? mozilla 7 Thursday, May 5, 2011
  • 33. What else? • CoffeeScript classes, for prototypal inheritance sugar • Or a different classes as closure pattern sugar proposal? • Or (and this is somewhat Coffee-like) extended object initialisers? mozilla 7 Thursday, May 5, 2011
  • 34. What else? • CoffeeScript classes, for prototypal inheritance sugar • Or a different classes as closure pattern sugar proposal? • Or (and this is somewhat Coffee-like) extended object initialisers? • Coffee’s @foo for this.foo • Or some private names or “soft elds” @ usage? mozilla 7 Thursday, May 5, 2011
  • 35. What else? • CoffeeScript classes, for prototypal inheritance sugar • Or a different classes as closure pattern sugar proposal? • Or (and this is somewhat Coffee-like) extended object initialisers? • Coffee’s @foo for this.foo • Or some private names or “soft elds” @ usage? • Paren-free syntax: if x > y return x while i < n { a.push(i++); } mozilla 7 Thursday, May 5, 2011
  • 36. What else? • CoffeeScript classes, for prototypal inheritance sugar • Or a different classes as closure pattern sugar proposal? • Or (and this is somewhat Coffee-like) extended object initialisers? • Coffee’s @foo for this.foo • Or some private names or “soft elds” @ usage? • Paren-free syntax: if x > y return x while i < n { a.push(i++); } • More operators: ?? ??= div mod divmod is isnt mozilla 7 Thursday, May 5, 2011
  • 37. Demo: generators for callback-free i/o • https://github.com/dherman/taskjs var {task} = require('./taskjs/lib/task.js'); var fs = require('fs'); function readFile(path) { return new NodeReadFile(path); } function NodeReadFile(path) { this.path = path; var wait = this; fs.readFile(path, function (err, data) { if (err) { wait.throw(err); } else { wait.return(data); } } }); mozilla 8 Thursday, May 5, 2011
  • 38. Demo: generators, continued • NodeReadFile.prototype = new task.Wait(); task.spawn(function () { try { var data = yield readFile('gen.js'); console.log(data.toString('ascii')); } catch (e) { console.log(e); } }); • You have to write yield a bit (don’t forget it!) • But you don’t have to write function(){...} nests mozilla 9 Thursday, May 5, 2011
  • 39. Even shorter generator anti-nesting demo • let {Wait, spawn, choose} = require('./taskjs/lib/task.js').task; let newRequest = new Wait(); require('http').createServer(function (req, res) { newRequest.return([req, res]); }).listen(10337, "127.0.0.1"); spawn(function () { let i = 0; while (true) { let [req, res] = yield newRequest; if (req.url === '/') { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World: ' + i + 'n'); i++; } } }) mozilla console.log('Server running at http://127.0.0.1:10337/'); 10 Thursday, May 5, 2011
  • 40. Thanks, contact, more demos, Q&A • Thanks to @robarnold @sdwilsh @zpao @john_h_ford and @andreasgal • irc.mozilla.org #spidernode • spidernode@mozilla.org (mailman subscribe request) • More demos • NodeChat running at SSID spidernode 169.254.64.209 • Questions? mozilla 11 Thursday, May 5, 2011