5 ms·
Woah: >Improved Java 8 language support - We’re excited to bring Java 8 language features to Android. With Android's Jack compiler, you can now use many popula
by ubertaco 11y ago
Woah:
>Improved Java 8 language support - We’re excited to bring Java 8 language features to Android. With Android's Jack compiler, you can now use many popular Java 8 language features, including lambdas and more, on Android versions as far back as Gingerbread. The new features help reduce boilerplate code. For example, lambdas can replace anonymous inner classes when providing event listeners. Some Java 8 language features --like default and static methods, streams, and functional interfaces -- are also now available on N and above. With Jack, we’re looking forward to tracking the Java language more closely while maintaining backward compatibility.
- RivieraKid 11y agoThis has been possible for some time with retrolambda.
- EddieRingle 11y agoIn fact, they've implemented lambdas exactly like retrolambda does via anonymous classes.
- sparky_ 11y agoSo this is just another way to blow up your dex method count?
- lukasb 11y agodisclaimer: I work on Android dev tools It depends. For example, let's compare providing an event listener via a lambda vs an anonymous inner class. Using the lambda will increase your method count by 1. However, if you're accessing class member variables, it will reduce the method count for each variable you use, because it's added as a method of the containing class and doesn't need to generate accessors.
- joelhaasnoot 11y agoI find the fact that streams and functional interfaces are not backwards compatible almost a deal breaker. Using Java 8 streams makes so many things easier that once you start using it, there's no going back. Now you're not going to be able to use it in production till 2019.
- richdougherty 11y agoWhen you say "not backwards compatible" do you mean that the streams and functional interfaces aren't compatible with Java in Android N or do you mean that they're not being to be ported to previous versions of Android?
- pas 11y agoMaybe in general, Java 8 generated bytecode won't run on earlier JVMs, but a lot of shops are still on Java 6/7. (Allegedly.)
- joelhaasnoot 11y agoAs I understood the article, it seems they're not being ported to previous versions of Android.
- V-2 11y agoWhile it's certainly a change for the better, personally I find the Streams API is still clunky and lacking. In compare to LINQ, or Kotlin (case in point: http://stackoverflow.com/a/34642255 http://stackoverflow.com/a/34642255).