Live data from Hacker News

Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)

slideshare.net

1–10 of 72 posts

Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)

#1
It’s very likely that you’ve been writing totally incorrect code without realizing it. Once you do realize it, it’s usually not too hard to fix the problem, depending on the language you're using.

Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)
slideshare.net

Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)

#3
post #2

Interesting 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.

To be fair, the author mentions that his is a Java school and (presumably, therefore) gives most attention to Java.

Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)

#5
post #2

Interesting 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, actually does.

Re: Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?)

#8
post #2

Interesting 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.

He sort of glosses over the "syntatic sugar" in C#. Which is simply:

  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?)

#10
post #5
post #2

Interesting 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…

Which counts as the sugar which he mentions. See also "using" in C#. These are pretty clearly design warts. WPF (C# UI library) jumps through some interesting hoops to make it look like all your resources can be properly garbage collected, but even then it tends to come back and bite you for any non-trivial application.
Post reply on HN