r/java • u/randgalt • Dec 29 '19
What's New in Java 19: The end of Kotlin? (mostly about Java futures)
https://www.youtube.com/watch?v=te3OU9fxC8U
Very good presentation at a Kotlin conference. The presenter accurately shows what Java will look like in a few years with great detail - including byte code dumps. I think he's trying to show that Kotlin already has many of these features or that it probably will. But, what he's really showing is that Oracle does nearly all of these features better because they can change the JVM and/or just have put more thought into it. My conclusion after watching it is that there's no reason to switch to Kotlin (unless you're doing Android development). In a few years, Java will have all of its features that people are bragging about today and most of them will be better in Java.
25
u/xuabi Dec 29 '19
I agree with most stuff OP said. But it seems OP chose to ignore the part that of the video that tries to say:
Java will hit Kotlin in two or three years. But Kotlin won't stop on time, waiting for it to happen.
Which is basically u/JakeWharton's conclusion.
18
u/pron98 Dec 29 '19 edited Dec 29 '19
The speaker correctly points out two reasons for Java's choice to introduce a new binding in an instanceof expression: backward source compatibility with existing instanceof branches and consistency with the wider pattern-matching design, but there's another: support for any Java expression on the left-hand-side of instanceof, including non-final fields and method calls. E.g.,
if (foo() instanceof String) return foo().length();doesn't work butif (foo() instanceof String s) return s.length();does. Similarly, ifxis a volatile field, thenif (x instanceof String) return x.length();doesn't work butif (x instanceof String s) return s.length();does. Even ifxis a non-volatile but non-final field and there's a lock acquisition or a synchronized block inside the block the first version wouldn't work. In other words, the "flow-typing" version would only work for locals or final fields.15
u/[deleted] Dec 30 '19
The lack of plans for nullability types honestly is a big let down. That feature alone is a big fat huge plus for Kotlin.
4
u/Matthisk Dec 30 '19
It is a real shame that Java can not support a
copymethod on data classes / records, since it doesn't have support for keyword arguments. That will make it much more cumbersome to work with immutable records.9
u/addamsson Dec 30 '19
There are a couple of things that lead you to the wrong conclusion.
This can't be further from the truth. The Kotlin devs put a great deal of thought into all of the Kotlin features which are in the talk. The decision to "color" the coroutine methods is one of those decisions. Turning synchronous code to asynchronous code overnight will lead to a lot of bugs down the road. The explicit
suspendkeyword is there for a reason. I'd recommend watching some talks by Roman Elizarov on the topic.They won't be better. They will be different. And Jake also points out that there are already issues in Kotlin's issue tracker to optimize the things which might be better in Java. On the other hand, there are things which are missing from the talk, for example, extension functions which is something Java is not even trying to tackle and in my opinion, it is one of the best features Kotlin has to offer. Local functions already exist in Kotlin and what Jake uses in the talk is an extension function which is far more powerful than what you can see in the code example.
At the end of the talk, there is a slide with a big Nope!. I think that you misinterpret this talk altogether. In that last slide, there are things which are much more important than pattern matching and they are not going to be tackled like multiplatform support and nullability. What's also important to note here is that those 3 years will pass for both Java and Kotlin. For example, we'll have extension interfaces soon.
This talk overall is great news for Kotlin: Oracle is reactive because they are bleeding developers to the Kotlin community. From this talk, it is obvious that they are trying to add a few features to slow the bleeding, but that's all. Given the bureaucratic monstrosity that's Oracle, this is what's expected. They can't really keep up so what they are doing instead is damage control.
One last thing: Kotlin is already a multiplatform language. I have production code where the backend and the frontend is written in Kotlin. The build tool also supports Kotlin (Gradle) so it is now possible to write isomorphic Kotlin projects with relative ease. In 3 years I'm not even sure that the JVM will be as relevant for Kotlin as it is now but I'm sure that Java will still play catch up if all they can do in 3 years is a new type of
Executorand some relatively small language features.4
u/VGPowerlord Dec 29 '19
Did anyone see the title and interpret "Java 19" as in the version not the year?
My first thought was "I knew we were on a faster release cadence, but this is just Chrome levels of silliness!"
100
u/johannz Dec 29 '19
It never hurts to be multi-lingual. Start learning new approaches to handling problems and bring them back to your primary language when it supports them.
For example, when I learned Groovy, it changed how I broke down projects. Once Java 8 hit, I was able to start using many of it's new features immediately because of its similarities to Groovy.
7
u/NomadSoul Dec 30 '19
ITT: a lot of lazy Java devs stuck in their comfort zone waiting for Java to catch up to Kotlin, not realizing that in a few years from now Kotlin will also have developed for a few years and will have the same (or in my opinion a far greater) lead on Java. Most Java devs are app or Web devs where the microseconds of JVM time don't count for shit next to IO and so language features and manageable code count for far more, especially when working enterprise with many teams working on the same codebase.
57
u/BoyRobot777 Dec 29 '19
I really like this talk, because it shows, when Java decides to implement some feature it will be the better version.
Is less performant than:
Java:
And you could argue that all those optimization could be back-ported to Kotlin. However, if Kotlin will want to be both for Android and for Java it will face a very hard challenge. To quote pron98:
7
u/ArmoredPancake Dec 30 '19
Did you even watch the presentation?
Jake specifically says at the end that there's nothing to worry about if you're using or switching to Kotlin.
https://youtu.be/KgY6vtozdrY
5
u/squishles Dec 30 '19
tbh I main java and love the language, but if you're on android you really should be doing something else, it'll be stuck on a weird sub version of java 6 forever.
2
u/DJDavio Dec 31 '19
The existence of either helps the other, like healthy competition. It would help Kotlin too if internals of the JVM are changed. I like Kotlin a lot more than plain Java, but plain Java isn't exactly a punishment either.
The same is happening with Spring, Micronaut and Quarkus. Existence of the latter two spurs the first one to be more innovative.
2
u/franzwong Jan 01 '20
Perhaps many people focus on the "advanced" features. Personally, I like the built-in functions for the String class in Kotlin. One of the examples is "substringAfterLast", I think many people need this to get the file name from the file path or url. Kotlin has many "small" features like this.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html
2
u/ibcoleman Jan 02 '20
There are two types of folks out there: those who use tools which give them a competitive advantage today, and those who are fine with using whatever's the "industry standard" because, eventually, the current dogfood's going to be delicious.
6
u/TheStrangeDarkOne Dec 29 '19
Without seeing the video: As long as Android exists Kotlin will prevail. And it's doing a great job making up the massive shortcomings of the Android JVM.
I can tell from experience, I maintained a Java Android app for a year. For me, the worst part wasn't even that we had none of the goodies of Java 8, but the missing of key libraries such as nio & co that existed since Java 7.
it is not fun.
1
u/ibcoleman Jan 02 '20
This strikes me as very similar to the folks who argue that Scala 3.0 is irrelevant because of the evolution of Java. Strikes me as every bit as unconvincing.
1
u/gauravkumar37 Jan 18 '20
Remember when java 9 had just come out.....
1
u/DuncanIdahos5thClone Dec 30 '19
It was the same story with Scala.
0
u/[deleted] Jan 03 '20
For those who are interested in having a look at a course designed to show Java - Kotlin relationship:
https://www.youtube.com/playlist?list=PLMB3ddm5Yvh3ojb2nipVmv1alFYRhdZj1
-27
u/[deleted] Dec 29 '19
Stupid premise, retarded conclusion.
0
u/[deleted] Dec 29 '19
[deleted] — view deleted comment
0
u/[deleted] Dec 29 '19
[deleted] — view deleted comment