I'm watching a talk by Paul Philips :
http://www.youtube.com/watch?v=TS1lpKBMkgg
at 12:48 he says "in Java 8 their views actually work" when comparing Scala and Java
What are Java "views" and what is Scala's equivalent ?
update : Thanks to Daniel's answer I found this article helpful : http://www.scala-lang.org/docu/files/collections-api/collections_42.html
Java 8's Stream
is what he means by views. They have two important properties:
- They are non-strict, which means they only produce the result on-demand.
- They "fuse" together multiple operations, so you can do multiple
map
or filter
calls, and the original collection will still be iterated only once.
Scala's equivalent are the various View
collections, which you can get by calling .view
on an existing collection. They do have these properties -- they are the defining properties, after all -- but are plagued with deficiencies and bugs, not to mention a very complex implementation.
Paul has toyed with alternative implementations for it on and off, but it has never been a priority replacing them.