Java

All posts tagged Java

The release of Kotlin 1.1 brings many welcome improvements to the language: val properties with custom getters can take full advantage of type inference and inlining; they introduced the T.also { it -> } extension method, which is to T.apply {} what T.let { it -> } is to T.run {}; and data classes can inherit from interfaces and base classes, just to name a few. But the two biggest changes are full support for JavaScript as a compilation target (possibly a huge deal, if you’re a full stack dev and reluctantly work with JavaScript), and coroutines(!!!).

Continue Reading

If you’re like me, you’ve grudgingly put up with Java for years, for the sake of getting things done on Android. With Kotlin picking up steam as a viable, modern alternative, things are looking much better for all of us. Whenever possible, I do all my Android work in Kotlin.

To reap the fullest benefits of Kotlin, though, we can’t just fall back on old habits; it’s very easy to write code in a familiar Java style. In fact, allowing this was a design goal of Kotlin, to make it easier to transition between languages. But the real power and beauty of Kotlin is where it differs from Java, sometimes drastically. Let’s take a look at some examples of code patterns I’ve run across in production code, and different ways we can improve upon them.

Continue Reading

Some of you may have noticed that AndroidStudio really wants you to develop for Lollipop–so much so that if you try to create a new project for any of the 4.x versions, it will be broken out of the box. Now, I’m not sure how widespread this problem is, so as a disclaimer, I’ll say I have this problem every time, with the most up-to-date version of AndroidStudio from the Beta channel, on my machine. Here’s some relevant system configuration data:

  • Mac OS X 10.8.5
  • AndroidStudio 1.1.0
  • javac 1.6.0_65
  • Android SDK Build Tools 21.1.2 (with a few older versions still installed)
AndroidStudio 1.1.0

AndroidStudio 1.1.0

Continue Reading