SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Kürzlich hochgeladen (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

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