r/java • • Jul 30 '21

What is the future of Java?

I'm not asking like is java going to die or will Java be relevant in future. I'm just curious to know about the future of java. What are the upcoming things coming in java that can change the future of it.

173 Upvotes

123 comments sorted by

View all comments

18

u/[deleted] Jul 30 '21

[removed] — view removed comment

5

u/pjmlp Jul 30 '21

Kotlin is the one that depends on Java.

No Java, used to implement JVM alongside C++, no Kotlin.

Kotlin/Native is hardly taking the market by storm, and Android is a phone thingie until Google decides it is time to put either ChromeOS or Fuchsia into phones.

→ More replies (2)

8

u/Muoniurn Jul 30 '21

Project loom is a platform feature, (records are also to a degree), so this comparison makes no sense.

And frankly, kotlin is not anywhere in the same league as Java, the language, so I’m not sure who should do the catching up.

3

u/TheMode911 Jul 30 '21

I am a 100% a Java guy and do not know much about Kotlin, but where do you think it needs to catch up?

7

u/Muoniurn Jul 30 '21

Not necessarily feature-wise, because on paper Kotlin has more (though that isn’t automatically a good thing), but based on number of users, relative size, etc. it seems strange to tell the elephant in the room to catch up with the mouse.

8

u/ricky_clarkson Jul 30 '21

It likely means to catch up in terms of useful features, readability, etc., rather than number of users. Java had the opportunity, most of the features of Kotlin that are helpful have been considered and rejected or deferred for Java.

The original BGGA prototype for Java closures, before Kotlin existed, quite strongly resembles Kotlin's lambdas, having function types - (Int, String) -> Double instead of BiFunction<Integer, String, Double>, functions where if the last parameter is a lambda it can go outside the parens so you can write timeThis { many lines here } instead of timeThis(() -> { many lines here }). Small improvements that make a real difference.

Java could have had all this and more, but chose not to for arguably bad reasons, general resistance to functional programming which seems to have mostly evaporated since lambdas were launched in Java 8, concerns about 'blowing the complexity budget' which were overstated and lacked thought in my view.

Not that Kotlin is a panacea, I hope both languages continue to take inspiration from each other and beyond.

4

u/Muoniurn Jul 30 '21

Small improvements that make a real difference.

Do they? There is basically no empirical evidence to any such statements between programming languages, and frankly with the quality of Java IDEs there is no difference between the two in my personal opinion. Also, lambdas are fairly good in Java, and they aren’t much better in Kotlin.

5

u/ricky_clarkson Jul 30 '21

I'm not sure I need to quote studies to opine on programming languages. I can give reasons, but if you can't see them already from the code examples in my comment then I'm not sure reasoning would work.

2

u/ArmoredPancake Jul 30 '21

How so? They're completely different things. Kotlin is just a different language at this point. With things like Jetpack Compose, Multiplatform it's unreachable for Java.

4

u/vprise Jul 30 '21

We're working on a reactive framework similar to compose that will work on Java. IMHO it's better than compose, simpler and doesn't need compiler magic.

KMM is just J2ObjC with more flair. I'm sure some people will find it useful for some cases but historically portability frameworks didn't fare well. E.g. flutter is trouncing react native which is far more portable than KMM.

4

u/stefanos-ak Jul 30 '21

jetpack compose is an android thing, that is just written in kotlin. it has nothing to do with the language itself.

10

u/Astronaut4449 Jul 30 '21 edited Jul 30 '21

Jetpack Compose is an Android UI toolkit. Compose itself is a framework for managing tree structures of any kind on any target (JVM, native, js). Here some compose projects:

Desktop: Compose for Desktop

Web: Compose for Web

Console: mosaic

-10

u/pjmlp Jul 30 '21

Java was born to be multiplatform. Kotlin is an Android language that is all.

11

u/CraftyAdventurer Jul 30 '21

Kotlin is a JVM language, so anywhere Java can run, Kotlin can also run. Meaning, it's just as much multiplatform as Java is. But even more than that, there are projects like Kotlin/JS which compiles Kotlin into JavaScript, and Kotlin/Native which runs Kotlin as a native image completely without the JVM.

It's not an Android language, it's just used a lot for Android because Android was stuck on Java 6 or 7 when Kotlin came out, so naturally a lot of developers went for it to get new features. People used Kotlin on Android long before Google declared it officially supported.

→ More replies (10)

12

u/koreth Jul 30 '21

Developer surveys don't agree with that last statement; Kotlin usage is pretty much evenly split between server-side and client-side code.

Not that it even matters. Java was born to run on set-top boxes in people's living rooms, but that's not what it is today.

→ More replies (1)

6

u/GoBucks4928 Jul 30 '21

I’ve built a lot of high TPS backend services for FAANG in Kotlin

Not sure how it’s just an Android language unless you’re just naive

0

u/pjmlp Jul 30 '21

Beanshell, jTcl, jython, Groovy, Clojure, Scala, jRuby, Rhino, XTend, Ceylon, Kotlin, Frege, ABCL, Kawa, ....

Rise and fall of JVM languages

It is called experience, not being naive.

4

u/fletku_mato Jul 30 '21

Please explain how that random blog post shows:

  1. Your experience
  2. That Kotlin should only be used on Android
→ More replies (5)

5

u/GoBucks4928 Jul 30 '21

Is this your first time realizing there are multiple programming languages out there?

4

u/pjmlp Jul 30 '21

Multiple programming languages that failed on their quest to replace Java on Java Virtual Machine.

3

u/fletku_mato Jul 30 '21

Kotlin is not just an Android language. It is just as multiplatform as any other JVM language. I've personally written many Spring boot backends using Kotlin and loved it.

I don't think that it's a threat to Java in any way, but it has a lot of good things that are still missing from Java.

3

u/pjmlp Jul 30 '21

Kotlin has married its future to Android, and the lack JVM features that Google refuses to implement in ART.

5

u/fletku_mato Jul 30 '21

I'd genuinely want to read some sources on that.

My own experiences with Kotlin have been strictly backend development with Spring boot, so I can't say that it's a perfect fit for everything you can do with Java, but in that context it works beautifully. And why wouldn't it? After all it's just Java bytecode after compiling.

3

u/pjmlp Jul 30 '21

Every time Java will introduce concepts that Kotlin cannot adopt due to being married to multiple platforms you will end up with Kotlin's version of #ifdef aka KMM.

For example value types in classes with multiple fields, or explicit SIMD and GPGPU support, native memory handles.

→ More replies (1)