Hacker News new | past | comments | ask | show | jobs | submit login

That’s funny, because I really dislike “finally,” because it isn’t much better than doing all the cleanup yourself.

The design document for Java try-with-resources says that Sun’s own programmers working on the standard Java libraries got it wrong a third of the time. I find it interesting that C#, Java and Python have each created some kind of automatic cleanup mechanism even though they already had “finally.” That suggests to me that “finally” has some big drawbacks.




The drawback is that the finally block is far away from the set-up block, which makes it painful to maintain and allows them to get out of sync pretty easily. It's a syntactic issue rather than a semantic issue.

(This is only referring to use cases other than resource release.)


That is probably the most well-known problem, but it’s not the only one.

Another issue is that people generally don’t test failures as much as they should. They’ll generally get “everything must be rolled back” but mess up “only some things should be rolled back.”




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: