Comments on: Errorhandling Ruby vs. Java http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/ ruby, java and the rest Fri, 21 Nov 2008 05:19:47 +0000 http://wordpress.org/?v=2.5.1 By: lenciel » 博客文章 » 昨日搜刮 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-49818 lenciel » 博客文章 » 昨日搜刮 Mon, 19 Mar 2007 15:17:17 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-49818 [...] Errorhandling Ruby vs. Java # [...] [...] Errorhandling Ruby vs. Java # [...]

]]>
By: Frank Spychalski http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2917 Frank Spychalski Mon, 12 Jun 2006 08:26:22 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2917 Neutronica, I want both :-)<!-- X-spaminator-strike: whitelist, -3 --><!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --><!-- X-spaminator-strike: url dashes, 3 --> Neutronica, I want both :-)

]]>
By: Neutronica http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2916 Neutronica Mon, 12 Jun 2006 02:12:17 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2916 Eh. It got chopped. Event w/ the yicky chunk above you should be able to figure out what I'm about: suffice to say, much nicer in Ruby, and this might be a usecase for AOP.<!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-strike: empty field - author url, 1 --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --> Eh. It got chopped. Event w/ the yicky chunk above you should be able to figure out what I’m about: suffice to say, much nicer in Ruby, and this might be a usecase for AOP.

]]>
By: Neutronica http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2915 Neutronica Mon, 12 Jun 2006 02:11:03 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-2915 Actually, I don't think you want the above, either: you want a retry keyword... Without thinking about it much, the best I could come up with is something like this: public static Object block(final IRetry block_, final Class[] catch_, final int tries_) throws RuntimeException { Exception finalException = null; for (int i = 0; i <!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-strike: empty field - author url, 1 --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --><!-- X-spaminator-strike: url dashes, 2 --> Actually, I don’t think you want the above, either: you want a retry keyword…

Without thinking about it much, the best I could come up with is something like this:

public static Object block(final IRetry block_,
final Class[] catch_,
final int tries_)
throws RuntimeException {
Exception finalException = null;
for (int i = 0; i

]]>
By: Frank Spychalski http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-598 Frank Spychalski Tue, 04 Apr 2006 07:16:02 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-598 Again, I should have been more specific :-) I usually have to do more than just print out the stacktrace. This errorhandling is sometimes the same for different Exceptions. This leads to solutions like the one below, which I don't consider very elegant, compared to the Ruby solution: try { foo(); } catch(java.sql.SQLException e) { handleEx(sqle); } catch(java.util.concurrent.TimeoutException e) { handleEx(e); } private void handleEx(Exception e) { ... } I would like to see: try { foo(); } catch(java.sql.SQLException, java.util.concurrent.TimeoutException : Exception e) { ... } I admit, this is just syntactic sugar but I like sugar :-) Again, I should have been more specific :-) I usually have to do more than just print out the stacktrace. This errorhandling is sometimes the same for different Exceptions. This leads to solutions like the one below, which I don’t consider very elegant, compared to the Ruby solution:

try {
foo();
} catch(java.sql.SQLException e) {
handleEx(sqle);
} catch(java.util.concurrent.TimeoutException e) {
handleEx(e);
}

private void handleEx(Exception e) {

}

I would like to see:

try {
foo();
} catch(java.sql.SQLException, java.util.concurrent.TimeoutException : Exception e) {

}

I admit, this is just syntactic sugar but I like sugar :-)

]]>
By: Robert Fisher http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-597 Robert Fisher Mon, 03 Apr 2006 17:51:06 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-597 "I would very much like to see a elegant solution which catches only java.sql.SQLException and java.util.concurrent.TimeoutException" try { foo(); } catch(java.sql.SQLException e) { sqle.printStackTrace(); } catch(java.util.concurrent.TimeoutException e) { e.printStackTrace(); }<!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --> “I would very much like to see a elegant solution which catches only java.sql.SQLException and java.util.concurrent.TimeoutException”

try {
foo();
} catch(java.sql.SQLException e) {
sqle.printStackTrace();
} catch(java.util.concurrent.TimeoutException e) {
e.printStackTrace();
}

]]>
By: Jason http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-595 Jason Sat, 01 Apr 2006 20:55:09 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-595 This article is written very poorly. You need to supply an example that compares and contrasts java code vs. the ruby code. Maybe code the same solution in both languages. As far as your comment " there is no elegant way of catching 2 or more exceptions without catching Exception or Throwable" is concerned, you are wrong. You need to look into OOP and polymorphism. Also, look at some design pattern books, then maybe you can start posting comments why you think ruby is so much better than java. ps, your site breaks in the Opera browser.<!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-strike: empty field - author url, 1 --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --> This article is written very poorly. You need to supply an example that compares and contrasts java code vs. the ruby code. Maybe code the same solution in both languages. As far as your comment ” there is no elegant way of catching 2 or more exceptions without catching Exception or Throwable” is concerned, you are wrong. You need to look into OOP and polymorphism. Also, look at some design pattern books, then maybe you can start posting comments why you think ruby is so much better than java. ps, your site breaks in the Opera browser.

]]>
By: Frank Spychalski http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-593 Frank Spychalski Sat, 01 Apr 2006 19:25:59 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-593 notany, Peter: thanks for the pointers<!-- X-spaminator-strike: whitelist, -3 --><!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --><!-- X-spaminator-strike: url dashes, 1 --> notany, Peter: thanks for the pointers

]]>
By: Peter Cooper http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-592 Peter Cooper Sat, 01 Apr 2006 18:42:27 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-592 Two queue ideas for Ruby.. Spread is a good messaging system that's been around years and there's a good Ruby client library. Just been playing with it, very nice. Alternatively, BerkeleyDB has a Queue mechanism. Both of these are mature technologies.<!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --> Two queue ideas for Ruby.. Spread is a good messaging system that’s been around years and there’s a good Ruby client library. Just been playing with it, very nice. Alternatively, BerkeleyDB has a Queue mechanism. Both of these are mature technologies.

]]>
By: notany http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-591 notany Sat, 01 Apr 2006 15:21:35 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-591 Everyone who is intrested digging deeper into Rubys error handling and it's pros and cons and philosophical motivations behind it, should read the following paper (now online). Like many other things, Common Lisp has the most advanced condition system in existence. Ruby's is restricted version of that. Condition Handling in the Lisp Language Family http://www.nhplace.com/kent/Papers/Condition-Handling-2001.html This paper appears in Advances in Exception Handling Techniques, edited by A. Romanovsky, C. Dony, J.L. Knudsen, and A. Tripathi. This book, published in 2001, is part of Lecture Notes in Computer Science, Volume 2022, published by Springer.<!-- X-spaminator-passed: IP check --><!-- X-spaminator-strike: excessive links, 3 --><!-- X-spaminator-passed: email check --><!-- X-spaminator-passed: author check --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --><!-- X-spaminator-strike: url dashes, 4 --> Everyone who is intrested digging deeper into Rubys error handling and it’s pros and cons and philosophical motivations behind it, should read the following paper (now online). Like many other things, Common Lisp has the most advanced condition system in existence. Ruby’s is restricted version of that.

Condition Handling in the Lisp Language Family
http://www.nhplace.com/kent/Papers/Condition-Handling-2001.html

This paper appears in Advances in Exception Handling Techniques,
edited by A. Romanovsky, C. Dony, J.L. Knudsen, and A. Tripathi.
This book, published in 2001, is part of Lecture Notes in Computer Science, Volume 2022,
published by Springer.

]]>
By: Frank Spychalski http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-590 Frank Spychalski Sat, 01 Apr 2006 11:56:13 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-590 The queue I was refering to, was a Java JMS Queue within JBoss. For what do you need a queue and what kind of problem are you trying to solve with it? The queue I was refering to, was a Java JMS Queue within JBoss. For what do you need a queue and what kind of problem are you trying to solve with it?

]]>
By: mal http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-589 mal Sat, 01 Apr 2006 10:49:29 +0000 http://amazing-development.com/archives/2006/04/01/errorhandling-ruby-vs-java/#comment-589 What are you using as a Queue in Ruby? I am looking for a good message que to use with ruby. Something really robust and fast.<!-- X-spaminator-passed: IP check --><!-- X-spaminator-passed: email check --><!-- X-spaminator-strike: short field, 1 --><!-- X-spaminator-passed: author check --><!-- X-spaminator-strike: empty field - author url, 1 --><!-- X-spaminator-passed: author url --><!-- X-spaminator-passed: comment body --> What are you using as a Queue in Ruby? I am looking for a good message que to use with ruby. Something really robust and fast.

]]>