Teaching Explicit Resouce Management

I'm looking for advice on how to move a team into learning about the new Explicit Resource Management proposal. Since it is available for experimentation via TypeScript and polyfills I'd like to prepare large teams to embracing its possible use.

One of the stumbling blocks I'm encountering is resistance to change. For example, the defer pattern is available in some languages where their ecosystem sees the value of locality of concerns, scoped cleanup guarantees, and the concise and expressive syntax. JavaScript will soon (and does with TS) allow all of that through using and the DisposableStack API. But because JS hasn't had this before the hill that needs climbing to reach understanding is extremely steep.

Has this happened with other JS proposals? How does new features make it into the consciousness of the wider community? What pit falls and troubles are on that path?

And most importantly, were do those who have found themselves at the top of the hill go to talk about higher level ideas like ERM without first having to teach a college course to get people up to speed?

I would also start with concrete problems. e.g. pulling up old tickets where a bug might have been avoided if the code had been able to use the syntax. Or do a code search to count how many places are currently using a try/finally that could be replaced with a using pattern.

The general pattern that this proposal aligns with is locality, the setup and teardown of a resource are written in close proximity meaning that less context needs to be in the readers mind when assessing the correctness of the code. I would also find examples that emphasis this.

Also, this proposal is relatively new and still only stage 3 so I'm not surprised that it's still considered more niche. Things take time to grow and find their place. The proposal will also benefit from time, in that it libraries will need to implant the new symbol dispose protocol so that they can be used with the syntax.

1 Like