Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
slideshare.net
Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
1–10 of 72 posts
Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#2Seems like a cheap way to get upvotes.
Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#3Interesting how java is the only language included in the title, but the slides have the opinion that C#, Ruby and Python all suck as well. Seems like a cheap way to get upvotes.
Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#4 X x = null;
Y y = null;
try{
x = foo();
y = bar();
yadda(x,y);
} finally {
if (x!=null) x.dispose();
if (y!=null) y.dispose();
}Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#5Interesting how java is the only language included in the title, but the slides have the opinion that C#, Ruby and Python all suck as well. Seems like a cheap way to get upvotes.
File.open("...") do |f|
firstline = f.readline
... stuff that might throw an exception ...
end
If the "stuff" throws an exception, the file gets closed automatically. And while File is a library class, it's getting no special favors here --- any pure ruby library can easily implement similar APIs, and ActiveRecord's connection pool, for example, actually does.Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#6Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#7 try {
mightFail();
} finally {
doCleanup();
}
instead of this: mightFail();
doCleanup();Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#8Interesting how java is the only language included in the title, but the slides have the opinion that C#, Ruby and Python all suck as well. Seems like a cheap way to get upvotes.
using(var resource = new Resource())
{
// potential code that throws exception
}Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#9:)
Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
#10Interesting how java is the only language included in the title, but the slides have the opinion that C#, Ruby and Python all suck as well. Seems like a cheap way to get upvotes.
And there actually is an idiomatic way to avoid the problem in Ruby: File.open("...") do |f| firstline = f.readline ... stuff that might throw an exception ... end If the "stuff" throws an exception, the file gets closed automatically. And while File is a library class, it's getting no special favors here --- any pure ruby library can easily implement similar APIs, and ActiveRecord's connection pool, for example, act…