Linked by fran on Fri 22nd Jul 2011 21:02 UTC
Google "Now everyone can use Google's Go language on the company's App Engine cloud platform as the company has announced that the Go runtime, which has been in development since it was announced at Google I/O, is now generally available."
Thread beginning with comment 482191
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: As a programmer...
by jessta on Mon 25th Jul 2011 16:33 UTC in reply to "RE[2]: As a programmer..."
jessta
Member since:
2005-08-17


Well, no.. surely the concept is similar as the following (Sorry, OS news seems to flatten the indentation in the preview, so probably the post too):


It's possible to use panic/recover as a fairly limited traditional exception handling system, but it's not nice to use and Go programmers won't expect it. Similarly you can return null to indicate errors in Java but Java programmers won't expect that either.


Exception handling and Error handling go hand in hand in modern OO languages.


They are distinct concepts and Go treats them as such.
By making them distinct you make your error handling easier to reason about and more resilient to changes in other parts of the code base. Even Java's checked exceptions have a neat trick of hiding the source of an exception from the code that has to handle it.

Reply Parent Score: 2

RE[4]: As a programmer...
by henderson101 on Tue 26th Jul 2011 09:33 in reply to "RE[3]: As a programmer..."
henderson101 Member since:
2006-05-30

"Exception handling and Error handling go hand in hand in modern OO languages.


They are distinct concepts and Go treats them as such.
By making them distinct you make your error handling easier to reason about and more resilient to changes in other parts of the code base. Even Java's checked exceptions have a neat trick of hiding the source of an exception from the code that has to handle it.
"

An exception is still an error that occurred in your code. This can be from a multitude of reasons, but many languages now treat exceptions as first class errors. What you are talking about is the traditional approach to Error handling - I pass in a bunch of params, including a pointer to my expected result, I return an integer (or boolean) that is either "success" or "reason for failure". Yeah, there's a place for this concept, but in a true OO language the Exception carries a wealth of extra information that the programmer can use to diagnose the error condition.

Reply Parent Score: 2

RE[5]: As a programmer...
by jessta on Tue 26th Jul 2011 09:48 in reply to "RE[4]: As a programmer..."
jessta Member since:
2005-08-17


An exception is still an error that occurred in your code. This can be from a multitude of reasons, but many languages now treat exceptions as first class errors.


Exceptions aren't recoverable. Your can't plan for them and handle them. An exception is a bug in your program and it can't continue until someone fixes the bug. It can restart but that's not really error handling.

Errors are expected so code can be written to handle them and attempt some kind of recovery. Treating exceptions as errors leads to attempts to recover from unrecoverable situations.

but in a true OO language the Exception carries a wealth of extra information that the programmer can use to diagnose the error condition.


I assume you haven't actually had a look at how Go does error handling. Functions can return multiple values so it's idiomatic to return a value and an error value.
The error value can be null or contain a data structure containing information about the cause of the error.

Reply Parent Score: 2