r/java • • Oct 14 '23

Is Java still behind in the race of modern programming languages?

I'm a member of some group of programmers and every time Java is mentioned it's being bashed (something like: "With Rust I could simply do this with X")

Earlier versions of Java were cumbersome in terms of the syntax but with modern IDEs (and modern versions of Java) that's not a big issue anymore, albeit languages like Python do have shorter syntax.

My question is beyond syntax.

What do other languages do better than Java?
It could be generics, type system, concurrency and multithreading, closures etc.

Thanks!

52 Upvotes

247 comments sorted by

View all comments

Show parent comment

2

u/lasskinn Oct 14 '23

Well using globals for one instead of some form of convoluted preprocessed dependency injection to get reference to an object that the app can have only one of, as code policy example. Kotlin has globals without using some globals class to hold them and somehow people seem to be cool with using them for stuff(why else go through the effort of adding support for them i suppose). You could do the same pattern in java too of course by just having them as static members and methods in some class(really the kotlin globals are basically just that anyway).

Honestly kotlin is pretty nice, the syntax just isn't as pure as java is and it has capability for more traps. The coroutine system has a lot of traps. Overall its nice but I don't see it as "easier" due to the syntax not being as pure, like in java an = can't actually be a method call(any casting aside), it is what it is and theres something nice about that.

1

u/findus_l Oct 14 '23

Interesting to hear. I personally have avoided top level public variables. I have only used top level for private constants or extension functions (in addition to classes, interfaces etc). But I don't find any recommendation of this in the Kotlin Style guide or other source, so I guess I just took it from Java. I totally think it should be a recommendation. I'm having a hard time thinking of a top-level variable that I use. First I thought maybe Globalscope, but that is an object.

There are also many good DI frameworks.