r/programming • • May 21 '20

Java programming language celebrates 25 years

https://www.infoworld.com/article/3544229/java-programming-language-celebrates-25-years.html
95 Upvotes

73 comments sorted by

View all comments

Show parent comments

11

u/dark_mode_everything May 21 '20

It's clunky to write. The bytecode is pretty much the same if not more optimized than Kotlin.

6

u/Determinant May 21 '20

Kotlin does some things during compile time which results in different bytecode.

For example, functions that accept lambdas which are marked with the inline modifier get inlined into each call site. This means that no lambda object gets created which avoids the performance issues from non-local memory access as well as eliminating any garbage collection overhead.

There are a ton of other improvements as well. In fact, most Kotlin bytecode can't be decompiled to Java because Kotlin makes use of bytecode capabilities that aren't possible in Java.

1

u/not-enough-failures May 22 '20

That actually causes some problems with some JVM tooling, like until very recently (a couple of days ago) GraalVM would crash on some kotlin coroutine code because it used some type of loop that was assumed to never be emitted by the Java compiler.

Thankfully it's now fixed.

1

u/Determinant May 23 '20 edited May 23 '20

I'm pretty sure that the Graal team said that they just didn't optimize that use-case before whereas it's now faster for coroutines.

Also note that Kotlin-generated bytecode is fully compliant with the JVM bytecode specifications and Graal is supposed to be able to handle all valid bytecode regardless of where it came from.