Kotlin

Why Java Developers Like Kotlin: Side by Side Example



Why do Java developers like Kotlin? In this video, I show a side by side example of the same application written twice: once in Java, and once in Kotlin. That allows me to demonstrate the following concepts:1) findViewById vs. Synthetics
2) Listener interface vs. inline method {}
3) DTO vs. data class
4) Multiple constructors versus default parameters and named parameters
5) Scoped Functions: with
6) Assignment/return from if
7) Asynchronous vs. coroutine
8) (nothing) vs. Extension…

Similar Posts

15 thoughts on “Why Java Developers Like Kotlin: Side by Side Example
  1. Less lines does not necessarily mean better code. We spend a lot more time reading code than writing it.

    Therefore in my opinion you want to make your code as easy as possible to read. So less lines is generally better but not all ways, sometime spreading things out and not having a bunch of inline conditionals is better.

    Also thanks for the video, I am currently working on my first kotlin project after a long time working with java

  2. this shows less how awesome kotlin is and more how java is a bit archaic. atleast compared to c# where most of those features have existed for ages…

  3. – Anonymous classes on java can be replaced for lambda expressions that look like their counterpart on kotiln
    – java now have record classes that are only mean to store data and yeah they already java getters and setters
    – since java 15 java also has string templates

    Altough i don't see much value on kotlin compared to java when you paired it with lombok, i think i'd ended up jumping to kotlin or even c#, Oracle gave java 8 support till 2030, so it'll be just like python2 that refused to die. At june (i'm not sure) of 2021 java 17 LTS will be released and then people will still stuck at java 8, that makes me sad

  4. So it looks like Kotlin has taken a lot of inspiration from Javascript.
    String templating using $
    Inline functions
    Data class initialization looks similar to how we can define functions/classes in javascript that take an object literal instead of a list of params
    Scoped functions have a similar result as object destructuring in javascript, although the with syntax looks cleaner
    Returning from if/else is pretty much the same as ternary operators
    Coroutines are pretty similar to the async/await syntax in javascript
    Extension functions are basically how prototypes work in javascript
    I've written javascript a lot, and it looks like I'll feel right at home using Kotlin. Thank you very much for this video!

Leave a Reply

Your email address will not be published. Required fields are marked *