DEV Community

Discussion on: Why I love Java

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.