Everyone hates Java, even I did (once).
The memes, the videos, I mean literally everywhere there is spread one thing - java's popularity is declining...
I wondered why people hated it so much, to a point where people are even ready to buy merch out of it :P
So I decided on trying out java myself... <3
So why do people hate Java?
Java has been popular for decades. There's no such proper reason to hate Java, rather there are some things that prick many developers.
Java is VERBOSE.
Verbosity is a good as well as a not-so-good feature. Like it makes debugging much easier and reliable but at the same time, you gotta write a lot of code. Many beginner developers complain about this thing a lot - why do we just write 1 line in python and 7 lines in javajust to print Hello, World!
on screen? But they don't understand what both languages are meant to perform!Forced OOP
Java is a pure Object Oriented Programming language and it was designed specifically from the very start. Even if you want to execute small programs, you have to compulsorily wrap it into classes-object form, which doesn't make sense to many beginners or devs of other languages.Memory Hog Language
By its very design, Java is a memory hog. You simply cannot make a memory-efficient program that handles enormous data while still preserving good object-oriented abstraction in your program. This extra memory consumption doesn't matter if you are making a small-scale application. But imagine making a video editing application that has to handle gigabytes of data in real-time! That's just insane...
My journey with Java
When I first encountered java, I found that language so cringes to learn. I too had that mentality of why to write long code! Instead, just use python to make life simpler. But I was wrong, I didn't even know the differences between those languages and I was simply comparing them.
Languages are simply tools that help you craft your desired application. So it doesn't matter which language you're using until you build super-efficient apps that drive you more users at end of the day :D
I learned Java and saw enormous applications of it! Like we can literally build highly scalable and enterprise-level apps using java. The Netflix you watch uses java to serve content to you ASAP.
Instead of hating java, try it out once
I'm sure you won't regret learning it once you build some cool projects with it. All you can build is an android app or a desktop app for your windows pc. Are you a web geek? try out spring boot and make scalable backend apps with it!
Just have an end goal in your mind and start your development journey! You will soon stop comparing languages and use them wisely :D
I hope you have got some value from this article and if so, don't forget to share it with all your friends and colleagues. Because sharing is caring :P
Top comments (24)
Question is: why use Java, if C# or Kotlin can do everything it does better and with less boilerplate?
Don't know about C#, but Kotlin is not an alternative to Java in enterprise setup.
You might be having some POV right? I would love to hear that!
Why ?
There are more reasons, but even those listed above is enough to try to avoid Kotlin for enterprises.
Indeed great powers implies great responsibility... DSL and extension methods are valuable tools but should be used sparingly.
In Java because there is no extension methods and we can't define a function outside class, we must define a lot of util classes (*Util, plural classname) with their static import, I'm not sure it's better :/
IMO Kotlin offers interesting patterns to compensate some lacks in Java. But teams are free to define coding standard to avoid exotic code.
I'd rather say that all these are signs of poorly though out and inconsistent language. One laughable example is that code written with infix methods often can be made non-compilable by adding one more line feed.
Another (significant) disadvantage is that Kotlin encourages developer to write hacky, hard to read and understand code. Optional chaining and elvis operator are especially easy to abuse.
I'm not sure
user?.address?.streetName ?: "No street"
is weirder than
Optional.ofNullable(user).map(User::getAddress).map(Address::getStreetName).orElse("No street")
But I'm sure it's shorter :)
About infix notation, I'm not a big fan in everyday code but it can be handy for DSL. Again, great powers...
Your code is shorted for two reasons:
user
has typeString
, although for fair comparison it should have typeOptional<String>
User
internals). If you try to actually compose operations, your code will not look so short.You may try to rewrite code below with optional chaining:
For comparison, monadic version of this code looks so:
Just assumed User/Address were kt data classes / java POJO but Indeed callee could've been returned a Optional
Because companies are chilly ? π
In mine just replacing Java with Kotlin (keeping same framework, same supervision tools, same IDE...) is quite complex π
And has no sense. Kotlin "features" make keeping code clean and maintainable much harder, than with Java.
Lol.... Not sure if you're trolling , but in my experience it's exactly the opposite. Less code lines, using ADTs, powerful pattern matching make your code so much expressive and safer.
See my comment above.
yeah it's bit hard though
Simple, MS SQL and Window Server isn't free.
.Net Core may be mature now and it available on Linux
But migrate whole company infrastructure will not easy
I've been a Java developer for the past 7 years. Was even a C/C++ dev for another 4 prior to that. Yes, Java is a bit "hated", but it has some really good features and it evolved a lot in the past years. I heard many arguments against Java, like "it is slow" or "it uses a lot of memory" and I don't find them all true. JIT speeds things up a lot and Java is capable or working with big quantities of data without a problem. In today's age, hardware is cheap, engineers are expensive. I would rather pay 50$ more per month for a bigger instance, than pay a few thousand to try and optimize the code so much or use a more efficient programming language but with features or libraries that are not so widely available.
There is a reason why many web apps run on Java or JVM-compatible languages (Spring, Spring boot, Play), even high-profile ones.
Spring and Hibernate are two main reasons why Java considered "memory hog" and "slow". Applications built without these frameworks usually fast and consume reasonable amounts of memory.
Yes it's just that many newbies are scared of those class names. Even i was but then i dived deep into learning Java and found it pretty amazing!
Most of the reasons you cite:
More than that, there is no reason to hate almost any language: every language has its history, its ecosystem and its peculiarities. There is a problem only when you can't choose a language that is better suited to the job you have to do.
Moreover, Java has a very, very solid and high quality ecosystem, that is tamper-resistant by design: it is very, very hard to publish a java library that contains malicious code and getting away with it, because it is very difficoult to publish something on Maven Central without giving them a really good idea of who you are.
So, there are many jobs and use cases where Java is an excellent choice, and a pleasure to work with. And there are other options (Kotlin, Scala, Groovy) if you want to access the same ecosystem but want less OOP, more FP or simply less syntax.
Just keep on codin'!
Yeah, pretty much. Java has already realized that the world has moved on, and it has started to move on as well. The new features are so beautifully functional. It's great that Java is taking a few pages from the C# book. Though even with said features, I'd pick kotlin over java any day.
The problem, though, with any mainstream language, that is widely inferior but impressively improving, is adoption. The deed has already been done. The industry is mostly bound to the ugly chains of Java 8, and not many of them are going to upgrade.
More recent surveys paint a slightly different picture: Snyk JVM Ecosystem Report 2021 Finds Increased Usage of Java 11 in Production.
It looks like 11 has already surpassed 8 in production. And everone is waiting for 17.
Maybe they are waiting more for the JVM than the language, but Java remains an approachable and solid solution for many use cases and many teams.
Yeah you are absolutely correctππ
Try functional style with Java and you will see how concise and expressive Java could be.