DEV Community

Cover image for Pitch me on Java

Pitch me on Java

Ben Halpern on May 19, 2022

Continuing the series! Feel welcome to dip in and weigh in on a past question.

Let's say I've never used Java before. Can anyone give the run down of what the language does and why you prefer it? Feel free to touch on drawbacks as well.

Collapse
 
kithminiii profile image
Bhagya

Pros of Using Java:

  • Simple
  • A Secure Language
  • Cheap and economical to maintain
  • Platform-independent
  • Java provides an efficient memory allocation strategy

Cons of Using Java:

  • Slow and Poor Performance
  • Poor GUI
  • No backup facility
  • Significant memory space required
  • Verbose and complex code
Collapse
 
siy profile image
Sergiy Yevtushenko

Java is not slow.
Java is not for desktop apps.
Java is reasonably verbose, which makes support and maintenance of long-living projects much simpler. As a consequence, Java dominates enterprise software development. Needless to say that it means virtually infinite number of jobs, constant high demand and great salaries.

P.S. Java is very expressive and simple language with very straightforward, consistent and well thought out syntax.

Collapse
 
leob profile image
leob

"Slow and Poor Performance", "Poor GUI", "No backup facility" - are you talking about Java on the desktop? (applets, swing, JWT) ... that's a disaster, and always has been, but Java on the server is a different story, it'd well-respected.

(scalability and memory management of the JVM in server environments are arguably strong points ... verbosity of the language remains an issue, but you can use other languages on top of the JVM)

Collapse
 
bigbott profile image
bigbott

Slow and poor performance? Where is it came from?
Compared to which language? JavaScript? Python? Ruby? PHP?
Do you have a benchmark?

Java is among fastest languages. For some tasks it is comparable to C++. With much simpler memory management.

Verbose - yes, but it is feature. All your fancy JavaScript oneliners should be well commented to be understood. Java code that follows conventions is self explained.

Writing GUI is not simple in Java, but it is possible. Check Eclipse and Netbeans. Those apps are among most complex GUI applications you ever seen and they written entirely in Java.

Collapse
 
thexdev profile image
M. Akbar Nugroho

Apache Cassandra is written in Java and it's fast 🤷‍♂️

Collapse
 
scottshipp profile image
scottshipp

Java is a great language to learn and use for the following reasons:

  • It is one of the most widely-used languages there are, consistently placing in the top three most popular alongside C++ and Python

  • It powers most of the major web apps you know--everything from Twitter to Google Maps to eBay

  • As a result, it has a huge ecosystem of open-source libraries and frameworks around it. You can leverage the advantages of widely-used and well-maintained libraries for every kind of programming task imaginable from concurrency to testing (caveat: this also means you can experience analysis-paralysis about which library/framework to use to accomplish a task)

  • It has great performance and scalability, particularly in web services and applications (caveat: it is slow to load and does not support autoscaling as well as a language like Go)

  • Java is always backwards-compatible, even across major versions, so code that was written twenty years ago can (and does) still do its job today (caveat: this sometimes means it is slow to adopt modern language features or does so in unexpected ways)

  • A real advantage of Java is not the language itself, but the Java Virtual Machine. The JVM both allows Java to run atop any underlying hardware (you can run Java on your phone or your microwave, for instance) and allows you to use wholly other languages like Clojure, Kotlin, Scala, etc. in case you prefer a different idiom (functional, for example)

HIH

Collapse
 
stealthmusic profile image
Jan Wedel

I can only second that. Performance is actually very good, in fact it outperforms natively compiled C++ code in many situations as the hotspot VM aggressively optimizes at runtime.
Also I don’t understand what „backup facility“ means.

Collapse
 
taijidude profile image
taijidude • Edited

Pros:

  • Lots of jobs - a lot of companies use java
  • Performance - javas bad reputation is not really justified. Sure, it's slower than c or c++ but it outperforms python and Javascript, and php.
  • Lots of stable libraries
  • Static typing
  • Under active development with some big companies behind it.

Cons:

  • Verbose
  • Standard Libary could be better
Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

Verbosity is not a bad thing. There is no behind the scene magic, which means you are in control, and can optimize code and its performance. Also in large enterprise, verbosity is encouraged because it will make it easier for the next guy who will replace you, to understand what is happening in code. Some companies even have code guidelines that prefers you to not show-off your special tricks and stick to basics.

At beginners level, With verbosity, you will learn concepts at a great details because you have to write every step of that concept. Every line of code that you write, you will ask yourself "have I covered all edge cases"

At intermediate level, your IDE will take care of a lot of stuff for you, You will have learnt the reason for any line of code you have written. So you will create generic snippets, and write a lot more code by writing a lot less.

And once you reach advance level of skillset, you will look beyond IDEs, You will use libraries like project lombok to replace boilerplate code with rich annotations. You will embrace annotations because you know what code compiler will generate based on those annotations. You will play with different JVM flags to optimize bytecode. All because you have a clear understanding of code that was verbose.

Collapse
 
tobhai profile image
Tobias Haindl

It is a robust and solid programming language.
You can build web APIs, Android applications and even GUIs with it.
The ecosystem is great and very mature!
There are well maintained libraries for nearly every use case.

Collapse
 
leob profile image
leob

Probably what you abhor is the verbosity - that got quite a bit better with the most recent version(s), but still ... there's also a culture in the Java world of being in love with 'patterns', with layers upon layers upon layers, and with over-engineering in general ... I worked with Java for a long time, but for me moving to other languages and ecosystems was a breath of fresh air.

Collapse
 
liamjoneslucout profile image
liam-jones-lucout • Edited

You've really hit the nail on the head here. I'm working with a Java dev on a Typescript project at the moment and he's really struggling to get out of this mind set. Especially wrapping everything in a class

Thread Thread
 
leob profile image
leob

Yep ... :)

First thing he needs to do is forget and unlearn the heavy OO baggage, and throw that thick "patterns" book (the infamous "Gang of Four") out of the window ;)

Collapse
 
codewander profile image
Kanishka

test induced design damage

Thread Thread
 
leob profile image
leob

Lol and that is? TDD (if that's what you mean) is generally a commendable technique, it's not necessarily the reason why all of the Java software got so complex, it's more the mindset that everything needs to be infinitely generalized and abstracted to death, even when there's no reason to do so.

Thread Thread
 
codewander profile image
Kanishka

dhh.dk/2014/test-induced-design-da... - that was the article that got me thinking that hexagonal architecture, which I first encountered in reading about java (and scala) patterns, was part of a pattern of over engineering in some circumstances.

Thread Thread
 
leob profile image
leob

Ah right, interesting article ...

The problem is the misconception that all tests must be "unit" tests in a pure sense - no database, no I/O, only calculations ... that's of course nonsense and impractical, and that's not what TDD says.

If you accept that a large part (the largest part) of your tests just execute web requests (but without talking to a real web server over the network), and use a (test) database, then TDD can still be applied perfectly well without having to use Hexagonal or such extreme stuff.

So I'd say don't blame TDD, blame people who don't understand how to implement it in a practical way. Oh and Hexagonal Architecture is cool and interesting, and very relevant ... for less than 5% of all apps/systems ;)

(the 5% is almost certainly an exaggeration)

Collapse
 
michaelfmnk profile image
Michael Fomenko • Edited

Pretty much every problem in Java has already been solved.

Literally, for every possible problem, there is a tutorial, library or research.
Anything from wrappers for some esoteric legacy protocols, to using existing C++ libraries.

Java is pretty much a 34 rule of programming. If some problem exists, there is a Java solution for that.

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

Java is pretty much a 34 rule of programming. If some problem exists, there is a Java solution for that.

This is so true, it made my day. 🤣

There have been many times, when I was working on PHP, or Node, I was stuck and closest thing I found was a java solution. It is easier to understand because of its verbosity, and convert that solution to whatever stack I am working on.

Most recently, I was working on a Golang project, and was stuck trying to refactor a very large module. I found an article on DZone about a similar example, I printed out the code, and implemented the structures based on that. Now my teammates are piggybacking on the improved package I wrote.
Funny thing is that this is the first time I am working with Golang, in a job. I have just learned Golang last year, and basically made a few contributions on various oss project on github. But my team is very happy to work with me, all because of Java.

Collapse
 
fnh profile image
Fabian Holzer

Disclaimer: I am a card-carrying member of the Boring Technology Club and my pitch might sound a bit like "nobody gets fired for buying IBM", but Java is a total work-horse.

It is not pretty. It is not best in class. But it is solid and has you covered. But you can draw from a vast pool of resources, have plenty of software engineers with experience to hire, there is an abundance of libraries. Its ecosystem is mature. All the stuff that makes you productive is in place.

I build software for hospitals for a living. I like to sleep well. I use Java.

Collapse
 
michaeltharrington profile image
Michael Tharrington

@goyo I'm calling you out! I know you got some thoughts on this topic. 😀☕️

Collapse
 
goyo profile image
Grzegorz Ziemonski

Well, a lot has been said here already but I'll chime in.

Java, especially the newer versions, is a very good language for server-side applications - it's fast, reliable, has powerful tooling and libraries, and virtually every question you may have has already been answered online.

On the other hand, it is not the most sleek language so if someone really cares about punctuation or the number of characters they have to write, they may be put off.

The language is ubiquitous among enterprises, so it's a pretty solid bet if you want to get a job or switch companies. It also means you're likely to work with enterprise applications and deal with complex business issues. IME, if you're biased towards solving interesting domain problems, you'll be happy doing it with Java (and probably any other language). If you're more biased towards doing cool technical stuff, you're probably going to look for something else.

Personally, I'm in love with Kotlin and I see it as an obvious replacement for Java, as they work in the same ecosystem.

Collapse
 
codewander profile image
Kanishka

I have been trying to find statistics on Kotlin backend adoption. I don't have a good way of measuring it right now. I see it occasionally in backend job descriptions. I suspect it will take over java marketshare, but not sure.

Collapse
 
stealthmusic profile image
Jan Wedel
  • It’s a very good language for backend web applications (because of libs, frameworks and static type system)
  • It‘s ecosystem is very good (libraries, support, testing like junit, testconteiners, spring integration tests etc)
  • it’s constantly evolving with new features while keeping backwards compatibility

If you’re into something longer, I wrote about it here…
dev.to/stealthmusic/java-is-dead-l...
…and here…
dev.to/stealthmusic/modern-java-de...

 
leob profile image
leob • Edited

I've worked at a company where they had a gazillion tests and still the codebase was a disaster, lol ... use any great theory or technique in a wrong way, and you'll still suffer ... in many cases it's just about people needing to take their blinders off, and get out of their dogmatic mindset

 
leob profile image
leob

Oh yeah that bothers me as well, the incessant urge to overcomplicate everything ... I'd want to say to the average Java dev, can we just do "KISS" for once, the simplest thing that works - but no, the thick Patterns bible (GoF) is never far away, because everything MUST be abstracted to death ...

 
leob profile image
leob

Right, it's 100% 'YAGNI' ... I don't know what it is, probably it's just that people want to show off, they want to make sure that everyone knows that they've read "the book" ;)

Interestingly, this runs anathema to TDD - because TDD teaches us to implement "the simplest thing that works", AND because TDD provides a safety net that allows us to implement that pattern or that abstraction if and when we need it ...

TDD is sound and solid practice, the over emphasis on complex OO modelling is not.

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

If you learn Java, you will become a good developer in any technology stack you want. It is strict, verbose, has a fixed way to do stuff. It has strict guidelines about coding styles. All these extra lines of code that you type to configure things, the lack of behind the scene magic, will enhance your concepts to a point that it will become a second nature for you. And then, when you work on any other tech stack, these basic skills will become foundation of your work.

In India, recruiters prefer students with java background, Not necessarily because they work on java stack, but because they know that these students will have a clear concepts, and can easily learn to work on any stack they are provided with.

I have personally experienced, that students who just learned nodejs, were not able to architect their apps in a scalable manner, Few of them don't like typescripts because they think strong typings doesn't have much benefits. They have excellent understanding of JS, and their frameworks, but can't transfer their knowledge on other stack if needed.
The students who had java as their background, it was their second nature to know how to split code into meaningful, reusable modules. They name their functions in a meaningful way. They write docblocks. And they can easily transfer and translate their skills to any stack they are given to work with. Node, PHP, Go, Dotnet.

Collapse
 
codewander profile image
Kanishka

My random impressions:

java community - bureaucratic over engineering
python, ruby, node community - under engineering
go community - enough engineering

clojure, scala, haskell, rust, elixir - more elegant, enough engineering

Collapse
 
dagnelies profile image
Arnaud Dagnelies • Edited

If Python is a car, Java would be a truck.

IMHO it's not made to make small programs and toy projects. It adds to much overhead for that. However, as the codebase grows in complexity, the benefits will come back more and more. It's something you want to build something big, large that will still be running in ten years.

Cons:

  • overhead
  • Oracle's stewardship catastrophic
  • Java Libs often lack simplicity
  • has some quirks

Pros

  • robust type system
  • one of the biggest ecosystem
  • high performance
  • good backward compatibility history
  • mature, large community
  • the language itself is overall rather sound
  • powerful IDEs
  • perfect auto completion with inline docs
Collapse
 
codewander profile image
Kanishka

Oracle's stewardship catastrophic

From what I understand, golang wouldn't exist if it wasn't for this disaster.

Collapse
 
dukemagus profile image
Duke

Can i do a half-pitch?

Learn enough java so you can read and understand it, then learn Kotlin to write your own tools.

Java is verbose and clunky, but it has decades of tools, programs and libraries done and availiable, most of them open source.

Since Kotlin can use any java library and compile to JVM bytecode, you keep access to all the millions of developer hours Java accumulated while still using something lean and concise to write your own code

Collapse
 
gjorgivarelov profile image
gjorgivarelov

Ok Ben, let's say you've never touched Java. Which may imply you are an aspiring developer looking for a way to prove your competency. Java provides that pathway to proven competency by its certification series. You study and take an exam, you pass and hang a badge on your social media profile. You become proficient and build a portfolio. And then you showcase it to potential clients. Proof of competency taken care of.
You also learn object oriented programming. You learn about code reuse, inheritance, polymorphism which may be a novel approach to developing applications to you as an aspiring developer. Many educators of Java programming make their case for Java by comparing it to its predecessors C and and C++, so you get to learn about other languages along studying Java.
Number of job openings for Java developers might be an incentive to you as an aspiring developer to take the path of learning Java.
I will deliberately skip on arguing for Java on a technical level, that discussion won't have an end/conclusion. Pick a tool that'll do the job, and if Java can do it or if you are paid to use Java to do that job and you already are an accomplished developer with expertise and experience under your belt, nobody would have to pitch it to you.
Now for those of us learning Java just because, its platform-independence feature might look appealing. Execute the same code on either Mac, Linux or Windows, that may draw you in. Java, just by the fact it has been in use for so long, has built itself a steady following and a ton of documentation, it has been around for decades. Plenty of how-tos on the web regarding Java, if that is your chosen path to learn Java. Which then begs the question: once you think you get proficient with Java, what's the next step? Multiplatform feature has much less of an appeal now with the prevalence of cloud computing and the clear win for the platform agnosticism. Use Java for web apps like ye olden applets? Many other tools now exist much better suited for that task. Data science? Again, much better suited and better built tools exist for that field. IoT? Embedded systems programming? Those are yet more dead ends for Java.

Collapse
 
rickdelpo1 profile image
Rick Delpo

Hi there fellow Devers.

I wrote a must-read Dev article recently on why we should all learn Java

click here at dev.to/rickdelpo1/why-would-i-want...

highlights

  1. we can learn just a little bit of Java
  2. it is a segway to SQL (acquire 2 skills by studying 1)
  3. beginners can be educated on REST api and JDBC quickly (fundamentals of request, response, get, post and hosting)
Collapse
 
ant_kuranov profile image
Anton Kuranov

Pros

  • Type-safe: design and modelling, compile-time errors, IDE support, etc
  • Huge ecosystem: frameworks, tools, libraries, documentation, support, etc...
  • Reliable: developed and supported by industry-leading companies
  • Fast and stable on different workloads
  • Still in top of jobs vacancies
  • Medium entrance level => (mostly) experienced engeneers in your team

Cons

  • Oriented mostly to backend development, almost is not presented on frontends
  • Not so modern and contains a lot of legacy stuff, however the language is still now in active development of new features
  • Verbose: standard design patterns require a lot of boilerplate code
  • Memory consumption (there comes some optimizations like project valhalla)
  • Slow startup and "heating" time (may be critical). May be solved withcompilation to native code.
 
bigbott profile image
bigbott • Edited

You don't have problem with Java alone, but with English and languages in general.

Sentence: "I don't think it's performance is bad compared to other interpreted languages." states that you think that Java is interpreted language.

 
bigbott profile image
bigbott • Edited

Ok. Let me give you kindergarten level example.

I think that Ferrari is fast compared to OTHER bicycles.
Word OTHER here means that Ferrari is a bicycle. Otherwise, it completely redundant.
I hope you finally learned something.

Also, you don't actually need to think about Java performance. Just check some benchmarks. For example: github.com/kostya/benchmarks. You will see that Java between fastest and for some tasks Java is the fastest language. And its main competitors are C, C++, Rust and Go. Are those interpreted in your opinion?
You will also see, that comparing Java to interpreted languages like Ruby, Python and PHP is meaningless as its performance usually ten times higher.

Opinion that Java is slow comes exclusively from "new language of the day" propagandons and aimed into idiots who tends to believe everything they read more than once.

Collapse
 
sherrydays profile image
Sherry Day

It seems like a good professional choice to know Java.

Let's say your a Python developer — Ruby probably won't expand your skills and professional opportunities that much, but Java likely will on both fronts.

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

I never coded in Java but used many internal developed Java softwares and every single one was slooow. We had the same app later rebuilt with Electron which was fully written in JavaScript/Node and it felt like 50 times faster.

Thread Thread
 
siy profile image
Sergiy Yevtushenko

Slow apps could be written in any language. Java is not an exception.

Thread Thread
 
leob profile image
leob

Those "internally developed Java softwares" were likely desktop apps ... let's be frank, Java on the desktop (applets, JWT, Swing and all that) sucks ... do not, I repeat do not, use Java on the desktop - should only be used server side!

Thread Thread
 
abhinav1217 profile image
Abhinav Kulshreshtha

@ivanjeremic

We had the same app later rebuilt with Electron which was fully written in JavaScript/Node and it felt like 50 times faster.

If you think electron was faster, you can't imagine the performance of tauri, or webview.

I have worked on Java desktop app. They can be really fast if you compile it for production, which uses compiler optimization flags. Yes startup time can be slow in some cases, but JVM has been improving a lot in past few years. Memory footprint of J9 is also in league of its own.
It also depends on framework used, In my experience, If animations are avoided, Fx is really fast, compared to swing. That said, Swing is really performant library. Eclipes IDE uses SWT which is built upon on swing.

Thread Thread
 
leob profile image
leob

Good to hear a bit of a different view, the huge amount of bashing that Java gets (often not based on actual knowledge) can be tiresome ...

Collapse
 
atulcodex profile image
🚩 Atul Prajapati 🇮🇳

Sorry Ben, but be honest I don't know much about Java so I can't pitch anyone for this 🤘🙏

But use your own curiosity and do some research, internet is overloaded with information's 👍

Happy journey 💞💜

Collapse
 
leob profile image
leob

Sorry but it's not an "interpreted language", not by a stretch ... it uses a JIT compiler, once a piece of code (class or method) has been JIT-compiled it essentially runs almost at C/C++ speed (well, with still some runtime overhead in the form of garbage collection and all that).

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Pros:

  • fast
  • much tooling, big ecosystem, especially for enterprises
  • suitable for big projects
  • brought us the JVM (which now is the base for many more languages)
  • tiny native binaries with little memory consumption are possible

Cons:

  • its OOP approach has spoiled so many developers
  • verbose syntax, especially for some creational design patterns
  • sometimes still memory-hungry
  • trademark is owned by Oracle
  • desktop app development is problematic (e.g. several competing UI toolkits)
  • java-in-the-browser once was a thing, but has died
  • take a look at Kotlin, it might be the better java
 
leob profile image
leob

Right, well then you know it's not in the same league :)

Collapse
 
siy profile image
Sergiy Yevtushenko

Java is Just-In-Time compiled language. It's performance comparable or even better to compiled languages like C or Rust.

Thread Thread
 
ivan_jrmc profile image
Ivan Jeremic • Edited

I know that JavaScript is a JIT language it is comparable but not faster it can however have a few areas where it is as fast as compiled or faster, but most of the time just comparable.

Thread Thread
 
siy profile image
Sergiy Yevtushenko

JS as a language has some specific (variable type may change at run time, for example), which makes efficient JIT compilation somewhat tricky.

 
leob profile image
leob

Spot on ... Smalltalk (what I've seen of it) is brilliant, it's OO as it was intended to be :)

Collapse
 
calinzbaenen profile image
Calin Baenen

Minecraft is made in Java therefore Java good.
Minecraft skapades dessutom av en svensk, så vi borde tala svenska.

Collapse
 
bigbott profile image
bigbott

Kindergarten here.
When Java became interpreted?
Go to school, take some lessons.

Collapse
 
s2rgi0 profile image
sergio

One of the pros could be that if a senior developer leaves you can almost get anybody to continue the proyect

Collapse
 
drozdodo profile image
Dominika Drozdova

Hi All! I am recruiting for Java,C# and C++ roles fully remote if anyone is seeking a new role or looking currently!