By Daniel Ehrenberg.
Slides at https://docs.google.com/presentation/d/1UOk7RlrCdFLs95OPQ-emm__oHD3n43zGyLsn0aGZWyI/edit#slide=id.p
JavaScript code frequently has to deal with missing values, but current mechanisms are repetitive or error-prone. Some are proposing that we change the JavaScript programming language, in a way inspired by other languages like Swift: the optional chaining and nullish coalescing operators.
We got a big upgrade to JavaScript with ES6, but TC39, the standards committee which defines the programming language, is still making improvements with this and other proposals. In this talk, I'll explain what kinds of things TC39 thinks about, how it goes about improving the programming language, and how you can participate to shape the future of JavaScript.
(c) BrazilJS 2018
24 e 25 de Agosto, Brazil
5. const people = [
{name: "Dan Ehrenberg,
passport: {number: 1234567n, expiration: new Date(2020, 1, 1)}},
{name: "John Doe",
dateOfBirth: new Date(2000, 5, 5)}
];
const passportNumbers = people.map(person => person.passport.number)
// ===> TypeError!
// people[1].passport is undefined,
// so it has no number property
48. Add these features?
● Pro
○ Makes some code cleaner
○ Avoids bugs from existing idioms
● Con
○ More to learn, mentally parse, etc
49. Steps needed for Stage 2
● First draft spec text ✔
● Agreement on syntax, broadly …
● Agreement that we want the proposal …
50. Plan from here
● Experiment with ?. and ?? in Babel, at Stage 1
● Collect feedback over time
● Consider for Stage 2 in the future
● The features are easy to implement; we are just
taking our time to work out the right design.
51. Steps needed for Stage 3
● Complete spec text …
● Signoff from reviewers, editor …
● Ready to pass off to implementers …
52. Steps needed for Stage 4
● Two implementations …
● Conformance tests …
● PR with editor signoff …
61. ?./?? documentation
● "Explainer documents" for each proposal
● Wanted: Better introductory materials
● Wanted: Educators' perspective on the proposals
62. Implementation
● Open-source projects accepting contributions:
○ Babel
○ TypeScript
○ V8
○ Acorn
● Features developed behind a flag/in a plugin
○ JSC
○ ChakraCore
○ SpiderMonkey
○ And many more
63.
64. ?./?? implementations
● Babel transforms in 7.0
○ @babel/plugin-proposal-nullish-coalescing-operator
○ @babel/plugin-proposal-optional-chaining
■ Included in React Native 0.56
○ Thanks, Justin Ridgewell and Lucas Azzola!
● Want to write more implementations? Try this out?
65. Attending TC39 as a delegate
● Join Ecma to come to TC39 meetings
● Contact me for more info, littledan@igalia.com
66. ● Get involved in TC39:
https://tc39.github.io/
● ?. and ?? are at Stage 1
for handling null/undefined
● Daniel Ehrenberg
● Twitter/GitHub @littledan
● littledan@igalia.com