Proposal: Automatic Resource Management (original) (raw)
Stephen Colebourne scolebourne at joda.org
Sat Mar 7 07:45:13 PST 2009
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Xavi MirĂ³ wrote:
But I would like to emphasize that the benefits of using this proposal are huge without direct support for Locks. Josh has made very clear it is not intended to be used with Locks.
I think this is understood, however the reality is that it will be. As soon as the ARM code is in the compiler, an open source project will appear with code to wrap other classes to make them work with the ARM block.
Of course that doesn't mean ARM is good or bad, just that we should be realistic about how widely used it will be.
There are other cases that I don't think ARM will handle perfectly (and BGGA/JCA do). For example, looping around the lines in a file, which might ideally look like:
for (String str : file.readLines()) { // process lines } <-- close file here
The closest ARM is this:
try (BufferedReader in = file.openBufferedReader()) { for (String str : in.lines()) { <-- new method returning an Iterable // process lines } }
Of course, that is still a lot better than today. And really, thats the point.
My personal take is that I would welcome ARM in Java 7, either interface-based or keyword-based. I think the benefits are sufficiently great that we shouldn't make developers to wait any longer.
I am of course fully aware of the reduction in value that BGGA/JCA style control invocation then faces as a language change (and hence the passion in the debate, notably from Neal).
However, with closures officially defined as 'out' I have to choose between solving real issues now (in the 80% case) or waiting another 3 years+. I choose pragmatism - solve the 80% now with ARM, and reconsider BGGA/JCA later.
Stephen
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]