3 ms·
Having built an offline-capable distributed database in go, I noticed that even "larger" projects in go tend to be a lot less source code than building somethin
by fxtentacle 6y ago
Having built an offline-capable distributed database in go, I noticed that even "larger" projects in go tend to be a lot less source code than building something similar in Java.
And maybe that's just my personal style, but to me defer is much more important than generics.
I can't even remember how often I've had to debug Java bugs where someone forgot to close a ResultSet for an SQL query... And then you leak memory so badly that restarting tomcat with a daily cron is still not enough :(
With defer, you can expect people to write the cleanup code immediately after opening something, which makes it much easier to confirm that you're not leaking resources.
- apta 6y agoJava already solved this with try-with-resources, which the linter or IDE can warn you about (because the instance has to inherit from `AutoCloseable`). Not so with golang's defer, where it is much more likely that the developer can forget to call it.