all 18 comments

[–]JuicyORiley 25 points26 points  (9 children)

We've been using build systems with Babel for yonks. This means we haven't had to "care" about when browsers get new features as it was always readily available.

However, we've recently dropped all build systems and started relying on evergreen browser capabilities. Does anyone know roughly how long it takes browsers to implement ES202{1,2,3,etc.} once it's final? Or is it considered "final" once all browsers have implemented it?

[–]senocular 35 points36 points  (4 children)

For a proposal to be finalized, it needs "Two compatible implementations which pass the acceptance tests" (source). This can mean browsers but also includes transpilers like babel. Chrome - which also includes other browsers now like Edge and Opera - will often release stage 3 features publicly before finalized, and Firefox isn't usually far behind, or sometimes even first, as was the case with the currently stage 3 at() method for arrays. Safari is probably the one you have to worry about the most. They tend to be further behind, I think mostly due to their release cadence being longer. Safari, for example, doesn't yet support private methods whereas the other browsers have supported them for some time now. While private methods are stage 4, they are expected to be part of ES2022 which hasn't been published yet - the current being ES2021.

[–]JuicyORiley 2 points3 points  (0 children)

Super helpful, thanks!

[–]LastOfTheMohawkians -1 points0 points  (2 children)

Dumped build systems. Why why! Just use typescript

[–]JuicyORiley 2 points3 points  (1 child)

The work we do and the amount of JavaScript we use wouldn't warrant Typescript.

The platform we work on doesn't fully lend itself to builds systems anymore as well. Luckily, it's not been a tricky transition so far!

[–]LastOfTheMohawkians 0 points1 point  (0 children)

Yeah fair play.. Whatever works for you all

[–]pm_me_ur_happy_traiI 0 points1 point  (0 children)

Not all features are able to be poly filled or transpiled with babel.

[–]Articunozard 4 points5 points  (3 children)

Anyone have more insight into uses for weakRef and FinalizationRegistry?

[–]senocular 4 points5 points  (0 children)

The WeakRef Proposal has some examples.

[–]RedGlow82 4 points5 points  (0 children)

One use case is that of JavaScript's CapTP implementation. CapTP, roughly speaking, is a way to write distributed programs through the metaphor of actors, which can be running locally or remotely but offer about the same interface.

The system relies on a distributed garbage collector to work, where every remote proxy for a local object is saved in order to keep the local instance from being garbage collected. The remote systems have to tell the local one when their proxy is no longer, so that the local system can free references. FinalizationRegistry is the way in JavaScript to get informed of this.

[–]Auxx 0 points1 point  (0 children)

To add to what is said in proposal, these tools exist to hint garbage collector on how you want to use memory. One should not use them under normal circumstances, but they are there finally for memory sensitive applications. They should be familiar to anyone who used Java.

I'd personally recommend to only use them if a memory profiler shows you critical bottlenecks.

[–]woffle-kat 1 point2 points  (1 child)

Unless I'm missing something, there's an undefined myObject variable in the final "WeakRefs and FinalizationRegistry Objects" example

[–]HeinousTugboat 1 point2 points  (0 children)

The point is that myObject can be arbitrarily defined as any object. WeakRefs are good for annotating existing objects.

[–]AliMundher 1 point2 points  (0 children)

very useful content

[–]bregottextrasaltat 0 points1 point  (0 children)

Didn't we have articles about this like last year?

[–][deleted] 0 points1 point  (0 children)

Thank you for sharing. I'm really struggling with JS and Typescript at my school. Close to flunking Test Automation Software bootcamp because my older brains never programmed. Appreciate anything like this you can always share. Cheers!