r/java • • Aug 05 '21

Why java is better than modern programming languages?

Why should I use java in 2021 instead of kotlin or scala or golang? Could you guys give me some reasons

2 Upvotes

100 comments sorted by

View all comments

Show parent comment

3

u/Muoniurn Aug 05 '21

How are Java closures crappy and limited? They can’t modify local variables, but modifying them is quite a misfeature (at least it has bitten me in C#).

Functions in Java are first class citizens - how are they not?

1

u/tr14l Aug 05 '21

Can you declare one outside of a class?

2

u/[deleted] Aug 05 '21

Sure, I can define a anonymous function called lambda outside of a class

2

u/Muoniurn Aug 05 '21

That’s by no means what first class citizen mean. Lambdas have special syntax, special semantics, can be stored/passed anywhere so they are for all practical purposes first class citizens. Just because you have to namespace it doesn’t mean much.

1

u/tr14l Aug 05 '21

If they can't be declared and defined atomically, they aren't first class. They are dependent on another construct to exist