News for hackers. Stuff that matters.
Re:Effective Go by morelisp on Sunday October 03, 2021 @02:17PM (#28739244)
You picked two languages (Java and Python) with extremely weak guarantees about disposal of resources when exceptions are thrown. Any time I acquire a non-trivial resource I must make sure it's disposed of properly, via a `close` etc. method. (And these are most cases of interest; acquiring trivial resources e.g. memory shouldn't need error handling in Go either.)

This isn't theoretical. I review a lot of Python code and I would say in over 20% of cases I see a try block with a `finally` longer than two lines, it mistakenly uses a variable that might not be set when an exception is thrown earlier than the writer expected.

Re:Effective Go by closeparen on Sunday October 03, 2021 @02:24PM (#28739322)
When a controller calls a couple of gateways and a database access layer, it is almost never holding resources. I would agree that testing error handling is more interesting when there are resources to clean up or fallback logic to implement. That's just very rarely the case. Mostly I just need to bail out of the request.
Re:Effective Go by Macha on Sunday October 03, 2021 @02:53PM (#28739580)
Java has try-with-resources and Python has context managers, I wouldn't consider either of them harder to use correctly than defer.
Re:Effective Go by morelisp on Sunday October 03, 2021 @02:57PM (#28739610)
I'm not talking about defer at all. The contrast would be C++'s RAII.