JavaScript WeakRefs and TC39 standardization.pptx
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《JavaScript WeakRefs and TC39 standardization.pptx》由用户(无敌的果实)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JavaScript WeakRefs and TC39 standardization
- 资源描述:
-
1、JavaScript WeakRefs andTC39 我 Daniel Ehrenberg littledan Delegate in TC39家Les Roquetes del Garraf, Europe工作Embedded WebKit and Chromium developmentMesa and GStreamer driversCSS, ARIA, WebAssembly, MathML, JavaScriptstandards+implementation in web WeakRefs:Motivation anduse In-memory cache Remote res
2、ources with identifiers Cache locally to avoid repeat lookups Tradeoff: Cache hit rate vs memory usage Idea: Hold things in the cache if the resource is being used Remove from cache when its garbage collected? (May be combined with LRU)WebAssembly memory management WebAssembly is based on a big Type
3、dArray: malloc and free inside How can allocations in WebAssembly be exposed to JavaScript? Object wrapping a range in the TypedArray Expect user to explicitly call obj.free() method? Too hard. Automatically free when no longer referenced?Avoiding stranded resources File handles, sockets, etc When n
4、o one references them:Resource leak until end of process Possible solution:Trigger error/log warning when a resource is Common capability: connecting to GC These examples require tying into GC:weak references and finalizers JavaScript doesnt give that access! Why? Interoperability/stability New trad
5、eoffs with new information Eventually, committee was convinced that we should add WeakRefs WebAssembly use case was especially persuasive JS devs have been telling us this is needed for decades Now, the proposal is at Stage 3 in TC39!Who is TC39? A committee of Ecma, with JS developers JavaScript en
6、gines Transpilers Frameworks, libraries Academics Major websites/app platforms Now, some Chinese companies! etcMeetings Every two months For three days Discuss language changes Seek consensus on proposalStage advancementTC39 stages Stage 1: An idea under discussion Stage 2: We want to do this, and w
7、e have a first draft.On the roadmap Stage 3: Basically final draft; ready to go Stage 4: 2+ implementations, tests Consensus-based decision-making TC39 doesnt vote on what the language will be (rarely vote on technicalities/procedural matters) TC39 is consensus-seeking We work together to meet every
8、ones goals Does anyone object to stage advancement? Objections must have rationale, appropriate to stage Technical concerns should be raised Consensus-based decision-making Consensus is established at some point,but could always be revisited with new consensus. Established consensus cannot be vetoed
9、/outvoted later Technical concerns should be raised as early as possible We assume good faith:True motivations are given for objectionsWorking together with trust All TC39 delegates are considered Stage 4 features2+ implementations, tests BigInt: Stage 4!const x = 2 * 53; x = 9007199254740992const y
10、 = x + 1; y = const x = 2n * 53n; x = 9007199254740992nconst y = x + 1n; y = const x = 2n * 53n; x = 9007199254740992nconst y = x + 1n; y = 9007199254740993nnstands for BigIDynamic import():Stage 4Domenic DlittledanIntl.RelativeTimeFormat:Stage 4Zibi BIntl.RelativeTimeFormat Shipped in Chrome and Fi
11、refoxlet rtf = new Intl.RelativeTimeFormat(en);rtf.format(100, day);/ in 100 daysnew Intl.RelativeTimeFormat(zh).format(100, day)/ 100天后Optional chaining:Stage 4Daniel RosenwasserClaude PacheGabriel IsenbergDustin Slet x = foo?.bar;/ Equivalent to.OptionalPropertyAccesslet x = (foo != null & foo !=
12、undefined) ?foo.bar :undefined;Collaboration with TypeScript in TC39 TypeScript saw many feature requests for ?. TC39s effort was going slowly TypeScript aligns with JavaScript runtime semantics TypeScript type system erased at compile time JS defines runtime semantics Daniel Rosenwasser, TypeScript
13、 PM, came in push it forward Based on TC39 success, ?. shipping in TS 3.7 Now, ?. will be part of ESNullish coalescing:Stage 4Daniel RosenwasserGabriel Ilet x = foo() ? bar();/ Equivalent to.NullishCoalescinglet tmp = foo();let x = (tmp != null & tmp != undefined) ?tmp :bar();Stage 3 featuresBasical
14、ly final draft; ready to WeakRefs:Stage 3Sathya GunasekaranTill SchneidereitMark MillerDean TRead consistencyconst w = new WeakRef(someObject);.if (w.deref() w.deref().foo(); / w.deref() here can not failPrivate fields andmethods:Stage Why? Private methods encapsulate behavior You can access private
15、 fields insideprivate methodsclass Counter extends HTMLElement #x = 0;connectedCallback() this.#render();#render() this.textContent =this.#x.toString();# is the new _for strong encapsulationWhy strong encapsulation? Not all code needs this, but Library/framework authors may want to provide a stable
16、API Common techniques can be hacked into_properties TypeScript private In practice, users depend on these internals, and then library authors cannotevolve beyond their old details Node.js and Moment.js hit these issues Library users benefit from good class PublicCounter class PrivateCounter _x = 0;#
17、x = 0;let c = new PublicCounter();let p = new PrivateCounter();console.log(c._x);/ 0console.log(p.#x);/ SyntaxErrorStage Why not private keyword? In languages with types:obj.x can check whether x is private by looking at the type of obj JavaScript is dynamically typed private vs public distinction n
18、eeded at access point,not just definition # as part of the name was the cleanest, simplest solution we found We thought about many alternatives over 20 years; ask me later about anyfurther Stage 2 featuresWe want to do this, and we have a first Decorators: Stage 2Yehuda KatzRon BSyntax abstraction f
19、or attrs/props in Web Components/ Salesforce abstraction/ Polymer abstractionimport api from salesforce;class XCustom extends PolymerElement property( type: String, reflect: trueclass InputAddress extends HTMLElement )api address = ;address = ;Example of using decorators to improve ergonomics.Tempor
20、al: Stage 2Maggie PintPhilipp DWhat time did this presentation start in Berlin?let startDateTime =/ Temporal.DateTimeTemporal.now.dateTime().with( hour: 14, minute: 00 );let startAbsolute =/ Temporal.AbsolutestartDateTime.inTimeZone(Temporal.now.timeZone();let localizedToBerlin =/ Temporal.DateTimes
展开阅读全文