The first typed programming language where I've seen pipe operator |> in action was in F#. You can write something like: sum 1 2 |> multiply 3 and it works because |> pushes the output of the left expression as the last parameter into the right-hand function. multiply has to be defined as: let multiply b c = b \* c so that b becomes 3, and c receives the result of sum 1 2 . RHS can also be a lambda too: sum 1 2 |> (f…
PHP 8.5 adds pipe operator
231–240 of 282 posts
Re: PHP 8.5 adds pipe operator
#232This will be the year of PHP. People are tired of JS.
Re: PHP 8.5 adds pipe operator
#233I had this argument in the PHP community when the feature was being discussed, but I think the syntax is much more complicated to read , requiring backtracking to understand. It might be easier to write. Imagine you're just scanning code you're unfamiliar with trying to identify the symbols. Make sense of inputs and outputs, and you come to something as follows. $result = $arr |> fn($x) => array_column($x, 'values')…
A lot of people could say the same of the rest/spread syntax as well.
Re: PHP 8.5 adds pipe operator
#234Earlier quoted context omitted.
Am I correct in my understanding that you're saying that the developers of the most widely used JS engine saying "hey we can't see a way to implement this without tanking performance" is a silly hypothetical that should be ignored?
Closures won over OOP in Javascript a long time ago (eg, React switching from classes to functions + closures), but they still keep trying to force garbage like private variables on the community. Loads of features have been added to JS that have worse performance or theoretically enable worse performance, but that never stopped them before. Some concrete (not-exhaustive) examples: * Private variables are generally 3…
Re: PHP 8.5 adds pipe operator
#235Earlier quoted context omitted.
yea I agree. haskell was my primary language for several years in the 00s. it's since had almost zero industry uptake. Don't come at me with jane street or the one off startup. I thought for a while I'd be able to focus on getting jobs that liked haskell. it never happened.
I certainly wouldn't focus on getting a Haskell job. Yet they are out there; e.g. my current job is Haskell, and happens to be in the same sector (public transport) as my last job (which was mostly Scala). Also, I've found Haskell appropriate for some one-off tasks over the years, e.g. - Extracting a load of cross-referenced data from a huge XML file. I tried a few of our "common" languages/systems, but they all ran…
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.
Re: PHP 8.5 adds pipe operator
#236The first typed programming language where I've seen pipe operator |> in action was in F#. You can write something like: sum 1 2 |> multiply 3 and it works because |> pushes the output of the left expression as the last parameter into the right-hand function. multiply has to be defined as: let multiply b c = b \* c so that b becomes 3, and c receives the result of sum 1 2 . RHS can also be a lambda too: sum 1 2 |> (f…
Is |> actually an operator in F#? I think it's just a regular function in the standard library but maybe I'm remembering incorrectly.
Re: PHP 8.5 adds pipe operator
#237I had this argument in the PHP community when the feature was being discussed, but I think the syntax is much more complicated to read , requiring backtracking to understand. It might be easier to write. Imagine you're just scanning code you're unfamiliar with trying to identify the symbols. Make sense of inputs and outputs, and you come to something as follows. $result = $arr |> fn($x) => array_column($x, 'values')…
Re: PHP 8.5 adds pipe operator
#238Earlier quoted context omitted.
Am I correct in my understanding that you're saying that the developers of the most widely used JS engine saying "hey we can't see a way to implement this without tanking performance" is a silly hypothetical that should be ignored?
Closures won over OOP in Javascript a long time ago (eg, React switching from classes to functions + closures), but they still keep trying to force garbage like private variables on the community. Loads of features have been added to JS that have worse performance or theoretically enable worse performance, but that never stopped them before. Some concrete (not-exhaustive) examples: * Private variables are generally 3…
Only in function calls, surely? If you're using spread inside [] or {} then you already know that it allocates.
Re: PHP 8.5 adds pipe operator
#239Earlier quoted context omitted.
What makes you believe Haskell is dead or even dying? New versions of GHC are coming out, and in my experience, developing Haskell has never been smoother (that’s not to say it is completely smooth).
it's easy to learn and speak latin as well.
Re: PHP 8.5 adds pipe operator
#240Earlier quoted context omitted.
This is what a good IDE brings to the table, it'll show that $result is of type string. The pipe operator (including T_BLING) was one of the few things I enjoyed when writing Hack at Meta.
> This is what a good IDE brings to the table, it'll show that $result is of type string. I think the parent is referring to what the result _means_, rather than its type. Functional programming can, at times, obfuscate meaning a bit compared to good ol’ imperative style.