What is Java and should you learn it?

Eugene Lebedev
Javarevisited
4 min readJun 24, 2020

--

This guide is for everyone who’s thinking about learning their first programming language. If you’re a seasoned developer, you already know these things. Beginners, read on!

What is Java?

Java is a programming language. You use it to make software. Here are Java’s main characteristics:

  • It’s object-oriented. To harness its power, you need to understand the basics of object-oriented programming.*
  • It’s multi-platform. You can re-use the same code for multiple platforms and devices.
  • It’s kind of slow and wordy. It’s not suitable for low-level** and high-load tasks.***

*Object-oriented programming means that the programming language uses the idea of objects to represent data and methods.

**Low-level means that the programming language gets very close to the language of the machine itself, requiring little to no abstraction.

**High-load tasks are those that use most of the available resources for processing.

What is Java’s superpower?

Java’s superpower is JVM — Java Virtual Machine. To understand this concept, we need to take a step back.

Let’s say you want to write a messaging app. It will need to talk to the internet, output some text to the screen, and store some data on the machine’s hard disk. And you want your app to be multi-platform so that people can use it on Macs, PCs, and other devices.

But there’s a problem: Macs and PCs handle network, disk, and user input differently. You can’t use the same code for the two different platforms. You’ll at least have to re-write the code for the inputs, outputs, networking, and user-related stuff. And that’s only for two systems. What if you wanted that messenger app to work on a smart fridge? The more platforms you want to work with, the more work you have to do.

Enter JVM. Java Virtual Machine is exactly what it sounds like: a virtual container that imitates a computer with standard inputs, outputs, network, disk, screen, and more. In Java, you write code for that virtual computer, and then the Java compiler closes the gaps between the virtual machine and the actual hardware.

With Java, you still need to compile your code for different platforms. But now you can use the same code for all the platforms — you just change the compilation environment.

Let’s say you work for a wholesale company that has a huge warehouse. You get a task to write some software to help the warehouse workers keep track of the inventory. You write the code in Java and compile it to the devices that the workers will carry around — let’s say, a Windows-powered tablet. The software runs well for a year, and you keep it updated. Then the company switches to Android-based laptops. Okay, no problem. You compile your software to Android devices, and you’re good to go.

So, what are the downsides?

Java isn’t as fast as C++ or Swift. C and Swift are very efficient languages thanks to the fact that they run tightly with the processor and the operating system. Although these languages are pretty high-level, involving a fair amount of abstraction compared to the language of the machine, C++ and Swift don’t do a lot of redundant work.

So, you’ll get the benefit of speed with Swift- and C-based programs. But you’ll still have to deal with the fact that the code in C and Swift varies for different platforms.

Java, on the other hand, has its one-and-only platform, and it carries it around everywhere. Everything that goes on in Java has to first talk to the JVM, and then that platform talks to the computer. That’s why apps in Java are not as blazingly fast as one would expect. It’s not a big deal for consumer-grade desktop software, but for server solutions and high-load tasks, that difference in speed can be critical.

Java is pretty wordy. It just happened that way. Here’s some code in Python that draws some symbols on the screen:

Here’s the same thing, but in Java:

Java — is that like JavaScript?

Oh no. Those are completely different languages, built by different teams for different tasks. The similarities in the names are due to marketing wars and the hype that Java created in the mid-1990s.

Java is a compiled language for making software. JavaScript is a scripting language for building dynamic webpages — that is, webpages which display different content every time they’re viewed. Sure, you can build some sort of software with JavaScript, but JS’s concepts, structures, and overall workflow are fundamentally different from Java’s in many ways.

Who should learn Java?

Java is a lot of work. It’s not that glamorous kind of hipster programming language for the kids.

Here is when to consider learning Java:

  • If you want a long-lasting career maintaining the financial or industrial infrastructure of the world. A lot of the real-world stuff runs on Java, from ATMs and cash registers, to production lines. It will take decades to transition these systems to other technologies, and at this point, that transition seems unlikely.
  • If you’re into the Android ecosystem. Java is very widely used for Android development.

However, learning Java as your first language can be quite tedious. If you want to dip your feet into the programming pool, try coding some JavaScript that runs in your browser, or learn some Python. These two languages are good for different tasks, but both are suitable to be your first programming language.

Want to learn more about programming? Explore the educational resources on Practicum. We offer online education to help you learn new tech skills and amp up your career.

--

--