DEV Community

loading...

Discussion on: Goodbye, Java

Collapse
omenlog profile image
Omar E. Lopez

Fun article I also really dislike Java not for the same reason that you pointed because I never tried it outside of programming classes at the university. For me as developer who like functional programming Java lacks of expressiveness, I find very annoying and frustrating the requirement to declare a class for absolutely everything, also it's famous for be a very verbose language indeed the fact that I need System.out.printLn() for just print something drive me crazy, in summary isn't for me. But beyond all of this I really think that JVM is an amazing piece of software, indeed there are very good languages that rely on it, as examples we have Kotlin, Clojure, Scala ... JVM is a component that have been battle tested over two decades, in my opinion seem like many people came with the idea to use it and create a language that remove Java ugliness.

Collapse
siy profile image
Sergiy Yevtushenko

Yes, Java is verbose. But why do you assume that verbosity is bad? A lot of typing? Who types every single character in the code these days? In any Java IDE this is only 4 or 5 chars (in Idea it's just 'sout'). And there are static imports as well.

Java verbosity has another side: it provides explicit context and programmers' intent. Which reduces mental overhead and simplifies reading the code. Since most of the time we're reading code, this verbosity makes Java code simpler to support and maintain, especially in long run. This is the one of the reasons why Java found its place in enterprise world.

Collapse
omenlog profile image
Omar E. Lopez

Verbosity isn't necessary to reach explicit content and programmer's intent , indeed as example of this we have Python, many arguing that is very explicit and easy to read and without verbosity at all. In my opinion the fact that verbosity help to reduce mental overhead and simplifies reading code is debatable.

On the other hand verbosity on Java isn't restricted to just one line of code as I pointed with the sout example, is spread all over the language, compare this two snippets in java and kotlin

kotlin-vs-java

Really I don't think that you can address this with 4 or 5 characters in your editor.

OK if you like it use it, as you said, it found it's place in the enterprise world(not by it's verbosity), but anyway isn't for me.

Thread Thread
siy profile image
Sergiy Yevtushenko

I don't have to. Since Java 14 I'm writing such things like this:

public record Book(String title, Author author) {}

It even shorter than Kotlin version.

P.S. yes, there are still areas where Java needs improvement and it actually quickly improves with every new release.

Thread Thread
siy profile image
Sergiy Yevtushenko

And about Python. It's less verbose just because it does not require types. And lack of types (or dynamic types, for that matter) has it's own drawbacks. For example, reusing the same name for variable with different type complicates reading code and creates mental overhead.
Lack of static type checking also requires more careful testing, so in turn programmer needs to write more code to cover things which are handled by compiler in statically typed languages.

Thread Thread
omenlog profile image
Omar E. Lopez • Edited

Very nice this syntax for declare a new record, I didn't know about it, I'm really out of anything related with Java but nevertheless looks good.

Thread Thread
omenlog profile image
Omar E. Lopez

I mention Python but can be others using static types, anyway I think that types or not types are out of the scope in this thread :)

Thread Thread
siy profile image
Sergiy Yevtushenko

I did mean that referring dynamically typed language as an example of low verbosity is not completely correct. And yes there are languages with static typing and concise syntax, for example Haskell. After all, you already referred Kotlin, which also has more compact syntax than Java.