Live data from Hacker News

PHP 8.5 adds pipe operator

thephp.foundation

271–280 of 282 posts

Re: PHP 8.5 adds pipe operator

#271
post #235

Earlier quoted context omitted.

Yea of course, its not really the focus for me either way. my point was that how great haskell seemed in grad school didn't match up with the real world interest. I use spark for most tasks like that now. Guido stole enough from haskell that pyspark is actually quite appealing for a lot of these tasks.

> Guido stole enough from haskell that pyspark is actually quite appealing for a lot of these tasks. He didn't do his homework. Guido or whoever runs things around the python language committee nowadays didn't have enough mental capacity to realize that the `match` must be a variable bindable expression and never a statement to prevent type-diverging case branches. They also refuse to admit that a non-blocking descri…

I agree. but we get phillip wadler's list comprehensions

Re: PHP 8.5 adds pipe operator

#273
post #268

Earlier quoted context omitted.

> also the dreadful state of its tooling this is plain and unsubstantiated FUD > Haskell has none after 30 years > I know Haskell I doubt it

FYI instig007 is not part of the Haskell community but seems to occasionally lambast people about Haskell, risking giving the Haskell community a bad name: https://news.ycombinator.com/item?id=44199980

rar

Re: PHP 8.5 adds pipe operator

#274
post #184
post #53

Earlier quoted context omitted.

It's true that pipes are more readable, and for many cases they will be the better option, but the example of nested functions just doesn't hold. That's like saying someone would use this: $result = $arr |> fn($x) => array_column($x, 'tags') |> fn($x) => array_merge(...$x) |> array_unique(...) |> array_values(...) which is harder to reason about than the nested functions. array_values( array_unique( array_merge( ...a…

Why didn't you format the pipes, too? $result = $arr |> fn($x) => array_column($x, 'tags') |> fn($x) => array_merge(...$x) |> array_unique(...) |> array_values(...) vs array_values( array_unique( array_merge( ...array_column($arr, 'tags') ) ) ); With pipes you have linear sequence of data transformations. With nested function calls you have to start with innermost function and proceed all the way top the outermost la…

Because they were already formatted that way to begin with.

Re: PHP 8.5 adds pipe operator

#275
post #64

Earlier quoted context omitted.

Agree, the ... syntax feels confusing when each fn($x) in the example uses $x as the name of its argument. My initial instinct would be to write like this: `$result = $arr |> fn($arr) => array_column($arr, 'tags') // Gets an array of arrays |> fn($cols) => array_merge(...$cols)` Which makes me wonder how this handles scope. I'd imagine the interior of some chained function can't reference the input $arr, right? Does…

You can do function ($parameter) use ($data) { ... } to capture stuff from the local environment. Edit: And you can pass by reference: > $stuff = [1] = [ 1, ] > $fn = function ($par) use (&$stuff) { $stuff[] = $par; } = Closure($par) {#3980 …2} > $fn(2) = null > $stuff = [ 1, 2, ] Never done it in practice, though, not sure if there are any footguns besides the obvious hazards in remote mutation.

idk if it counts as an obvious hazard, but being able to modify the original input by reference within a chain of piped functions definitely makes it a lot harder to reason about what that sequence might be doing. Particularly since we assume that arrays are passed by reference anyway unless the function you're calling is making a shallow copy of their elements.

My feeling is that this makes the code less legible. I'd rather write 5 lines of code that mutate an object or return a copy than do a pipe this way. I'm sort of not excited to start running into examples of this in the wild.

Re: PHP 8.5 adds pipe operator

#276
post #239
post #204

Earlier quoted context omitted.

it's easy to learn and speak latin as well.

Latin never paid my mortgage. Helped on the SATs though.

I think the point is that there is hardly anybody to speak Latin to, much as there are hardly any actual jobs in Haskell.

Re: PHP 8.5 adds pipe operator

#277
post #146

Earlier quoted context omitted.

Uhm, don't do it, then. That's like arguing that the addition of the ternary operator is a bad one because not all if/else blocks look better when translated into it. The goal is to linearlize unary function application, not to make all code look better.

I think the commenter meant that once the new syntax is approved and adopted by the community, you have no choice to not use the syntax. You'll eventually change your project and will be forced to deal with reviewing this code.

_You_ might not use it, but somebody's going to send a PR, or some LLM is going to spit it out, or some previous maintainer put it in there, or will be in some tutorial, or it will be in some API documentation.

You are going to have to deal with it as a mess at some point. One of the downfalls of perl was the myriad of ways of doing any particular thing. We would laugh that perl was a write only language - nobody knew all the little syntax tricks.

Re: PHP 8.5 adds pipe operator

#278
post #252

Earlier quoted context omitted.

And yet, while PHPs, Javas, and even nicher/newer languages like Kotlin, Clojure or Scala have plenty of killer software (software that makes it worth learning a language just to use that library/framework) Haskell has none after 30 years. Zero. Mind you, I know and like Haskell, but its issues are highly tied to the failure of the simple haskell initiative (also the dreadful state of its tooling).

I will not stand for this Xmonad slander

ahhh i was there, 3000 years ago when it was announced in IRC.

Re: PHP 8.5 adds pipe operator

#279
post #239

Earlier quoted context omitted.

Latin never paid my mortgage. Helped on the SATs though.

I think the point is that there is hardly anybody to speak Latin to, much as there are hardly any actual jobs in Haskell.

And yet I, who am kinda dumb, have managed to find some of each. There's hope out there, beloved Latinists and Haskellers. Never let the fire in your heart burn out.

Re: PHP 8.5 adds pipe operator

#280
post #268

Earlier quoted context omitted.

> also the dreadful state of its tooling this is plain and unsubstantiated FUD > Haskell has none after 30 years > I know Haskell I doubt it

FYI instig007 is not part of the Haskell community but seems to occasionally lambast people about Haskell, risking giving the Haskell community a bad name: https://news.ycombinator.com/item?id=44199980

> but seems to occasionally lambast people about Haskell

If you are to add community notes to my comments, at least add the part that clarifies that I only lambast incompetence and lies.

> risking giving the Haskell community a bad name

as opposed to those that spread FUD, I suppose? It's not the first time I'm asking this question, so what's your take on people who inflate their credibility by telling lies about the tech they clearly don't know?

Post reply on HN