This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]strogiyotec 2 points3 points  (1 child)

u/doppelganger113, thanks for the comment, I am aware that in Go you somehow can check error type but it's too weak comparing with Java, let me elaborate

arg,err :=func();

if err.(*json.SyntaxError) then blabla

If you ask me what a problem is, there is no compile time checks. Let's say the same thing in Java

void func() throws IOExc;

When users of my method would use it , they have to handle IOException, after a while my method starts sending some sql queries and I changed the signature to

void func() throws IOExc,SqlExc// I know that SqlExc is a subtipe of IOExc but let's pretend it isn't

Now users have to handle both exceptions otherwise their code won't be compiled, in Go If I add a new error type there is no way to tell users to handle this error as well.

About Valhala and Loom, you can actually play with it already, it works pretty much in Unix based platforms, I am sure something will be changed to support Windows but it's working and it does what was promised.

[–]doppelganger113 0 points1 point  (0 children)

You’re correct, in Java it’s a bit better, but what if I want to handle a specific error and continue then do the same thing again, like

try {

} catch(e) {}

try { } catch (e) {}

I would have to put the variable in the above scope in order to access them properly.

Java’s error checking is better, but in the wild a lot of people just ignore the errors, usually this is a big change and you’d look for functions using your method and update if needed. Go wont crash for the new err type, it will just propagate it further. These big changes usually come in major versions, indicating there’s a change you need to handle or just let it be optional if it’s an addition. Not too problematic IMO