DevoxxUK Lambdas Lab
richard.warburton at gmail.com
Wed Apr 3 01:12:28 PDT 2013
Last week at DevoxxUK we ran a brief lambdas hackday. People were
encouraged to focus on the collectors component of the API through setting
a few problems to solve. I appreciate its a bit late in the game as far as
API changes, but some of these issues are fixable through
documentation/improved compiler error changes rather than API changes.
1. No one complained about the move from “into(new ArrayList<Foo>());” ->
“collect(toList())” when you explained that the change had been made.
However, people didn’t naturally find Collectors.toList() and they did
express frustration around that. At least one request for an abbreviated
toList() method on a stream - more for findability/fluency reasons rather
than brevity of code.
2. ToIntFunction, ToDoubleFunction etc. are all usable with flatMap, but
the naming confused people as to why.
3. Several people requested a way to transform a boxed stream into an
unboxed stream. Its pretty easy to go the other way around, but there
didn’t seem to be any utility methods for making the boxed -> unboxed
4. People found “groupingBy” to be a hard conceptual leap. We had set an
exercise where people were asked to count the frequency of words in a
document, in order to force them to use it.
a. Quite a few people didn’t initially look for a function that collects a
stream into a map.
b. When you suggest that they should look for that, they didn’t look for
something called “groupingBy”.
c. They did get the concept once you bring up SQL. With hindsight I wished
I had enquired about how many people had used LINQ.
d. People then didn’t grok that they needed to use the multiple argument
overload of groupingBy, with a reducingBy, in order to complete the task.
I suspect that this method needs more documentation examples in order to
be easily understandable by people.
5. People are beginning to get confused by old documentation on the
internet being out of date. I hadn’t seen this in previous hackdays. Even
an article in the latest Java Magazine is out of date due to the API moving
so much recently, and so is the official tutorial:
Probably not a long term concern - but might be a concern for the first
6. If anyone else runs this kind of thing and they are a day-to-day eclipse
user, word of advice to make sure you know how to set the preferred JVM
location in netbeans and intellij before you run the event!
Thanks to everyone that attended, and especially to Stuart Marks, Maurice
Naftalin, Graham Allan and John Oliver for helping out with running the lab.
There’s a full link with code that people wrote and pasted at, and it also
contains some more comments by people:
More information about the lambda-dev