With M being deprecated, we will soon be able to use Java's stream APIs in Chrome.
This site has great examples of how to use them:
And for googlers, there's some advice at go/java-practices/streams
I think it would be good to add a note about streams to chrome's style guide. Some of the examples are very compelling, but some of the most common uses (afaict) require heavy use of lambdas, which end up being larger in compiled size, and slower at runtime than a boring old loop.
There's also the question of whether or not to allow parallel() / parallelStream(). They don't allow using Chrome's own PostTask-based threadpool, so I suspect we should just say these are banned for now, but should be considered once we have a concrete motivating use-case.
In terms of presubmit checks, I think we should add a warning for code that uses stream(), that tells devs to consult the style guide, but we need to figure out what the style guide advice is first :).
As a starting point, I propose:
* parallel() / parallelStream() are banned but could be unbanned with disucssion.
* reduce() is banned due to be alway being confusing
* stream() without custom lambdas (incl. things like Foo::bar) are fine
* stream() expressions that use filter() or map() with custom lambdas are discouraged, but allowed if they would be comparatively difficult to write as loops.
As an interesting related point, Kotlin sequences appear to
have the same problem, in they they are not re-written as loops when possible. It *is* possible that R8 may one day do such re-writing, but I'd propose we update guidance only when that happens and not before.