32
gitpush
6y

The joy of using Kotlin instead of Java :')
Though if I'm not mistaken they produce almost same out put :\ but writing kotlin is just time saving IMO

Comments
  • 1
    Actually there are cases in which Java is better but kotlin is still better if you see the whole picture :D
  • 0
    @ilikeglue compared to age of both languages I'm sure Java is better in some cases (if not a lot of cases)

    But the code is waaaay less and more readable than Java. But both use JVM so I guess not much of a difference in performance?
  • 2
    Sorry to break it to you, kotlin runs a lot slower because the jvm assembly code is not ran thru the java optimization steps
  • 1
    @sharktits in that case then why did Google support it in Android Studio? Android already has that bad reputation of running slower than iOS, now kotlin apps run slower :\
  • 2
    Good fucking question, i wanted to like kotlin too, but after some significant slow down on one of my projects, i just scrapped it. As it stands now, its mostly suited for smaller apps, what makes it really redundant, because react native does that job a lot better.
  • 2
    @sharktits any source/benchmarks on that?
  • 1
    @sharktits HELL NO React Native DOES NOT!

    Sorry caps all lol

    React is cool for tiny projects only, but I've made two projects which are of the same size of the app i'm doing for my own, they are waaay slower than my kotlin app tbh

    We cannot blame RN I might have made coding mistakes, but at least login page of both apps have different speeds in rendering (RN is rendered on a Galaxy S8+, while kotlin is rendered on an Alcatel Flash) and kotlin renders faster, (after disabling all init code, just rendering UI no inits happening in code behind while rendering)
  • 1
    @sSam just my experience, but ill make a benchmark eventually
  • 4
    @sharktits source? because I was under the impression that Kotlin was actually faster than Java
  • 1
    @mjones44 @vlatkozelka @vlatkozelka I have not found issues but was wondering since they end up in same JVM Kotlin and Java should have same performance? Or does Kotlin have its own optimization?
  • 2
    @gitpush I could be wrong but AFAIK Kotlin does some neat stuff under the hood because of the null-safety features that allow it to generate more efficient bytecode
  • 0
    @mjones44 at least the result code that we devs see is readable and less of a pain compared to Java especially those get and set functions, I really hated them, take more lines for simple task
  • 1
    Always convert to Kotlin when reading someone else’s code. The difference is night and day.
  • 1
    @gitpush @vlatkozelka @mjones44 I would guess their performance to be pretty similar. Wouldn't be surprised if Java was a bit more efficient because of years of optimizations, however Kotlin devs could have just taken best compile methods from java compiler source code to match the performance closely.

    I haven't used Kotlin myself, but depending on their implementation of data/value classes it might perform faster. That is, if they don't create object for data classes.
  • 4
    @sharktits Kotlin is actually as fast (and faster) than Java, though has a little more overhead some places (e.g. null checks everywhere, but much rather that than typing them myself)
  • 4
    @ilikeglue Name me one example, as I struggle to find one where Java may possibly reign against Kotlin
  • 4
    Would be great if people stopped saying things without any proof. Anyways, here's some benchmarks:

    https://sites.google.com/a/...
  • 0
    @vlatkozelka Pretty sure she's talking about null checks in byte code, not in Kotlin source code. Also I've never seen code that required that many null checks, something might be wrong with your code base. I guess in worst case you could just:

    try {

    doShit(x.y.z.k);

    catch (NullPointerException e) {}

    Might have side effects, depends how doShit() works, but don't think this is such a realistic example.
  • 1
    @vlatkozelka I definitely agree that Kotlin statement is way better, just wanted to mention that I've never worked on code that would require such null checks. My main point was a guess what @Proximyst meant by null check overhead.
  • 1
    @gitpush performance is not just vm dependant in this case. It also depends on the compiler which creates the byte code. But yeah moetly same speed.
  • 5
    @vlatkozelka @Ssam I am a full on Kotlin fan, to the extent where I hardly remember Java syntax; It is simply a language which has everything in Java and more. Amazing, really.
  • 2
    @vlatkozelka That was wonderful to me. I however hated forced null safety, but grew accustomed to it and love it due to Rust and Crystal
Add Comment