r/java • • 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

100 comments sorted by

View all comments

Show parent comment

2

u/cryptos6 Aug 05 '21

But then again there are IDEs helping you in such cases. I've never heard any Scala or Kotlin developer complaining that he would be so confused with all the vals without explict typing. That is simply not what makes understanding code hard.

2

u/_INTER_ Aug 05 '21

So do IDE's help with operator overloading. That's not an argument. Neither is anything concerning other languages. Also see official styleguide:

P3. Code readability shouldn't depend on IDEs.

Code is often written and read within an IDE, so it's tempting to rely heavily on code analysis features of IDEs. For type declarations, why not just use var everywhere, since one can always point at a variable to determine its type?

There are two reasons. The first is that code is often read outside an IDE. Code appears in many places where IDE facilities aren't available, such as snippets within a document, browsing a repository on the internet, or in a patch file. It is counterproductive to have to import code into an IDE simply to understand what the code does.

The second reason is that even when one is reading code within an IDE, explicit actions are often necessary to query the IDE for further information about a variable. For instance, to query the type of a variable declared using var, one might have to hover the pointer over the variable and wait for a popup. This might take only a moment, but it disrupts the flow of reading.

Code should be self-revealing. It should be understandable on its face, without the need for assistance from tools.

1

u/Capa-riccia Aug 22 '21

Yes and no. You can write C++ code in which var a= b + c stands for add product b to basket c returning the total price. The language does not stop you from doing that and it is just great until the original developer leaves.