Slide 1

Slide 1 text

TC39 x JSConf.jp Panel Discussion 2023/09/25 @ South Tower Tokyo

Slide 2

Slide 2 text

We will talk about JS weakpoints, next features, and so on.

Slide 3

Slide 3 text

First, take a look at our survey.

Slide 4

Slide 4 text

Excited proposals

Slide 5

Slide 5 text

Which proposal are you most excited? / Ͳͷϓϩϙ ʔβϧʹظ଴Λ͍ͯ͠·͢ ͔ʁ

Slide 6

Slide 6 text

Most exciting proposals • Temporal x 12 • Pipeline operator x 10 • Pattern Matching x 7 • Record and Tuple x 5 • JSON Modules x 3

Slide 7

Slide 7 text

Temporal // Stage 3 const zonedDateTime = Temporal.ZonedDateTime.from({ timeZone: 'America/Los_Angeles', year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500 }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles]

Slide 8

Slide 8 text

Pipeline operator // Stage 2 // Previous const json = await npmFetch.json(npa(pkgs[0]).escapedName, opts); // With pipes const json = pkgs[0] |> npa(%).escapedName |> await npmFetch.json(%, opts);

Slide 9

Slide 9 text

Pattern Matching // Stage 1 match (res) { when ({ status: 200, body, ...rest }): handleData(body, rest) when ({ status, destination: url }) if (300 <= status && status < 400): handleRedirect(url) when ({ status: 500 }) if (!this.hasRetried): do { retry(req); this.hasRetried = true; } default: throwSomething(); }

Slide 10

Slide 10 text

Record and Tuple // Stage 2 const record = #{ prop: 1 }; const tuple = #[1, 2, 3]; Record.isRecord(record); // true Record.isRecord({ prop: 1 }); // false // Equality #{ a: 1 } === #{ a:1 } // true #[1] === #[1] // true

Slide 11

Slide 11 text

JSON Modules // Stage 3 import foo from "foo.json" with { type: "json" };

Slide 12

Slide 12 text

Which proposals are exciting? (TC39 team?) • Iterator helpers • Pattern matching, modules declarations, deferred imports, compartments • temporal • Array.fromAsync • type annotation

Slide 13

Slide 13 text

Weak points

Slide 14

Slide 14 text

Do you have current JavaScript weak points? and what are the weak points? / ͲΜͳ఺͕ JavaScriptͷऑ఺ͩͱࢥ͍· ͔͢ʁ

Slide 15

Slide 15 text

JavaScript weak points • ݹ͍ػೳͱͷޓ׵ੑΛ࣋ͨͳ͍ͱ͍͚ͳ͍఺ɻ • JS needs to have an interoperability for legacy features. • This is not weak, strong point. • JS survives 20 years. • Backword compats are really important. • Some aspects of JS make it harder, such as being able to modify prototypes • To keep compatibility is needed. documentation is also important.

Slide 16

Slide 16 text

JavaScript weak points • Some parts are scattered in various specs (e.g. ECMA262 does not have Cancellation. It's relying on DOM AbortController) • ECMA262 ͚ͩ͡Όͳͯ͘ɺଞͷ࢓༷΋ݟ͓͔ͯͳ͍ͱ͍͚ͳ͍ͱ͜Ζ ʢྫ͑͹ɺΩϟϯηϧ͸DOM AbortController ͱ͔ݟͯͳ͍ͱ͍͚ͳ ͍ʣ • Cancellation is misunderstandable... it is not ECMA262 spec. • JS is just the language, it is not runtime environment. some other langs have similar architecture. •

Slide 17

Slide 17 text

JavaScript weak points • ESM and CJS separate the JS world. • ESMͱCommonJSͰ΍͸Γੈք͕෼அ͞Εͯ ͠·͏ॴ •

Slide 18

Slide 18 text

JavaScript weak points • Immutability is weaker than other langs • ෆมΛఏڙ͢Δػೳ͕ଞͷݴޠʹൺ΂ͯऑ͍ࣄ • Most js objects are mutable, so it is hard. • Object.freeze / seal are pragmatic... • Haskell is ever thing is immutable, python, c++, Java are not so immutable. It depends on design? • TS is not so immutable either.

Slide 19

Slide 19 text

JavaScript weak points • ະఆٛϝϯόΞΫηε΁ݫີͳ੍ޚ͕Ͱ͖ͣ unde fi ned ͕ޙͰൃ֮͢Δ఺ɻ • JS developers could not handle unde fi ned property access and fi nd these faults at production. • TypeScript will help you!! • Optional chaining ?. will help you!!

Slide 20

Slide 20 text

JavaScript weak points • Coercing Things • (NaN Λ 0 ͱͯ͠ѻͬͨΓ string ౉͞ͳ͖Ό͍͚ ͳ͍ͱ͜Ζʹ number ౉ͨ͠Βউखʹcastͨ͠Γ) • New APIs should not handle these unpredictable behaviour • Throw errors if the types are invalid.

Slide 21

Slide 21 text

JavaScript weak points • Prototype Pollution • ϓϩτλΠϓԚછͳΜͱ͔ͳΒΜʁ • 1. locked down (built-in prototype is frozen, global object is also freezed) • 2. realm proposal (create new environment / realm, prototype polluted in the environment, but it is not affected all world. shadow realms are stage3, ) • node vm module does not solve security problems.

Slide 22

Slide 22 text

Discussion: (Yosuke's talk)

Slide 23

Slide 23 text

ESM status • TypeScript con fi g `module` props have many options like es2022, nodenext, bundler, etc. • this prop nightmare is introduced by Node.js CJS / ESM options. • Node.js has CJS / ESM interop feature. • Historically, CJS is needed in Node.js. • ESM was declared in 2015. • Node.js core committer thought 2 specs would cause migration issues. • So, Node.js implemented CJS / ESM interops using the fi le extension and the package.json `type` fi eld.

Slide 24

Slide 24 text

ESM status • Spec difference: • ESM and CJS are totally different. • ESM: async load / CJS: sync load • ESM: static / CJS: dynamic • ESM: pass by reference / CJS: pass by value

Slide 25

Slide 25 text

ESM status • My opinion: • TypeScript developers feel Node.js brings ESM/CJS nightmare. • Node.js developers feel if CJS/ESM interop has never been implemented, migration nightmare will start. • I guess TC39 people think module system is required and it would be better to be browser friendly (CJS is not ideal it is for Node.js / Server-side).

Slide 26

Slide 26 text

😇 My Opinion: This is nobody's fault. Future prediction is hard.