> On 16 Jul 2016, at 07:08, John Zhuge <jzh...@cloudera.com> wrote: > > Hi all, > > What is the guideline to select which Java 8 features to use (e.g., Lambda, > CompletableFuture, etc.) when developing for both trunk and old branches > that do not support for Java 8? The goal is to leverage nice Java 8 > features while minimizing backporting effort. > > If we plan to use certain Java 8 features, do we recommend any idioms that > facilitate easy backporting? > > Has anybody had experience in RetroLambda > <https://github.com/orfjackal/retrolambda>? >
If you are writing code for trunk with no plans to backport, I think you get to use whatever bits of the language you want. That said: I'd recommend we all start learning to use the language in tests; it's safer to play there. You can also do some really fun stuff with closures in tests; something i've done in Groovy in the past, and with scalatest's eventually() clause. you can do things like define a probe to retry until it succeeds (or fails fast with some specific exception).; scalatest eventually() even does exponential backoff. Things like that deliver tangible improvement to any test which sleep+ waits for things to happen. I've also been doing stuff in scala closures related to metrics -lambda-expressions which get evaluated for building metric values. This makes it easy to write metrics which are evaluated on demand. Otherwise: 1. I think we learn to use the various map/apply ops and the ability to add stuff to traits 2. UGI.doAs looks like a very nice target for a lambda-expression variant, something like caller.doAs(() -> fs.delete("tmp")) That'd be adding better java 8 features to core components, to make it easier to use downstream. If you want to target older branches and Java 7, it's best to code against branch-2 and use that in your patch naming, so that yetus builds against java7. Locally, I've gone to Java 8 JVMs, but with Java 7 language set. --------------------------------------------------------------------- To unsubscribe, e-mail: common-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-dev-h...@hadoop.apache.org