You're ignoring half the paragraph in order to spew the most obvious and cliche point in modern software development.
The question was: What's the point. The part you are quoting is an observation that the functional style is no closer to the actual execution, and therefore that could not be the point. The second part (that you didn't quote) is the same observation about mathematics. I've never seen a mathematician talk about aggregating something with the function that takes two arguments and returns the addition of the two.
I'm not "intimidated" by functional programming. I've tried it. I've written Haskell, I've written Scheme. I've written functional Lua, and used Java streams. I think that functional languages, like Scheme Haskell (and to some extent lua and python) have interesting ideas that are useful in certain contexts. I don't think those ideas have any business being used in the way they are. .Aggregate is not more clear than a simple for loop.
PS: If you want to hear the second most cliche opinion in software development: I don't think OOP is any good either. Understanding what the computer is going to do is of utmost importance, because there is really only one thing that matters: Does the code work. The code that doesn't execute doesn't need to be maintained.
I wouldn't read too much into the performance difference of the tests. whichever one runs first is probably including the runtime startup and jit time in the results. I can't quite believe you'd be able to observe a difference in this short of an execution (you're probably not hitting a GC in either example).
As for the readability of you example, i think it's a great case. A case like you have here is where streams are the closest to making sense. The case is also pretty simple, making the syntax and mental overhead of the nesting scopes minimal. Streams don't get really problematic until you have something like:
var y = getRelated();
foo.stream().map(x -> {
if(y.processFoo(x))
return x;
return null;
});
Which some of the code i maintain looks like. I still have people telling me that "streams are more readable", even when we have shit like this in the codebase.
Even then, I still firmly believe the imperative example shown here is just better, because it's much more clear in its description of what the computer will do.
As for the negative reception, there's probably some amount of people who just don't agree, and it sucks that i get downvoted for that. There's probably also some amount who take offense with the argumentative (and sometimes hostile) way I've deliberately written some of the responses. I chose this style of argument because it makes it clear that i don't think people who like streams prefer a different "style" to me, i think they are wrong. People who like FP prefer a different style to me, people who like streams are just wrong.
If you think functional programming is somehow less mathematical
I don't think functional programming is less mathematical. Functional programming is very mathematical. What is not mathematical is the particular favor of "functional" goop called Linq and Streams. Have you ever seen a mathematical paper talk about anything that looked like Linq and Streams?
I don't dislike Haskell and Scheme. In fact a like them. I hope we got that out of the way.
I hope I never have to share and maintain a codebase with you.
I don't think you'll have that problem, seeing as you'll probably never have a codebase worth maintaining. (I know that's pretty snarky, but you have to respond to snark with snark).
0
u/[deleted] May 25 '19
[deleted]