#prosvscons

The Pros and Cons of Using Java in Software Development

Portability and tooling weighed against speed and verbosity

Java is a widely used programming language, valued mainly because the same program runs on many different systems. It is object-oriented, ships with a large standard library, and has security features built in. It also has a reputation for using a lot of memory and for needing more code than some newer languages.

Below are the main points in its favor and against it, from the tooling around it to the cost of running on a virtual machine. They won't settle every case, but they are a reasonable place to start.

Pros

Several of Java's strengths come from the ecosystem around the language as much as from the language itself.

  • +1

    Platform independence

    A Java program runs on any system that has a Java Virtual Machine (JVM) installed. This is probably the best-known reason people choose the language. Developers can write their code once and run it on different operating systems, so they rarely need extensive rewrites or separate optimizations for each one. For teams that ship software to several platforms, that portability saves a great deal of work.

  • Rich standard library

    Java ships with a large standard library, a collection of classes and methods that covers much of what developers would otherwise have to write themselves. Data structures, networking, and GUI programming are all supported out of the box. Complex tasks become simpler and development goes faster. Because everyone builds on the same pre-built pieces, code also tends to be easier to reuse across projects.

  • Security features

    Java has security built into its design. Its sandboxing model limits what code is allowed to do, and the platform supports encryption and authentication mechanisms. Together these help developers defend their applications against common vulnerabilities. No language makes an application secure on its own, of course, but Java gives you a solid set of tools to start from.

  • Large community and support

    Java has a very large community of developers and users worldwide. Around it has grown an ecosystem of forums, online communities, and other resources. In practice this means that when you run into a problem, someone has usually run into it before and written about the solution. The same community maintains a wide range of libraries, and anyone new to the language can draw on the collective knowledge and experience of the people who came before.

  • Strong tooling and development environment

    The tools for Java are mature. IntelliJ IDEA, Eclipse, and NetBeans are integrated development environments (IDEs) that give developers extensive support for writing, debugging, and optimizing code. Tools of this quality tend to raise both productivity and code quality. That makes it more efficient to build Java applications and, just as important, to keep maintaining them afterwards.

Missing a pro?

Let us know which pro you are missing!

Cons

The drawbacks fall into two groups. One is speed and memory, and the other is the amount of code you have to write.

  • Performance overhead

    Compared with languages like C or C++, Java carries a performance overhead, and this is one of the most common criticisms of the language. Most of the overhead comes from running on a virtual machine and from automatic memory management. Java's performance has been optimized considerably over the years, but applications with very high computational demands can still run into limits.

  • Memory consumption

    Java applications tend to use a fair amount of memory, particularly next to languages where the programmer manages memory more explicitly. The Java Virtual Machine itself takes up space, and garbage collection adds to the total. On resource-constrained systems, or in applications with strict memory requirements, that can become a real concern.

  • Complexity and verbosity

    Java often needs more code than some modern languages to accomplish the same task. Critics call this ceremony: strict syntax and a lot of boilerplate before the actual logic shows up. Writing the code takes longer and the result is less concise. People also worry about what that means for readability, and for how well such code holds up over years of maintenance.

  • Verbose syntax and boilerplate code

    Closely related is the day-to-day cost of all that repetition. Writing long, repetitive code slows developers down, and every extra line is something that has to be maintained later. Beginners may find the learning curve steeper, since they have to work through a lot of structure before they reach the part of the program they care about. As the code grows, a verbose codebase also becomes harder to manage.

  • Limited performance optimization

    Portability has a price. Java runs on a virtual machine. Its just-in-time compiler turns the code into machine code while the program runs, which closes much of the gap with natively compiled languages, but startup time and memory use are usually higher, and there is less room to optimize for a specific machine. For applications with strict latency or resource-efficiency requirements, that constraint can weigh heavily when choosing a language.

Missing a con?

Let us know which con you are missing!

Conclusion

If your software has to run on several operating systems, will be maintained by a team for a long time, and benefits from ready-made libraries, Java's strengths count for a lot. If it has to run with tight memory limits or strict latency targets, a natively compiled language such as C or C++ is probably the better fit.

What do you think?

Do you think the pros outweigh the cons?