Campbell Ritchie wrote:Why do people think the Streams API is only suitable for advanced people? Think how easy that would be:-
There are three kinds of actuaries: those who can count, and those who can't.
Stephan van Hulst wrote:Agree with Campbell. Functional approaches are much more natural for data transformations, and we only think of streams as hard, because we're so used to imperative programming.
T-h-r-e-a-d-s?? That is the worst spelling of Streams I have ever seen. But it still has the three middle letters rightHalf an hour ago, I wrote:. . . it is quite possible to teach students at least the basics of using Threads. . . .
Campbell Ritchie wrote:
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Remembering that it is really 0...<100; both IntStream.range() and the standard idiom of a for loop would run up to 99 inclusive. otherwise you get Fred's off‑by‑error.Junilu Lacar wrote:. . . . When I see "from 0 to 100" the first thing that comes to mind is still a for-loop. . . .
Who said that originally? It is horribly inaccurate; teaching is just as much a skill as “doing”.Junilu Lacar wrote:. . . "Those who can.. those who can't" adage . . .
We have had some bad experiences here; you are liable to fnd companies saying, “We want graduates who can use XYZ,” so teaching proper computer sciences has taken second place to teaching XYZ. I think that sort of thing will vary from place to place doubtless other people have had no such problems at all.getting academia to collaborate more with industry. I think that would move the needle towards narrowing the gap.
Campbell Ritchie wrote:
Who said that originally? It is horribly inaccurate; teaching is just as much a skill as “doing”Junilu Lacar wrote:. . . "Those who can.. those who can't" adage . . .
There are three kinds of actuaries: those who can count, and those who can't.
That's a pleasure (), but I didn't really start this thread. There was something in Ana Yo's thread which looked like a candidate for a Stream solution, so I posted it, and next thing I knew, there were all these replies. So I split part of the discussion off.Peggy Fisher wrote:Campbell,
Thanks for starting this thread! . . .
All good points, Salvin. But why aren't students taught those things? Start with populating an int[], which is just about the simplest Stream application I can think of, and later add more details. Even something daft like this can be used for useful teaching:-You might not write such code in real life, but you can use that to teach method chaining and lazy execution. Build up the use of Streams and λs gradually.salvin francis wrote:Let me look at this from a complete fresher's point of view: . . .
Nearly five years.Tim Moores wrote:. . . lack of elapsed time since streams were introduced. . . .
If you really are going to create an array of the same size, you would have to iterate the phones array twice, once to count the matching elements and once to collect them. A Stream does the counting for you, and produces the right size of array without needing more instructions. You could do the same with a List, but AY has to create an array.Piet Souris wrote:. . .
1) determine the number of elements that meet the requirement
2) create an array of that size
3) put the matching elelemnts into that array
. . .
Campbell Ritchie wrote:
Nearly five years.Tim Moores wrote:. . . lack of elapsed time since streams were introduced. . . .
But you can paddle in streams before learning all those concepts.salvin francis wrote:. . . There are a lot of concepts that one should learn before diving into streams.
Start with simple things like what I showed on Thursday (this post in this thread); explain that you need a source of information, that unusually here the Stream is providing its own source of information, that you mustn't alter that source nor use the same Stream twice, that Stream methods might produce a new Stream or something else, and that there is lots more to learn about Streams but it is too early to go into all the details yet.A few minutes ago, I wrote:. . . But you can paddle in streams before learning all those concepts.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |