Hacker News new | ask | show | jobs
by chuck8088 318 days ago
This article makes a great case WHY the pipe operator is useful, but why didn't they just rewrite those functions to support method chaining? ` $profit = [1, 4, 5] .loadSeveral() .filter(isOnSale()) .map(sellWidget()) .array_sum(); ` this has the side benefit of 'looking normal'
2 comments

Backwards compatibility. The language has done a pretty amazing job at adding features over the last 10 years without really breaking a lot of old code. I believe PHP still runs about 75% of the internet, so that's pretty huge.
The Python 2 to 3 upgrade is a example of how important backwards compatibility is
Because pipes work on all functions, not just object methods. So your business logic, validations etc. don't have to be methods of the built-in objects.

And there's nothing abnormal about pipes