4 ms·
Java has the compiler in memory while running. Rust's compiler is a separate program so isn't in memory while it runs. That by itself is a lot of code.
by chrisseaton 6y ago
Java has the compiler in memory while running. Rust's compiler is a separate program so isn't in memory while it runs. That by itself is a lot of code.
- oriolid 6y agoKotlin runs in JVM and should get the same benefits from live profiling and JIT compilation.
- pjmlp 6y agoLike all guest languages it needs to generate additional boilerplate to pretend to be Java, and support its additional features not available out of the box in JVM bytecodes.
- dtech 6y agoKotlin should be close-to-identical* in terms of bytecode it immits for straightforward code like this, it's designed to very closely match Java capabilities, among others to make sure interop is very good. * Exception is supporting things like default methods on JVM 1.6 bytecode
- pjmlp 6y agoApparently that isn't the case. Additionally it is stuck on Java 8 view of the world, otherwise those .class files won't be usable on Android toolchain thanks Google.
- jontro 6y agoLooks like it supports generating class files up to java 16 https://kotlinlang.org/docs/compiler-reference.html#jvm-target-version https://kotlinlang.org/docs/compiler-reference.html#jvm-targ...
- pjmlp 6y agoYeah, but it can't make use of JVM bytecodes without DEX counterparts, nor JVM abilities unknown to ART.
- dtech 6y agoIncorrect, the Kotlin compiler allows you to specify the target JVM level, it can generate JVM 1.6 bytecode (for android) up to 16. I know for a fact it uses different bytecode features if the level is >= 1.8, not sure how smart it is above that.
- pjmlp 6y agoIt can only generate bytecode features that ART understands, and D8 is able to convert into DEX, thus is the price of Android marriage. Going forward while for Java code there is no worry about using SIMD, JNI replacement, value types, Kotlin code will need to make use of KMM for code that is supposed to target both JVM and Android.
- dtech 6y agoAre you so dense that you cannot understand that the Kotlin compiler can do gasp different things depending on different settings? It can do stuff android doesn't support if you set the bytecode target level to > 1.8 It's like using modern Javascript features but providing a polyfill for older browsers.
- pjmlp 6y agoWhich produces libraries that are worthless to be consumed from Android without recompiling. Also stuff like value classes will have different semantics in memory consumption and performance across targets. Maybe some learning required?
- dtech 6y agoThose are bytecode level related. You can't consume Java 16 libraries on Android either. It's not related to Kotlin at all. You are either being deliberately obtuse or you genuinely have difficulty to understand that Java version, bytecode version, Kotlin compiler output and what bytecode Android supports are totally independent concepts.
- chrisseaton 6y agoOh I replied to the wrong comment - I was commenting on why it used more memory than Rust.
- lallysingh 6y agoOptimizers can be finicky; kotlin and Java are going to generate different bytecode. The optimiser's been optimized for Java, and those differences will matter