DEV Community

loading...

Discussion on: Goodbye, Java

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.