This is part of my live blogging from QCon 2015. See my QCon table of contents for other posts.
ES2015 being approved now. Then comes ES 2016 and working on yearly releases. Train model like Eclipse. The train leaves the station once a year and mature proposals get on the train.
To get on release train must have multiple interoperabl implemntations. Avoids “breaks the web” features. Ensures really are mature. Also must have tests. (test 262 collateral)
Timeline
- 1995 – Mocca/JavaScript was born
- 1999 Edition 3 standard. Used by IE 6
- ES 4 didn’t pan out. Then commitee couldn’t agree on anything for a decade
- 2009 – ES5 came out. Added strict mode, getters/setters, minor array features. Small release
- June 2015 – ES 2015
- June 2016 – ES 2016
Disclaimer: Everything is a work in progress and subject to change
s.at(0)
unicode support – how long is an emoji?
Functions
- return a single value synchronously with functions
- return many values synchronously with generator functions
- return a single value asynchronously with promises:
async function f() { …}
f().then(f => { …}
async (a,b) => await a + await b; - >return many values asynchronously with observables
let observer = {
next(value) {},
throw(error) {},
return() }let d= new Observable( a => { …});
d.subscribe(observer());Observerables should fel like arrays. Call forEach(), etc.
Math.pow(10,2) becomes 10 ** 2
SIMD (single instruction mutliple data)
- Hardware instructions for number crunching
- Uses data parallelism to perform multiple calclulation simulatnenously
- Good for things like 3D graphics where can use scalar math
- let a = SIMD.int32x4(0,1,2,3);
let b =SIMD.int32x4(4,5,6,7);
let c = SIMD.add(a,b);
let zero = SIMD.init32x4.zero();
‘a’.lpad(4) and ‘a’.rpad(4)
Decorators
- Can decorate classes, properties, functions
- Like a function wrapper. [like an aspect or Ruby active record]
- Annotation to use
Value types
- New primitive typs – Int64, Bignum, Decimal, Complex, Rational,SIMD typs, TypedArray types
- Factory let int8 = Int8(254)
- Literal suffixes let i64= 0L; let bigNum b = 0n; etc
- Primitves are better for serializing across frames
- Still immutable like other primitives
- === compares by value
- Custom primitive types – export let Yard – ValueType(Symbol(“Yard”), Float64)
- Can overload operators on new custom primitives: Reflect.defineOperator(‘+’, f, Yard,Yard)
Q & A
- What about value types in JSON? No plans. JSON is frozen. Can’t break JSON parse and it is used everywhere.
- Opportunity for confusion when assign value types to a JSON object. Would convert back to regular primitives and throw an error if can’t do safely