DEV Community

Cover image for Why I love Java

Why I love Java

Arik on October 23, 2018

Java is unarguably one of the most popular programming languages in the world today. Companies like Google, Amazon and Netflix -- to name a few big...
Collapse
 
bzitzow profile image
Brian Zitzow • Edited

As someone who has used Java, Ruby, Scala, PHP and JavaScript in a professional setting ... I chuckled a little bit when reading this. It has not been my experience that Java is productive. Quite the opposite, really. When compared to Ruby and JavaScript, the framework and libraries in Java are dismal.

Doing anonymous functions in Java is painful.

The same is true for concurrency.

Jave only recently got a REPL, with Java 9, and if you are working on an existing software platform, the chances you have access it Java 9 are small.

The JVM isn't bad ... But it's a memory hog, and I'm having a lot of fun and continually impressed learning about the erlang virtual machine. When compared to an imperative language, the JVM is definitely fast, so that's good.

You said you have used Java for the past 10 years ... I noticed you didn't compare it to any other languages, communities or development ecosystems...

Collapse
 
mechtecs profile image
Max Schorradt

Java 8 added anonymous / lambda functions, to easily define functions for e.g. EventListeners, without specifying a class and overriding a specific method. I cannot talk much about the other languages considering concurrency, but JavaScript is by default single threaded in the user code. Multi threading is a hard effort. Same goes for PHP, which when I wanted to try it last time, was just too complicated. Java supported concurrency for a long time now, but you had to manage and write the algorithms to be threadable. Now with Java 8 you can just use streams for simple algorithms.

Collapse
 
bzitzow profile image
Brian Zitzow

Java 8 did add anonymous functions. Unfortunately, bolting features like this onto Java results in a "yes we can do this, but it feels really icky because the language wasn't designed to support this. Not really." kind of experience. It's very noticeable for anyone coming to Java who has experience in a language that was designed to support lambdas.

While I haven't really used Kotlin, a quick web search comes up with examples that show it reduces the boilerplate code by 40%:

medium.com/androiddevelopers/from-...

Another disappointment (I have) with Java's implementation with anonymous functions is their incompatibility with Checked Exceptions. Again this is a result of Java adding features it wasn't designed to do.

Just 2 weeks ago I had to refactor some code a developer wrote with the Streams API and anonymous functions because we encountered a need to depend on code that relied on CheckedExceptions - and it wasn't practical or feasible to rewrite it at this time.

Java is an Okay language. My only point is that I don't find it "productive" or "developer friendly" compared to the other languages out there, especially the newer ones.

The other reasons listed in this article aren't targeted at me, because I've not used C professionally and had to deal with memory management in one of those older languages. That being said, the other newer languages on the market also handle this stuff - it's not a unique value add Java brings in the current market.

Collapse
 
bzitzow profile image
Brian Zitzow

"Multi threading is a hard effort."

I'll agree with that. If you're really interested in concurrent and fault tolerant systems Elixir or erlang are worth checking out.

The erlang virtual machine supports the actor model as a foundational design and is time tested. They both enforce immutable data structures as well.

Go and Kotlin also tout abstractions that make it easier to deal with concurrency.

As someone that uses Java daily, I'm just saying - I don't see it. I don't see why it's so special anymore. It was special and useful and productive at a certain time period, but in my opinion, that period is gone.

There are better Java's than Java and there are plenty of other alternative modern languages that are very well designed.

Collapse
 
dean profile image
dean

People give Java a lot of crap for it's verbosity. I started using Kotlin and began to love it's conciseness, and slowly started to hate Java for how verbose it was.

But then I started learning Go, and learned the value of verbosity. It really does make code more readable and helps you understand what's going on. I now have a greater appreciation for Java, and it's verbosity.

Collapse
 
differentsmoke profile image
Pablo Barría Urenda

Sometimes verbosity is necessary to express an idea with enough nuance.

Sometimes verbosity is not what we, in the modern world, would call a necessity or a demand but rather an unnecessary addition of words born out of verbosity not necessity, what one would call an unnecessary verbosity which truly adds nothing to the original idea, that of verbosity being unnecessary, meaning it is unnecessary verbosity.

Collapse
 
dean profile image
dean

Go strikes a really nice balance between verbosity and conciseness. Java, I feel, could be a little more concise... All the ByteArrayOutputStream outputStream = new ByteArrayOutputStream() is a bit much, but other parts, such as not having true "properties" (and rather fields), is actually nice in my eyes.

Thread Thread
 
tomlincoln93 profile image
Gáspár Tamás

You mean:
var outputStream = new ByteArrayOutputStream()

? :)

Thread Thread
 
dean profile image
dean

Some of the machines I use can't update to Java 9 since it broke backward-compatability with using Java internal libraries, esp if I want to use tools like jd-gui

Collapse
 
mohamedelidrissi profile image
Mohamed Elidrissi • Edited

I think it was on the StackOverflow survey's top 3 most loved languages by developers and that's not surprising at all, but I still like java because it was the first programming language I learned and it was a lot of fun to work with

Collapse
 
tomerbendavid profile image
Tomer Ben David • Edited

I love java, I used Scala, JavaScript, python, R, typesceipt, Ruby, haskell, closure, and more professionalky. Computer language is just a tool, the product, system is the main thing and where the real challenge compelexity lays.

Collapse
 
remify profile image
Rémi B

I can't love Java because of other languages. Java is good and it can do many things but it doesn't shine anywhere it use to.

Collapse
 
schreiber_chris profile image
SCHREIBER Christophe

On the subject of memory management, developers should be aware of how the garbage collector works under the hood, because it affects the design of the code. Not having to care about freeing memory doesn't mean you don't have to care about memory management at all ;-)
I've seen many projects having poor performance because of memory leaks, leading to garbage collector running constantly and even the server crashing because the GC couldn't free enough memory (if I remember well, this occurs when GC is running 98% of the time to free less than 2% of the heap).

Collapse
 
shaijut profile image
Shaiju T

😄, I used to have questions like which language is better ? After discussing with my friends and listening to people online, I realized that Its better to stop asking these questions. Instead start asking which tool is better for current Job and Trend.

Choose the right tool for the Job.

  • Based on your experience, you can use C# or Java for building enterprise and large applications.
  • Instead JSF you can think of using Anuglar orReactorVueetc. for Front End.
  • Python for Machine Learning.
  • Go for Micro Services based performant applications.

In future maybe today's Languages and Framework may be outdated, so to survive you will be forced to learn new language of that time.

Conclusion:

  • Developer Happiness, stick to the language which make your life easier, like easy to read syntax, maintainable, has Good IDE. I like C# for current work, and its up-to you to decide what you like.

  • Its always good to be Open to learn any language as required and Choose the right tool for the Job.

Hope this helps.

Collapse
 
differentsmoke profile image
Pablo Barría Urenda

I have never used Java, but this was something of a red flag to me:

To the uninitiated, this means that you design your code around unit of codes called "objects" which loosely resemble real-world object (or concepts).

I'm a self taught dev, and I REALLY struggled with understanding Object Orientation early in my career. I once came across an article on "worst advise rookie programmers get" and listed in it was that this idea that "Objects are like things in the real world".

I'm really not trying to be a hater, but reading that that was a bad way of thinking about objects was the beginning of my grokking object orientation.

Collapse
 
andevr profile image
drew

I'm recently learning Java after struggling for a long time to learn JavaScript. I chose Java over Kotlin because I wanted the best chance of getting a job with my first language (way more available jobs) while also positioning myself to eventually learn kotlin/android development if Kotlin eventually takes over or becomes more prevalent. Java has been such a joy to learn, I've made way more progress with it than I ever made with my early attempts to learn a language.

Collapse
 
acoh3n profile image
Arik

That's really cool. And I totally agree on all points. Java is a great choice career-wise because it's in very high demand. It is also a pretty simple language and not overly loaded with features -- which to some might seem as a shortcoming compared to other languages -- but personally, I think that its simplicity is one of the language's biggest strengths. Good luck in all endeavors!

Collapse
 
andevr profile image
drew

Thank you. I think the simplicity is part of what draws me. In a lot of ways JavaScript was very complicated, and the lack of exercises in 99.9% of JavaScript learning material aimed at completely new people is more a hindrance than anything. Java is definitely more my speed, and having multiple opportunities to practice has made it a much better experience.

Collapse
 
henry701 profile image
henry701

Java is not purely an Object-Oriented language. It's mixed. Still, i got the point.

No points there about Java are wrong, but what i found is that most of the other similarly-used languages get those points right better than Java 90%> of the time. And when people compare it to other languages, that's why it comes out bad.

When comparing Java to C#, for example, i found it outdated because there are many features that really make developing more productive and code cleaner and that are purely syntax sugar, but Java does not implement those at all.

Collapse
 
bertilmuth profile image
Bertil Muth • Edited

As a long time Java programmer myself, I fully agree. I have learned to live with the downsides, and appreciate the upsides, e.g. having a decent type system. Sure there are lots of other languages with that as well, but there are also languages with inexplicable type casts - IMHO that is not helpful at all, but a constant source of unnecessary surprises.

Collapse
 
emkographics profile image
Emko

Is the JVM still a pipedream or are you actually now able to write once run evwrywhere without having to tweak your code per environment?

Collapse
 
shryne profile image
Eugen Deutsch

If you are writing library management software, your software might have units like "book", but also a "Manager", "Controller", "Utils", "Helper" or a "Service". I still don't get, how a "Controller" is a real-life entity, but to be fair I am also not sure If I can blame java for that.

Besides, since you like Spring I wonder how you could say that Java is purely object-oriented. At least it gives Spring enough room to not be object-oriented - leaving aside whether you actually care about it or not.

Collapse
 
stealthmusic profile image
Jan Wedel

Fun fact: Java is not a pure object oriented language. int, float and other primitives are not objects. Moreover, objects actually should should not be able to mutate state of other objects directly (foo.bar = 3) but using messages (aka method calls).

In Python for example everything is an object. Numbers, strings, lists, functions, modules, code. Doing stuff like foo.bar = 3 actually calls a method in the background.

Collapse
 
orelzion profile image
orelzion • Edited

Ne, those same points are valid for kotlin too.
Actually aside from the Jvm these points are valid for almost any of the popular languages

Collapse
 
saint4eva profile image
saint4eva

Though I am a C#/ .NET developer, I concur with your article. Java is a powerful programming language/ platform, with a tremendous community behind it.

Thank you for your write-up.

Collapse
 
silverhusky profile image
SilverHusky • Edited

This is actually an excellent summary for Java one of my favorite.
More importantly this article give us a different perspective about its pros. Cool to save.

Collapse
 
saraalfred profile image
Sara Alfred

I personally like Java but as I am of not this field I am not having enough command in it. My UK based company also use JAVA for backend services. Thanks for sharing this motivating article

Collapse
 
acoh3n profile image
Arik

Thanks for the nice feedback

Collapse
 
srowles profile image
Stephen Rowles

Given what you like about Java you should try Go. I switched from Java about 3 years ago and haven't looked back :)

Collapse
 
parambirs profile image
Parambir Singh • Edited

The best part about JVM is the community. However, Java is an okay language. It's possible that people 'loving' Java are suffering from Stockholm syndrome! :D

Collapse
 
acoh3n profile image
Arik

or maybe they just like the language.