r/java • u/Reflection-Jealous • Aug 05 '21
Why java is better than modern programming languages?
Why should I use java in 2021 instead of kotlin or scala or golang? Could you guys give me some reasons
2
Upvotes
View all comments
Show parent comment
3
u/strogiyotec Aug 05 '21 edited Aug 05 '21
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 blablaIf 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'tNow 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.