Hacker GitHub

← All repos

tc39/proposal-explicit-resource-management

View on GitHub ↗ ★ 943 JavaScript

ECMAScript Explicit Resource Management

31 mentions on Hacker News by 29 people: 2 stories, 29 comments · first 2021-12-13 · latest 2025-09-08

Mentions per year 31 mentions · busiest year 2023 (15)
20082026
  1. And at the other extreme, it takes TC39 seven years to bikeshed half of a decent implementation of Python's context managers: https://github.com/tc39/proposal-explicit-resource-managemen... On one extreme, we have standards committees that…
    comment by quotemstr · 2025-09-08 · in NPM debug and chalk packages compromised
  2. The `using` proposal is so bad. [1] There is exactly zero reason to introduce a new variable binding for explicit resource management. And now it doesn't support destructuring, etc. It should have been using (const a = resource()) { }…
  3. I wrote an article with more examples https://waspdev.com/articles/2025-05-17/js-destructors-or-ex... . It's actually a simplified version of this https://github.com/tc39/proposal-explicit-resource-managemen... .
  4. https://github.com/tc39/proposal-explicit-resource-managemen...
  5. > This looks most similar to golang’s defer. It runs cleanup code when leaving the current scope. It's nothing like go's defer: Go's defer is function-scoped and registers a callback, using is block-scoped and registers an object with a…
  6. Here’s some relevant discussion about some of the footguns: https://github.com/typescript-eslint/typescript-eslint/issue... https://github.com/tc39/proposal-explicit-resource-managemen... I imagine there will eventually be lint rules for…
  7. That's because the author of the proposal is from Microsoft and has repeatedly shot down counter-suggestions that made the syntax look different from C#. https://github.com/tc39/proposal-explicit-resource-managemen...…
  8. It's similar, but more inspired by C#'s "using declaration", an evolution of the using blocks, which are the C# version of try-with-resource: `using` declarations don't introduce their own block / scope. The original proposal references…
  9. > A conforming JavaScript implementation, even one that does garbage collection, is not required to call cleanup callbacks. Really looking forward to the "Explicit Resource Management" proposal[0] that sounds like a much better idea…
    comment by ketanhwr · 2025-05-09 · in Finding a Bug in Chromium
  10. Small hint, JavaScript is in the process of getting a dispose like API, already at stage 3. https://github.com/tc39/proposal-explicit-resource-managemen...
    comment by pjmlp · 2025-02-18 · in Go 1.24
  11. Uh, you are wrong. It absolutely is a thing and it has been in your browser and Node for longer than a year. https://github.com/nodejs/node/pull/48518 https://github.com/tc39/proposal-explicit-resource-managemen...
    comment by sureIy · 2024-11-18 · in Web Locks API
  12. > navigator.locks.request("my_resource", async (lock) => { This would be so much more readable with `using` { using lock = navigator.lock('my_resource'); await do_something(); await do_something_else(); } (…
    comment by unilynx · 2024-11-10 · in Web Locks API
  13. The standard doesn't have anything to do with TypeScript, not sure where you got that from? https://github.com/tc39/proposal-explicit-resource-managemen...
    comment by explaininjs · 2024-04-01 · in A proposal to add signals to JavaScript
  14. In addition to this, is the new (stage 3 even!)explicit resource management proposal[0], supported by TypeScript version >= 5.2[1] Though I agree that async context is better fit for this generally, the ERM should be good for telemetry…
    comment by no_wizard · 2023-08-28 · in OpenTelemetry in 2023
  15. TSC should fail the build if it doesn't have the destruction interface, the scope is the scope the variable is initialized in/under. It's very similar to C#'s usage of using. Edit: It's also a pending Stage 3 proposal for EcmaScript.…
    comment by tracker1 · 2023-08-24 · in TypeScript 5.2
  16. ▲ 2
    ECMAScript Explicit Resource Management Proposal
    story by tentacleuno · 2023-07-03 · 0 comments
  17. There's a conversation I had with Ron Buckton, the proposal champion, mainly on this specific issue. [1] Short answer: Yes, Disposable can leak if you forget "using" it. And it will leak if the Disposable is not guarded by advanced GC…
    comment by rixtox · 2023-06-23 · in TypeScript 5.2's new keyword: 'Using'
  18. I think you’re confusing scope and reachability. Maintaining a reference to an object has nothing to with whether or when it’s disposed in this TC39 language enhancement. Such a system _does_ exist in Object finalizers, but it’s hard to…
    comment by semiquaver · 2023-06-20 · in TypeScript 5.2's new keyword: 'Using'
  19. I'm pretty sure that example won't work and is based on an old version. But assuming a javascript implementation where it works, I don't know what you mean by "language rule". The spec says what "using" means, and it doesn't require any…
    comment by Dylan16807 · 2023-06-20 · in TypeScript 5.2's new keyword: 'Using'
  20. In my opinion, this is a flawed proposal. The disposer should not be a method on the object, because it means it cannot pass around the resource without the risk that the recipient of the resource disposes it themselves. A safer…
    comment by rbalicki · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  21. I thought the same and I don't see motivation from it on the TC39 spec page [1] but I do see they have several examples that make use of the feature. It makes me realize I've never really considered the memory implications of doing…
    comment by zoogeny · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  22. This is not TypeScript-specific, it’s a stage-3 ECMA-262 proposal. https://github.com/tc39/proposal-explicit-resource-managemen... It’s a shame the author insisted on it looking like C# and sabotaged attempts to combine disposal with…
    comment by pwdisswordfishc · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  23. The proposal[1] explains several cases where try…finally is verbose or even can result in subtle errors. The upshot for me is that this feature adds RAII to JavaScript. It makes resource management convenient and more maintainable. Seems…
    comment by robby_w_g · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  24. The last example: { await using { connection } = getConnection(); // Do stuff with connection } // Automatically closed! edit: according to the ES proposal issues, this might be something that doesn't actually exist, on purpose (it's…
    comment by masklinn · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  25. Nice, so this is the equivalent of `with` and context mangers in Python. I like it. I generally avoid new TS features (apart from typing that gets compiled away) until it looks like they are going to make their way into JavaScript, anyone…
    comment by samwillis · 2023-06-19 · in TypeScript 5.2's new keyword: 'Using'
  26. ▲ 13
    ECMAScript Explicit Resource Management Proposal
    story by Lwrless · 2023-06-19 · 0 comments
  27. I'm not _entirely_ sure which RAII you mean, but if you mean something like C#'s `using` or Java's `try-with-resources` or Python's `with`, then https://github.com/tc39/proposal-explicit-resource-managemen... and…
    comment by svieira · 2023-06-12 · in Douglas Crockford on JavaScript
  28. I'd prefer something with a more sound type system, and something that makes cleaning up resources easier and more ergonomic. This might help with cleanup: https://github.com/tc39/proposal-explicit-resource-managemen... But I'm not sure…
  29. There's a proposal for syntax to help with this in JS, incidentally: https://github.com/tc39/proposal-explicit-resource-managemen...
    comment by bakkoting · 2022-09-27 · in Go runtime: 4 years later
  30. There is no reason why you could not, in principle, have Rust-style compile-time borrow checking in a managed language. As an extreme example (that I have occasionally thought about doing though probably won't), you could fork TypeScript…
    comment by ameliaquining · 2021-12-27 · in Why Is C Faster Than Java (2009)
  31. Things like https://github.com/tc39/proposal-explicit-resource-managemen... . Essentially better language level support for objects which represent some IO resource that should be reliably closed when a user is done with it. Something like…
    comment by lucacasonato · 2021-12-13 · in Deno Joins TC39