DEV Community

Cover image for Is Java Still Worth Learning in 2022?
Elliot Brenya sarfo
Elliot Brenya sarfo

Posted on

Is Java Still Worth Learning in 2022?

Java, is it worth learning today, especially with all the new emerging programming languages? I like to evaluate decisions like this by listing out the pros, and cons, comparing them.

Image description

People always ask me, what ID I use for Java and I use IntelliJ which is developed by Jet Brains and I love their products. Java, it's a high-level programming language developed in 1995 into one of the most popular languages in the world. It's open-source, it runs on pretty much every operating system that's used to build everything from Android apps to server networks to video games. So Needless to say, it's a very powerful and merciful language, so let's start with the pros.

Java embraces object-oriented programming. It was basically a rebuild of C. However, with C, they basically took C and slapped the ability to have classes on there. This made this syntax and just the overall feel of using classes. Plus, kind of awkward Java was built from the ground up with classes in mind. Everything is an object and it's just an overall cleaner implementation.

So why is this a good thing? Well, it allows developers to easily reuse objects and their programs. It helps just the overall maintenance of your code.

The second thing is its platform independence. There's a famous saying in Java writing. Once, run it anywhere. Java runs on top of a virtual machine which is called Java virtual machine or JVM. So as long as the JVM is installed on a machine, you can run Java code. So you can write and run your code on a windows machine take that same code, run it on Mac or Linux, and really technically you can just take the bytecode which is compiled Java code and run that on the JVM running on any machine so you don't even really need the original source code.

With Java, you also get automated memory management. Now if you're coming from a language like Python, you're going be like what's the big deal, but if you're like me. In your first language, was C++. This is an amazing feature.

So, what does this mean? Well, if your program is running, you might need extra memory in a language like C. Once you're done using that memory, you need to deallocate this pace back and forgetting to do this will cause memory leaks in your program.

In a language like Java, once a chunk of code is no longer referenced, there's something called a garbage collector that runs and will automatically deallocate that for you.

So, the automated memory management just adds an extra safety net and just let it upset you have to do it manually. Java has built in support for multi-threading. This means that you can have multiple threads running concurrently.

A thread is just a unit of a process that can perform an action and the fact that Java has this built into it and in my opinion built into it very well. It just gives it a huge advantage over other languages.

The last Pro is that it's a very mature language. Java has survived for a few decades now. It has a great community. It's backed by Oracle, and they've really kept it up to date with features of competing languages like C Sharp and Kotlin.

It seems like when one of these languages come out with a new feature and the next Java update, they've you know build something similar and the Oracle website has some of the best documentation I've seen for a language, frameworks and libraries have been very well tested, and it's a language that's just probably going to be around for a long time.

All right? So those are the pros of learning Java. Let's take a look at some of the cons.

The first con is that it's losing popularity now, although it is such a widely used language, I do believe that its popularity will start to decline slowly over the years.

Now it's not something that's going to happen overnight, but you know you still you have a lot of newer languages that are coming out. Like Go and rust that are getting popularity.

Then you think of Android with solely using Java and now they're moving away to start using Kotlin. Stackoverflow developer survey from 2017 and 2020 we see in 2017 it was the third most popular language 2020. It was went down to 5th now although it is slightly higher like half a percent.

We see the other mainstream languages like JavaScript went up from 62% to 67%. We see Python from 32 to 44%, so even though it went up by half a percent, I do kind of see it kind of like, you know, reaching its peak, and I feel like it's going to start declining over the years.

The next con is that it's a very verbose language, meaning you have to write a lot of code to do a little for. Both languages are meant to be very like declarative, and it's supposed to be very clear what you're doing. But in my opinion, it makes the code a little bit cluttered and actually harder to read, and it may not seem like a big deal to you know. Because you're just typing a little bit more, but if you're writing Java code like all day, every day, it can get quite tedious and honestly, a little bit obnoxious, especially when you compare it to a language like Python.

Java is a slow language. Remember how I mentioned Java runs on a virtual machine? Well, this layer of abstraction slows things down. Virtual machines act as an operating system running on top of another operating system, so there's a lot of overhead there, but further away this software is from the hardware. The slower the performance, especially when you compare two languages like C which is very close to the hardware.

Anything where you need real-time operations like online gaming or like cars operating system. Java just isn't really going to be a good choice for that. We also mentioned the garbage collector well when that runs, your entire program suspends, then the garbage collector runs, and then the program resumes. Now, this is only a fraction of a second.

Users really aren't going to notice it, but again, if you're really looking for a speedy application take a slight performance hit.

Conclusion

So with that being said, is Java still worth learning today now you know? Obviously depends on what you're looking to get into. But in general, I still think it's a really good language. There's still a huge community behind it. Obviously, it's backed by a massive company like Oracle, and obviously, Oracle isn't going anywhere anytime soon. I think it's just a great language to pick up whether you're a beginner learning your first language or just more experienced developer looking to add to your toolbox.

Top comments (33)

Collapse
 
jwp profile image
John Peters

No, C# is far superior, fast, and runs everywhere. It even can become WASM. If Android didn't exist Java would have become much less popular. I programed in Java for 10 years and C# for 15. .NET is just a superior platform with the best 2 IDEs on the planet.

Collapse
 
miguelmj profile image
MiguelMJ

Companies still use Java and still need Java developers. So no matter how modern, lower maintenance or enjoyable other languages are. That fact alone makes it worth learning for a lot of people looking for a job.
Should companies migrate all their Java code to other language? I don't know. But that's not going to happen this year, so...

Collapse
 
nibelino profile image
Matteo

Also kotlin and dart... Basically all the new languages with a modern design

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Kotlin with Quarkus for web dev is extremely good too.

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Yes but dart has upper hand as compared to kotlin

Thread Thread
 
nibelino profile image
Matteo

What do you mean?

Thread Thread
 
elliot_brenya profile image
Elliot Brenya sarfo

Dart is widely used as compared to kotlin

Thread Thread
 
nibelino profile image
Matteo

I only see dart been used with flutter... But idk. Kotlin is the "substitute" of java in the android dev world

Thread Thread
 
elliot_brenya profile image
Elliot Brenya sarfo

Alright

Collapse
 
gaming_gamer profile image
Gregor-code

I think it is worth learning. When I started learning Java, I was kind of overwhelmed and thought there were way better alternatives. But now after I learned enough to create my own projects, I have a totally different view on it. I think there are a lot of programming languages that are easier and better, but the concepts I learned to use, are worth way more than the knowledge of one language. I instantly was able to understand Dart and Kotlin syntax and concepts.

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Ok

Collapse
 
noviicee profile image
Anamika

Java might be old, but I think it's still worth learning. Although I'm better at Python, but many projects still use java as their base.

Collapse
 
alekseiberezkin profile image
Aleksei Berezkin • Edited

Java is slow

Seems you've read 90s articles 😉 Please study recent benchmarks. Java is order of magnitude faster than interpreted languages like JS or Python. Contemporary Java 17 is still very good and balanced solution for data intensive systems.

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Okay

Collapse
 
mirkoperillo profile image
mirko

Yes it is. The last versions of Java (11 and above) modernize the language.
Don't think about the "old" Java, give it a try

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Ok

Collapse
 
ibrong profile image
iBrong

bro why c#, i heard my senior recomend c#, but i not sure why!

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

C# is well organized as compared to Java

 
romeerez profile image
Roman K

You're right! I'll spend more time waiting for build because I care a lot of type correctness and I won't get any null issue to debug, and I wish it to everyone.

Thread Thread
 
elliot_brenya profile image
Elliot Brenya sarfo

You’ve a point

 
elliot_brenya profile image
Elliot Brenya sarfo

You’ve a point though

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Yhh

 
elliot_brenya profile image
Elliot Brenya sarfo

Interesting

Thread Thread
 
rxliuli profile image
rxliuli

tsc is probably one of the slowest compilers out there, but now you can try esbuild, which is written in golang and can improve performance by an order of magnitude or two.
esbuild.github.io/

Thread Thread
 
romeerez profile image
Roman K

tsc can be very fast if you configure it to use SWC, which is written in Rust and doesn't perform any type checks just as esbuild

Thread Thread
 
rxliuli profile image
rxliuli • Edited

swc is an interesting project, but it has not been proven at scale in production environments, compared to esbuild as one of the cores of vite that is used at scale and proven effective.

Also, esbuild does not check typescript types

 
elliot_brenya profile image
Elliot Brenya sarfo

Obviously but I think you didn’t read the article

Collapse
 
elliot_brenya profile image
Elliot Brenya sarfo

Ohk

Collapse
 
romeerez profile image
Roman K

JavaScript, c#, python, and Go are all better, more enjoyable

Is it really good to assign null to anything? Is it enjoyable to debug such silly mistakes?

IMO allowing string = null means a poor language design, so TypeScript and Rust are better options for me than the four you mentioned.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.