Google guys, if you stumble on a few peculiarities in a language under development, talk directly with your partner instead of showcasing them in public and on RU-vid. It's lame and unprofessional. After all, Kotlin is your way out of this Dalvik mess of yours.
The guy said it himself, it's still experimental. Obviously the code doesn't yet check for wrap-around values and so on. It's just a very bad presentation overall.
Such a piece of crucial information. It's so hard to believe the kind of mess Kotlin creates underneath for providing those extra features to the end developer. Every developer should beforehand dig in a little beneath this syntactical sugar provided by modern languages. And yes, Chet and Romain, always a delight to watch.
In Kotlin, we do 10001 comparasions of an integer to a variable of type Int?. As it's been told, Kotlin's Int? is java.lang.Integer under the hood. So, on each iteration we compare a primitive type int to an object of type Integer, and the only way to do this is to wrap the int into a corresponding Integer, like: Integer iAsInteger = new Integer(i); So, we expect 10001 object allocations. But Kotlin optimizes this a little bit by caching instances Integer(0), Integer(1), ..., Integer(127). Unless i gets greater than 127, Kotlin uses the cached java.lang.Integer's instead of allocating new ones.
This video is incredibly insightful. I will never forget about Int? needing to allocate every time a new value is assigned. On the other hand, this video also feels like many passive aggressive remarks from Google to Jet Brains around the Kotlin compiler's inconsistencies and oddities. The lambda example actually seems pretty scary.
I'm so angry, why should I keep developing Android applications if at any time and without notice YOU block manufacturers?... even more, why users (and clients) should keep buying Android devices if at any time YOU can make'em "WASTE" their money with this S T U P I D deciscions?.