r/programming • • May 25 '19

Making the obvious code fast

https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
1.3k Upvotes

263 comments sorted by

View all comments

-8

u/Beaverman May 25 '19

I don't understand linq and streams. What's wrong with the imperative for loop? How is it any easier to read than a for loop and a variable?

Linq and streams are not how the computer executes your code, it's not how you'd write the math. What's the point?

0

u/[deleted] May 25 '19

[deleted]

-8

u/Beaverman May 25 '19

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.

6

u/ylyn May 25 '19

In some (many) situations, functional/declarative style is actually clearer and easier to reason about.

At least to me. YMMV.

→ More replies (3)