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 b... [Read Full]
markdown guide
 

Brace yourself. Comments from Kotlin devs are coming! :)

 

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

 

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

 

I just don't think they would pass on the opportunity to mention that Kotlin is better than Java. Just search for Kotlin on dev.to. In the last month there were at least 5 articles explaining how Kotlin is superior. Writing such an article seems to be a rite of passage for Kotlin devs.

 

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...

 

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.

 

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.

 

"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.

 

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.

 

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.

 

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.

You mean:
var outputStream = new ByteArrayOutputStream()

? :)

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

 

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.

 

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.

 

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).

 

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.

 

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.

 

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.

 

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.

 

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.

 

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.

 

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?

 

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

 

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

 
 

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.

 

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

 
code of conduct - report abuse