SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
JavaScript: the High
Road & the Low Road
Brendan Eich
@BrendanEich <brendan@mozilla.org>
Wednesday, March 12, 14
Prologue
Wednesday, March 12, 14
If Web Dev is like...
• ... sewing with mittens
• ... juggling kittens
• ... fighting evil with one hand cut off
Wednesday, March 12, 14
Wednesday, March 12, 14
Wednesday, March 12, 14
Wednesday, March 12, 14
https://twitter.com/_Lady_Jedi_/status/404082867048681472
Wednesday, March 12, 14
Then JavaScript is like...
• ... having a chainsaw for a hand
Wednesday, March 12, 14
Wednesday, March 12, 14
(Me after hacking JS in 10 days)
Wednesday, March 12, 14
Flash back to 1995
• (What’s with that hair?)
Wednesday, March 12, 14
Wednesday, March 12, 14
Wednesday, March 12, 14
Wednesday, March 12, 14
Groovy
Wednesday, March 12, 14
The High Road
Wednesday, March 12, 14
Harmony - ES6
• var	
  obj	
  =	
  {[“key_”	
  +	
  nextId()]:	
  value};
• var	
  obj	
  =	
  {method()	
  {	
  return	
  42;	
  }};
• var	
  square	
  =	
  x	
  =>	
  x	
  *	
  x;
• class	
  Point	
  {
	
  	
  constructor(x,	
  y)	
  {
	
  	
  	
  	
  this.x	
  =	
  x,	
  this.y	
  =	
  y;
	
  	
  }
	
  	
  add(p)	
  {
	
  	
  	
  	
  this.x	
  +=	
  p.x,	
  this.y	
  +=	
  p.y;
	
  	
  }
}
• class	
  MyNodeList	
  extends	
  NodeList	
  {...}
• let	
  x	
  =	
  “outer”;	
  {let	
  x	
  =	
  “inner”;	
  ...}
• const	
  TAU	
  =	
  2	
  *	
  Math.PI;
• function	
  f(a	
  =	
  1,	
  b	
  =	
  2	
  *	
  a)	
  {...}
• let	
  rotateArray	
  =	
  (h,	
  ...t)	
  =>	
  t.push(h);
• let	
  a	
  =	
  [1,	
  2,	
  3];	
  rotateArray(0,	
  ...a);
• let	
  b	
  =	
  [0,	
  ...a,	
  4,	
  5,	
  6];
• export	
  function	
  transcode(src,	
  url)	
  {...}
• import	
  {keys,	
  items}	
  from	
  “itertools”;
• for	
  (let	
  [k,v]	
  of	
  items(o))	
  print(k,v);
• let	
  eager	
  =	
  [for	
  (v	
  of	
  values(o))	
  2	
  *	
  v];
• let	
  lazy	
  	
  =	
  (for	
  (v	
  of	
  values(o))	
  2	
  *	
  v);
• function	
  iter()	
  {	
  return	
  {next()	
  {...};	
  }
• function*	
  gen()	
  {	
  yield	
  1;	
  yield	
  2;	
  }
Wednesday, March 12, 14
Harmony - ES6, cont
• console.log(`interpolate	
  ${x}`);
• let	
  lexer	
  =	
  /w+|d+/y;	
  //	
  y	
  for	
  stickY
• map	
  =	
  Map([[‘key’,	
  42],	
  [obj,	
  “foo”]]);
map.get(‘key’)	
  //	
  42
map.get(obj)	
  	
  	
  //	
  “foo”
map.set(obj,	
  “bar”)
map.get(obj)	
  //	
  “bar”
map.size	
  	
  	
  	
  	
  //	
  2
for	
  (let	
  [k,	
  v]	
  of	
  map)	
  print(k,	
  v)
map.delete(‘key’);	
  map.size	
  //	
  1
• set	
  =	
  Set([0,	
  1,	
  2,	
  3]);
set.has(0)	
  //	
  true
set.add(9)
set.size	
  //	
  5
for	
  (let	
  elt	
  of	
  set)	
  print(elt)
set.delete(9);	
  set.size	
  //	
  4
• let	
  objectCache	
  =	
  WeakMap();	
  //	
  advanced
• var	
  proxy	
  =	
  new	
  Proxy(target,	
  handler);
• const	
  Point	
  =
	
  	
  new	
  StructType({x:	
  uint32,	
  y:	
  uint32});
• const	
  Triangle	
  =	
  new	
  ArrayType(Point,	
  3);
• {	
  function	
  in_block()	
  {	
  return	
  42;	
  }	
  ...	
  }
• let	
  {x,	
  y}	
  =	
  aPoint;
• let	
  [v1,	
  v2,	
  v3]	
  =	
  aTriangle;
• Object.assign(target,	
  source);
• Object.mixin(target,	
  source);
• Promises,	
  Symbols,	
  and	
  more...
Wednesday, March 12, 14
The module tag
• <script>
System.import(“myapp”).then(app	
  =>	
  {
	
  	
  //	
  ...
});
</script>
• <module>
import	
  app	
  from	
  “myapp”;
//	
  ...
</module>
async, strict, isolated top-level body scope FTW
https://github.com/dherman/web-modules/blob/master/module-tag/explainer.md
Wednesday, March 12, 14
Harmony - ES6 Compat
Wednesday, March 12, 14
ES6 Resources
• https://github.com/google/traceur-compiler
• http://people.mozilla.org/~jorendorff/es6-draft.html
• http://wiki.ecmascript.org/doku.php?
id=harmony:specification_drafts
• http://kangax.github.io/es5-compat-table/es6/
Wednesday, March 12, 14
Harmony - ES7
• Object.observe(target,	
  observer)	
  	
  	
  	
  	
  	
  	
  	
  	
  (High	
  Road)
http://wiki.ecmascript.org/doku.php?id=harmony:observe
• SIMD	
  intrinsics,	
  e.g.	
  SIMD.add(a,	
  b)	
  	
  	
  	
  	
  (Low	
  Road)
https://github.com/johnmccutchan/ecmascript_simd
• Value	
  objects	
  -­‐	
  int64,	
  decimal,	
  etc.	
  	
  	
  	
  	
  (Low	
  Road)
Wednesday, March 12, 14
The Low Road
Wednesday, March 12, 14
Value Objects
• int64, uint64
• int32x4, int32x8 (SIMD)
• float32 (to/from Float32Array today)
• float32x4, float32x8 (SIMD)
• bignum
• decimal
• rational
• complex
Wednesday, March 12, 14
Overloadable Operators
• | ^ &
• ==
• < <=
• << >> >>>
• + -
• * / %
• ~ boolean-test!! unary- unary+
Wednesday, March 12, 14
Literal Syntax
• int64(0) ==> 0L // as in C#
• uint64(0) ==> 0UL // as in C#
• float32(0) ==> 0f // as in C#
• bignum(0) ==> 0n // avoid i/I
• decimal(0) ==> 0m // or M, C/F#
• Can we generalize? 0u for unit u translates via
lookup table at compile time to units.u(0)
• Predefine units.L = int64, etc.
Wednesday, March 12, 14
Possible Operators API
function addPointAndNumber(a, b) {
return Point(a.x + b, a.y + b);
}
Function.defineOperator('+', addPointAndNumber, Point, Number);
function addNumberAndPoint(a, b) {
return Point(a + b.x, a + b.y);
}
Function.defineOperator('+', addNumberAndPoint, Number, Point);
function addPoints(a, b) {
return Point(a.x + b.x, a.y + b.y);
}
Function.defineOperator('+', addPoints, Point, Point);
Wednesday, March 12, 14
SIMD
Single Instruction, Multiple Data (SSE/AVX, NEON, etc.)
Wednesday, March 12, 14
SIMD intrinsics
• Game, DSP, other low-road hackers need them
• John McCutchan added them to DartVM
• Dart-to-the-heart? No, Dart2JS needs ‘em in JS
• A Google, Intel, Mozilla, Ecma TC39 joint
Wednesday, March 12, 14
Possible ES7 Polyfillable SIMD API
https://github.com/johnmccutchan/ecmascript_simd
var a = float32x4(1.0, 2.0, 3.0, 4.0);
var b = float32x4(5.0, 6.0, 7.0, 8.0);
var c = SIMD.float32x4.add(a, b);
// Also SIMD {sub,mul,div,neg,abs} etc.
// See ES7 Value Objects for some sweet
// operator overloading sugar.
Wednesday, March 12, 14
Why Operator Syntax Matters
A comment from Cameron Purdy’s blog:
“At a client gig, they were doing business/financial coding, so were using
BigDecimal.
Of course, .add() and friends is too difficult, so they ended up with
roughly:
BigDecimal subA = ...
BigDecimal subB = ...
BigDecimal total = new BigDecimal(
subA.doubleValue() + subB.doubleValue() );
It was beautiful.”
Posted by Bob McWhirter on October 31, 2005 at 08:17 AM EST
Wednesday, March 12, 14
Why decimal? AKA Who can spot the bug?
Wednesday, March 12, 14
Where the Low Road goes
Wednesday, March 12, 14
Nearly Native Performance
Wednesday, March 12, 14
Demos
Wednesday, March 12, 14
Epilogue:
The Two Roads Converge
Wednesday, March 12, 14
Extensible Web Manifesto
• http://extensiblewebmanifesto.org/
• Focus on safe, low-road capabilities for the Web platform
• Expose capabilities that explain Web features, e.g., HTML
• Complete the high-road language work in ES6 and ES7
• Develop and test new high-road libraries on GitHub
• Prioritize efforts that follow these recommendations
Wednesday, March 12, 14
Always Bet On...WTF Evolution?
Wednesday, March 12, 14
Wednesday, March 12, 14
Conclusion
• First they said that JS + the Web stack
couldn’t do “Rich Internet Applications”
• Then they said it couldn’t be fast
enough
• Then they said it couldn’t be fixed
• Wrong every time!
• Always bet on {JS, HTML,WebGL, ...}
• Really, always bet on Web Developers
Wednesday, March 12, 14

Más contenido relacionado

La actualidad más candente

Introducing: A Complete Algebra of Data
Introducing: A Complete Algebra of DataIntroducing: A Complete Algebra of Data
Introducing: A Complete Algebra of DataInside Analysis
 
Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into ScalaNehal Shah
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and DestructorsKeyur Vadodariya
 
Optionals by Matt Faluotico
Optionals by Matt FaluoticoOptionals by Matt Faluotico
Optionals by Matt FaluoticoWithTheBest
 
Introduction to join calculus
Introduction to join calculusIntroduction to join calculus
Introduction to join calculusSergei Winitzki
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskellfaradjpour
 
Dynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner TypingDynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner TypingYusuke Miyazaki
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scalaPiotr Paradziński
 
Mining Functional Patterns
Mining Functional PatternsMining Functional Patterns
Mining Functional PatternsDebasish Ghosh
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1Troy Miles
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaznkpart
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cppgourav kottawar
 
constructor with default arguments and dynamic initialization of objects
constructor with default arguments and dynamic initialization of objectsconstructor with default arguments and dynamic initialization of objects
constructor with default arguments and dynamic initialization of objectsKanhaiya Saxena
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsDebasish Ghosh
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 

La actualidad más candente (20)

Introducing: A Complete Algebra of Data
Introducing: A Complete Algebra of DataIntroducing: A Complete Algebra of Data
Introducing: A Complete Algebra of Data
 
Railroading into Scala
Railroading into ScalaRailroading into Scala
Railroading into Scala
 
Towards hasktorch 1.0
Towards hasktorch 1.0Towards hasktorch 1.0
Towards hasktorch 1.0
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Optionals by Matt Faluotico
Optionals by Matt FaluoticoOptionals by Matt Faluotico
Optionals by Matt Faluotico
 
Introduction to join calculus
Introduction to join calculusIntroduction to join calculus
Introduction to join calculus
 
Sigma type
Sigma typeSigma type
Sigma type
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskell
 
A taste of Functional Programming
A taste of Functional ProgrammingA taste of Functional Programming
A taste of Functional Programming
 
Dynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner TypingDynamic Type Inference for Gradual Hindley–Milner Typing
Dynamic Type Inference for Gradual Hindley–Milner Typing
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scala
 
Mining Functional Patterns
Mining Functional PatternsMining Functional Patterns
Mining Functional Patterns
 
Elm talk bayhac2015
Elm talk bayhac2015Elm talk bayhac2015
Elm talk bayhac2015
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaz
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
 
constructor with default arguments and dynamic initialization of objects
constructor with default arguments and dynamic initialization of objectsconstructor with default arguments and dynamic initialization of objects
constructor with default arguments and dynamic initialization of objects
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain Models
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 

Destacado (13)

JSLOL
JSLOLJSLOL
JSLOL
 
Paren free
Paren freeParen free
Paren free
 
Taysom seminar
Taysom seminarTaysom seminar
Taysom seminar
 
Fluent15
Fluent15Fluent15
Fluent15
 
Capitol js
Capitol jsCapitol js
Capitol js
 
My dotJS Talk
My dotJS TalkMy dotJS Talk
My dotJS Talk
 
Mozilla's NodeConf talk
Mozilla's NodeConf talkMozilla's NodeConf talk
Mozilla's NodeConf talk
 
dotJS 2015
dotJS 2015dotJS 2015
dotJS 2015
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party Talk
 
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
 
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
 

Similar a Fluent14

C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)Michael Redlich
 
Using CartoDB to analyze OpenStreetMap data
Using CartoDB to analyze OpenStreetMap dataUsing CartoDB to analyze OpenStreetMap data
Using CartoDB to analyze OpenStreetMap dataandrewxhill
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScriptYnon Perek
 
Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Michael Redlich
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Intro to Crowdsourcing and CrowdFunding (in Russian)
Intro to Crowdsourcing and CrowdFunding (in Russian)Intro to Crowdsourcing and CrowdFunding (in Russian)
Intro to Crowdsourcing and CrowdFunding (in Russian)Weavora
 
Mapnik Sotm 2007
Mapnik Sotm 2007Mapnik Sotm 2007
Mapnik Sotm 2007artemp
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?jonbodner
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Jordi Valverde
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageWayne Tsai
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6Solution4Future
 
What we can learn from WordPress as a developer
What we can learn from WordPress as a developerWhat we can learn from WordPress as a developer
What we can learn from WordPress as a developerChandra Maharzan
 
JSDC 2014 - functional java script, why or why not
JSDC 2014 - functional java script, why or why notJSDC 2014 - functional java script, why or why not
JSDC 2014 - functional java script, why or why notChengHui Weng
 
Miscelaneous Debris
Miscelaneous DebrisMiscelaneous Debris
Miscelaneous Debrisfrewmbot
 
2013 jsdc webworker
2013 jsdc webworker2013 jsdc webworker
2013 jsdc webworkerBingo Yang
 
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...Anton
 

Similar a Fluent14 (20)

C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)
 
Using CartoDB to analyze OpenStreetMap data
Using CartoDB to analyze OpenStreetMap dataUsing CartoDB to analyze OpenStreetMap data
Using CartoDB to analyze OpenStreetMap data
 
Access Control
Access ControlAccess Control
Access Control
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Intro to Crowdsourcing and CrowdFunding (in Russian)
Intro to Crowdsourcing and CrowdFunding (in Russian)Intro to Crowdsourcing and CrowdFunding (in Russian)
Intro to Crowdsourcing and CrowdFunding (in Russian)
 
Mapnik Sotm 2007
Mapnik Sotm 2007Mapnik Sotm 2007
Mapnik Sotm 2007
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011Lighting talk neo4j fosdem 2011
Lighting talk neo4j fosdem 2011
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
 
What we can learn from WordPress as a developer
What we can learn from WordPress as a developerWhat we can learn from WordPress as a developer
What we can learn from WordPress as a developer
 
Text adventure
Text adventureText adventure
Text adventure
 
JSDC 2014 - functional java script, why or why not
JSDC 2014 - functional java script, why or why notJSDC 2014 - functional java script, why or why not
JSDC 2014 - functional java script, why or why not
 
Miscelaneous Debris
Miscelaneous DebrisMiscelaneous Debris
Miscelaneous Debris
 
2013 jsdc webworker
2013 jsdc webworker2013 jsdc webworker
2013 jsdc webworker
 
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
 
Managing Memory
Managing MemoryManaging Memory
Managing Memory
 

Último

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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 

Último (20)

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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

Fluent14

  • 1. JavaScript: the High Road & the Low Road Brendan Eich @BrendanEich <brendan@mozilla.org> Wednesday, March 12, 14
  • 3. If Web Dev is like... • ... sewing with mittens • ... juggling kittens • ... fighting evil with one hand cut off Wednesday, March 12, 14
  • 8. Then JavaScript is like... • ... having a chainsaw for a hand Wednesday, March 12, 14
  • 10. (Me after hacking JS in 10 days) Wednesday, March 12, 14
  • 11. Flash back to 1995 • (What’s with that hair?) Wednesday, March 12, 14
  • 16. The High Road Wednesday, March 12, 14
  • 17. Harmony - ES6 • var  obj  =  {[“key_”  +  nextId()]:  value}; • var  obj  =  {method()  {  return  42;  }}; • var  square  =  x  =>  x  *  x; • class  Point  {    constructor(x,  y)  {        this.x  =  x,  this.y  =  y;    }    add(p)  {        this.x  +=  p.x,  this.y  +=  p.y;    } } • class  MyNodeList  extends  NodeList  {...} • let  x  =  “outer”;  {let  x  =  “inner”;  ...} • const  TAU  =  2  *  Math.PI; • function  f(a  =  1,  b  =  2  *  a)  {...} • let  rotateArray  =  (h,  ...t)  =>  t.push(h); • let  a  =  [1,  2,  3];  rotateArray(0,  ...a); • let  b  =  [0,  ...a,  4,  5,  6]; • export  function  transcode(src,  url)  {...} • import  {keys,  items}  from  “itertools”; • for  (let  [k,v]  of  items(o))  print(k,v); • let  eager  =  [for  (v  of  values(o))  2  *  v]; • let  lazy    =  (for  (v  of  values(o))  2  *  v); • function  iter()  {  return  {next()  {...};  } • function*  gen()  {  yield  1;  yield  2;  } Wednesday, March 12, 14
  • 18. Harmony - ES6, cont • console.log(`interpolate  ${x}`); • let  lexer  =  /w+|d+/y;  //  y  for  stickY • map  =  Map([[‘key’,  42],  [obj,  “foo”]]); map.get(‘key’)  //  42 map.get(obj)      //  “foo” map.set(obj,  “bar”) map.get(obj)  //  “bar” map.size          //  2 for  (let  [k,  v]  of  map)  print(k,  v) map.delete(‘key’);  map.size  //  1 • set  =  Set([0,  1,  2,  3]); set.has(0)  //  true set.add(9) set.size  //  5 for  (let  elt  of  set)  print(elt) set.delete(9);  set.size  //  4 • let  objectCache  =  WeakMap();  //  advanced • var  proxy  =  new  Proxy(target,  handler); • const  Point  =    new  StructType({x:  uint32,  y:  uint32}); • const  Triangle  =  new  ArrayType(Point,  3); • {  function  in_block()  {  return  42;  }  ...  } • let  {x,  y}  =  aPoint; • let  [v1,  v2,  v3]  =  aTriangle; • Object.assign(target,  source); • Object.mixin(target,  source); • Promises,  Symbols,  and  more... Wednesday, March 12, 14
  • 19. The module tag • <script> System.import(“myapp”).then(app  =>  {    //  ... }); </script> • <module> import  app  from  “myapp”; //  ... </module> async, strict, isolated top-level body scope FTW https://github.com/dherman/web-modules/blob/master/module-tag/explainer.md Wednesday, March 12, 14
  • 20. Harmony - ES6 Compat Wednesday, March 12, 14
  • 21. ES6 Resources • https://github.com/google/traceur-compiler • http://people.mozilla.org/~jorendorff/es6-draft.html • http://wiki.ecmascript.org/doku.php? id=harmony:specification_drafts • http://kangax.github.io/es5-compat-table/es6/ Wednesday, March 12, 14
  • 22. Harmony - ES7 • Object.observe(target,  observer)                  (High  Road) http://wiki.ecmascript.org/doku.php?id=harmony:observe • SIMD  intrinsics,  e.g.  SIMD.add(a,  b)          (Low  Road) https://github.com/johnmccutchan/ecmascript_simd • Value  objects  -­‐  int64,  decimal,  etc.          (Low  Road) Wednesday, March 12, 14
  • 23. The Low Road Wednesday, March 12, 14
  • 24. Value Objects • int64, uint64 • int32x4, int32x8 (SIMD) • float32 (to/from Float32Array today) • float32x4, float32x8 (SIMD) • bignum • decimal • rational • complex Wednesday, March 12, 14
  • 25. Overloadable Operators • | ^ & • == • < <= • << >> >>> • + - • * / % • ~ boolean-test!! unary- unary+ Wednesday, March 12, 14
  • 26. Literal Syntax • int64(0) ==> 0L // as in C# • uint64(0) ==> 0UL // as in C# • float32(0) ==> 0f // as in C# • bignum(0) ==> 0n // avoid i/I • decimal(0) ==> 0m // or M, C/F# • Can we generalize? 0u for unit u translates via lookup table at compile time to units.u(0) • Predefine units.L = int64, etc. Wednesday, March 12, 14
  • 27. Possible Operators API function addPointAndNumber(a, b) { return Point(a.x + b, a.y + b); } Function.defineOperator('+', addPointAndNumber, Point, Number); function addNumberAndPoint(a, b) { return Point(a + b.x, a + b.y); } Function.defineOperator('+', addNumberAndPoint, Number, Point); function addPoints(a, b) { return Point(a.x + b.x, a.y + b.y); } Function.defineOperator('+', addPoints, Point, Point); Wednesday, March 12, 14
  • 28. SIMD Single Instruction, Multiple Data (SSE/AVX, NEON, etc.) Wednesday, March 12, 14
  • 29. SIMD intrinsics • Game, DSP, other low-road hackers need them • John McCutchan added them to DartVM • Dart-to-the-heart? No, Dart2JS needs ‘em in JS • A Google, Intel, Mozilla, Ecma TC39 joint Wednesday, March 12, 14
  • 30. Possible ES7 Polyfillable SIMD API https://github.com/johnmccutchan/ecmascript_simd var a = float32x4(1.0, 2.0, 3.0, 4.0); var b = float32x4(5.0, 6.0, 7.0, 8.0); var c = SIMD.float32x4.add(a, b); // Also SIMD {sub,mul,div,neg,abs} etc. // See ES7 Value Objects for some sweet // operator overloading sugar. Wednesday, March 12, 14
  • 31. Why Operator Syntax Matters A comment from Cameron Purdy’s blog: “At a client gig, they were doing business/financial coding, so were using BigDecimal. Of course, .add() and friends is too difficult, so they ended up with roughly: BigDecimal subA = ... BigDecimal subB = ... BigDecimal total = new BigDecimal( subA.doubleValue() + subB.doubleValue() ); It was beautiful.” Posted by Bob McWhirter on October 31, 2005 at 08:17 AM EST Wednesday, March 12, 14
  • 32. Why decimal? AKA Who can spot the bug? Wednesday, March 12, 14
  • 33. Where the Low Road goes Wednesday, March 12, 14
  • 36. Epilogue: The Two Roads Converge Wednesday, March 12, 14
  • 37. Extensible Web Manifesto • http://extensiblewebmanifesto.org/ • Focus on safe, low-road capabilities for the Web platform • Expose capabilities that explain Web features, e.g., HTML • Complete the high-road language work in ES6 and ES7 • Develop and test new high-road libraries on GitHub • Prioritize efforts that follow these recommendations Wednesday, March 12, 14
  • 38. Always Bet On...WTF Evolution? Wednesday, March 12, 14
  • 40. Conclusion • First they said that JS + the Web stack couldn’t do “Rich Internet Applications” • Then they said it couldn’t be fast enough • Then they said it couldn’t be fixed • Wrong every time! • Always bet on {JS, HTML,WebGL, ...} • Really, always bet on Web Developers Wednesday, March 12, 14