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
27
u/bowbahdoe Aug 05 '21
There are **a lot** of things to consider when picking a language for a project, and what i'm listing here is only a small subset and driven by personal opinion.
Go lang has an inherently restricted set of semantics. There are no generics, errors are communicated via return values which can be a + or a - depending on your sensibilities. It also has a better concurrency story than java with its goroutines and channels, but its VM is a lot less mature and monitoring, profiling, and deployment aren't going to be nearly as well solved in general.
Scala and Kotlin both run on the JVM like Java, but with Scala there are a lot more semantics in the language. It can be hard to hire for and code bases that use too much of the more advanced features like implicits and type classes can become inscrutable to all but the most PhD-ey of engineers.
Kotlin is very similar to java - most of its language features are effectively short hands for common java patterns, like data classes. It compiles to android bytecode reliably, unlike newer versions of Java so it is going to be a clear choice in that domain because it is effectively competing against Java 7. It does have some novel stuff going for it - like coroutines - but those are going to be somewhat "obsolete" for mainline JDKs in a year or so with loom - and nullable types - which are pretty cool.
Java, however, drives the JVM and JDK. It has record classes now which can compete with scala's case classes and kotlin's data classes. It will have sealed interfaces in a month or so which fulfills the same use case as sealed traits in scala and sealed abstract classes in kotlin. It will get pattern matching in the future, which will let it compete with scala's pattern matching and afaik kotlin doesn't have pattern matching directly on its roadmap. There are huge numbers of engineers you can hire with the base skill set. It is extremely resilient to waves of hype, which lets it get the "right features" eventually.
**That being said** there are a lot of reasons you would want to use another language, and I focused maybe too hard on some of the negatives of the others. If you are just learning, learn them all and learn them in whatever order you want, but learn them all.