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]

1

u/Beaverman May 25 '19

How is it more explicit? It's way more explicit to just do the thing you want to do.

Yes, they are higher level. That doesn't make them good.

In each case, the benefits for the writer of the code include reliability (no off-by-one errors with indices and such)

That's solved by for-each loops. They are pretty simple in their function, and easily understandable.

brevity (lack of boilerplate).

How is doing what you actually want to do boilerplate? If what you want to do is sum a set of numbers, then why not just sum those numbers?

→ More replies (2)