Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/ILvHbv.
Brendan Eich surveys interesting developments in the Web platform, analysing emergent trends, and making some predictions. Filmed at qconsf.com.
Brendan Eich is CTO and SVP of Engineering for Mozilla, and widely recognized for his enduring contributions to the Internet revolution. In 1995, Eich invented JavaScript (ECMAScript), the Internet’s most widely used programming language. He co-founded the mozilla.org project in 1998, serving as chief architect, and has been a board member of the Mozilla Foundation since its inception in 2003.
2. Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/web-evolution-trends
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
3. Presented at QCon San Francisco
www.qconsf.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
5. Extensible Web Manifesto
•
•
•
•
•
http://extensiblewebmanifesto.org/
Focus on new, safe, low-level capabilities for the web platform
Expose capabilities that explain existing features, e.g., HTML
Develop and test new high-level standard libraries on github
Prioritize efforts that follow these recommendations over
other work
3
6. JavaScript
•
•
•
AKA ECMAScript, ECMA-262, ES
ES Harmony = editions from 5 on
Harmony goals
•
•
•
better for applications
better for libraries
better for code generators
4
18. Preserving Boolean Algebra
• != and ! are not overloadable, to preserve identities including
• X ? A : B <=> !X ? B : A
• !(X && Y) <=> !X || !Y
• !(X || Y) <=> !X && !Y
<=> !(X == Y)
• X != Y
16
19. Preserving Relational Relations
• > and >= are derived from < and <= as follows:
• A > B <=> B < A
• A >= B <=> B <= A
• We provide <= in addition to < rather than derive A
<= B
from !(B < A) in order to allow the <= overloading to match
the same value object’s == semantics -- and for special cases,
e.g., unordered values (NaNs)
17
20. Strict Equality Operators
• The strict equality operators, === and !==, cannot be overloaded
• They work on frozen-by-definition value objects via a structural
recursive strict equality test (beware, NaN !== NaN)
• Same-object-reference remains a fast-path optimization
18
21. Why Not Double Dispatch?
• Left-first asymmetry (v value, n number):
•v
•n
+ n
==>
v.add(n)
+ v
==>
v.radd(n)
• Anti-modular: exhaustive other-operand type enumeration
required in operator method bodies
• Consequent loss of compositionality: complex and rational
cannot be composed to make ratplex without modifying
source or wrapping in proxies
19
22. Cacheable Multimethods
• Proposed in 2009 by Christian Plesner Hansen (Google) in esdiscuss
• Avoids double-dispatch drawbacks from last slide: binary operators
implemented by 2-ary functions for each pair of types
• Supports Polymorphic Inline Cache (PIC) optimizations (Christian
was on the V8 team)
• Background reading: [Chambers 1992]
20
23. Binary Operator Example
• For the expression v + u
• Let p = v.[[Get]](@@ADD)
• If p is not a Set, throw a TypeError
• Let q = u.[[Get]](@@ADD_R)
• If q is not a Set, throw a TypeError
• Let r = p intersect q
• If r.size != 1 throw a TypeError
• Let f = r[0]; if f is not a function, throw
• Evaluate f(v, u) and return the result
21
24. API Idea from CPH 2009
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);
22
25. Literal Syntax
• int64(0)
• uint64(0)
• float32(0)
• bignum(0)
• decimal(0)
==>
0L // as in C#
==> 0UL // as in C#
==>
0f // as in C#
==>
0n // avoid i/I
==>
0m // or M, C/F#
• We want a syntax extension mechanism, but declarative not
runtime API
• This means new syntax for operator and suffix definition
23
26. Straw Value Object Declaration Syntax
value class point2d { // implies typeof “point2d”
constructor point2d(x, y) {
this.x = +x;
this.y = +y;
// implicit Object.freeze(this) on return
}
point2d + number (a, b) {
return point2d(a.x + b, a.y + b);
}
number + point2d (a, b) {
return point2d(a + b.x, a + b.y);
}
point2d + point2d (a, b) {
return point2d(a.x + b.x, a.y + b.y);
}
// more operators, suffix declaration handler, etc.
}
24
28. SIMD intrinsics
•
•
•
•
Game, DSP, other low-level 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
26
29. 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.add(a, b);
// Also SIMD.{sub,mul,div,neg,abs} etc.
// See ES7 Value Objects for some sweet
// operator overloading sugar.
27
30. Why Operator Syntax Matters
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
28
36. WebRTC Sample JS
•
•
•
var
pc
=
new
RTCPeerConnection();
var
localVideo
=
document.getElementById(“local”);
navigator.getUserMedia(
{video:
true,
audio:
true},
function
(stream)
{
pc.addStream(stream);
//
See
https://github.com/HenrikJoreteg/attachMediaStream
attachMediaStream(localVideo,
stream);
},
function
()
{
console.log(“failed
to
get
video
camera”)
}
);
34
39. Networking
•
•
•
•
•
•
Layering hurts (Sam Ruby, OSCON 2005? I forget)
DNS lookup, HTML load, img and script step on each other
and power up the radio just as it is powering down
10kbs on LTE, not great
Here, underused on server side: SPDY; coming: HTTP2
We can fix things incrementally with better coordination
37
40. Privacy, Trust, User Agency
•
•
•
Mozilla won “Most Trusted for Privacy” award in 2012
Working to earn it:
•
•
•
•
Sync encrypts client-side, but key mgmt beyond most users
Verified builds on Linux, using bootstrapped/verified clang
Use as a trust anchor to verify Mozilla services
Yes, Mozilla is doing services: https://services.mozilla.com/
What would a user-first Web of services look like?
38
42. Conclusion
•
First they said that JS or 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
40
43. Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/webevolution-trends