frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

PHP 8.5 adds pipe operator

https://thephp.foundation/blog/2025/07/11/php-85-adds-pipe-operator/
71•lemper•2h ago

Comments

bapak•1h ago
Meanwhile the JS world has been waiting for 10 years for this proposal, which is still in stage 2 https://github.com/tc39/proposal-pipeline-operator/issues/23...
wouldbecouldbe•1h ago
It’s really not needed, syntax sugar. With dots you do almost the same. Php doesn’t have chaining. Adding more and more complexity doesn’t make a language better.
EGreg•1h ago
It’s not really chaining

More like thenables / promises

wouldbecouldbe•1h ago
It looks like chaining, but with possibility of adding custom functions?
bapak•34m ago
It's chaining without having to vary the return of each function. In JS you cannot call 3.myMethod(), but you could with 3 |> myMethod
cyco130•13m ago
It requires parentheses `(3).myMethod()` but you can by monkey patching the Number prototype. Very bad idea, but you absolutely can.
bapak•1h ago
Nothing is really needed, C89 was good enough.

Dots are not the same, nobody wants to use chaining like underscore/lodash allowed because it makes dead code elimination impossible.

troupo•53m ago
> With dots you do almost the same.

Keyword: almost. Pipes don't require you to have many different methods on every possible type: https://news.ycombinator.com/item?id=44794656

te_chris•12m ago
Dots call functions on objects, pipe passes arguments to functions. Totally missing the point.
sandreas•1h ago
While I appreciate the effort and like the approach in general, in this use case I really would prefer extensions / extension functions (like in Kotlin[1]) or an IEnumerable / iterator approach (like in C#).

  $arr = [
    new Widget(tags: ['a', 'b', 'c']),
    new Widget(tags: ['c', 'd', 'e']),
    new Widget(tags: ['x', 'y', 'a']),
  ];
  
  $result = $arr
      |> fn($x) => array_column($x, 'tags') // Gets an array of arrays
      |> fn($x) => array_merge(...$x)       // Flatten into one big array
      |> array_unique(...)                  // Remove duplicates
      |> array_values(...)                  // Reindex the array.
  ;
feels much more complex than writing

  $result = $arr->column('tags')->flatten()->unique()->values()
having array extension methods for column, flatten, unique and values.

1: https://kotlinlang.org/docs/extensions.html#extension-functi...

troupo•54m ago
The advantage is that pipes don't care about the type of the return value.

Let's say you add a reduce in the middle of that chain. With extension methods that would be the last one you call in the chain. With pipes you'd just pipe the result into the next function

cess11•8m ago
PHP has traits, just invent that API, put it in a trait and add it to your data classes.
librasteve•1h ago
raku has had feed operators like this since its inception

  # pipeline functional style
  (1..5)
    ==> map { $_ * 2 }
    ==> grep { $_ > 5 }
    ==> say();              # (6 8 10)

  # method chain OO style
  (1..5)
    .map( * * 2)
    .grep( * > 5)
    .say;                   # (6 8 10)
uses ==> and <== for leftward

true it is syntax sugar, but often the pipe feed is quite useful to make chaining very obvious

https://docs.raku.org/language/operators#infix_==%3E

gbalduzzi•1h ago
I like it.

I really believe the thing PHP needs the most is a rework of string / array functions to make them more consistent and chain able. Now they are at least chainable.

I'm not a fan of the ... syntax though, especially when mixed in the same chain with the spread operator

keyle•1h ago
C'mon Dart! Follow up please. Go is a lost cause...
tayo42•33m ago
I feel like a kindergartener writing go. I wish another language got popular in the space go is used for.
avkrpatel•29m ago
This will be game changer for AI.
edhelas•16m ago
What?
keybored•10m ago
Prompt: Mention how this will affect AI on every topic.
phplovesong•28m ago
The stdlib is so inconsistent this will be a nightmare.

Optionally with a better language you know what order params as passed (array_map / array_filter), but in PHP is a coin coss.

This feels very bolted on and not suited for the stdlib at all.

PHP devs should instead FIRST focus on full unicode support (no, the mb_real_uppercase wont do), and only then focus on a new namespaced stdlib with better design.

lordofgibbons•23m ago
Why doesn't PHP remove the horrid $ symbol for variables and the -> symbol for calling methods? I think those alone would do a lot more for its perception and adoption than adding the pipe operator.
JaggerJo•16m ago
Thanks F#!
ChocolateGod•12m ago
Why not just make types psuedo-objects?

$myString.trim().replace("w", "h");

Which has the advantage of also offering a clean alternative to the fragmented stdlib.

habibur•11m ago
I tried to emulate something similar with PHP at one point. But the problem with PHP was parameter order. Especially in functions like array_key_exists() the array element is the 2nd parameter, while pipe operator expects the object to work on be the 1st parameter, the array in these cases.

I believe they have solved this problem by now. Though no idea how.

Apache ECharts 6 New Features

https://echarts.apache.org/handbook/en/basics/release-note/v6-feature/
1•makepanic•41s ago•0 comments

Show HN: I built Deep Research for SEO keywords

https://www.jelloseo.com/
1•grantsingleton•54s ago•0 comments

Show HN: FlexLLama – Run multiple local LLMs at once with a simple dashboard

https://github.com/yazon/flexllama
1•yazon•2m ago•0 comments

Real-time neural video codec – 100 FPS 1080p and 4K videos

https://github.com/microsoft/DCVC
1•selvan•3m ago•0 comments

In Support of Shitty Types

https://lucumr.pocoo.org/2025/8/4/shitty-types/
1•ingve•12m ago•0 comments

How the Brain Protects Itself from Blood-Borne Threats

https://www.quantamagazine.org/how-the-brain-protects-itself-from-blood-borne-threats-20230620/
1•signa11•14m ago•0 comments

ChatGPT Agent's User-Agent

https://simonwillison.net/2025/Aug/4/chatgpt-agents-user-agent/
1•ingve•18m ago•0 comments

Imaging reveals 2k-year-old ice mummy's 'incredibly impressive' tattoos

https://www.cbc.ca/radio/asithappens/ice-mummy-tattooos-1.7601132
2•empressplay•23m ago•0 comments

China pushes back at US demands to stop buying Russian and Iranian oil

https://apnews.com/article/china-russia-iran-oil-trump-trade-tariffs-a21b0d791007fe0984b38ae3c9087f26
1•mhga•26m ago•0 comments

World in $1.5T 'plastics crisis' hitting health from infancy to old age

https://www.theguardian.com/environment/2025/aug/03/world-in-15tn-plastics-crisis-hitting-health-from-infancy-to-old-age-report-warns
2•benkan•27m ago•0 comments

India Will Buy Russian Oil Despite Trump's Threats, Officials Say

https://www.nytimes.com/2025/08/02/world/asia/india-russia-oil-trump-threats.html
1•mhga•28m ago•0 comments

Google agrees to pause AI workloads when power demand spikes

https://www.theregister.com/2025/08/04/google_ai_datacenter_grid/
1•benkan•28m ago•0 comments

Duffy to announce nuclear reactor on the moon

https://www.politico.com/news/2025/08/04/nasa-china-space-station-duffy-directives-00492172
1•benkan•30m ago•0 comments

AI Rewrote Its Code When I Asked About Human Nature

https://www.psychologytoday.com/us/blog/the-algorithmic-mind/202508/ai-rewrote-its-code-when-i-asked-about-human-nature
1•aard•37m ago•0 comments

Show HN: LinkJolt – SaaS affiliate tracking with 0% fees

https://www.linkjolt.io/
1•frostydog111•39m ago•0 comments

Ask HN: What are some resources to learn about building infra for AI workloads?

1•lambdafunct•43m ago•0 comments

Show HN: I created an AI-powered Python testing suite that writes its own tests

1•MarcoDewey•46m ago•0 comments

Show HN: Code Index MCP – Codebase Indexing Server for LLMs

https://github.com/johnhuang316/code-index-mcp
2•johnhuang316•50m ago•0 comments

Before AWS existed, one company ran the servers for Twitter, LinkedIn, Facebook

https://threadreaderapp.com/thread/1952384517983121540.html
3•taubek•55m ago•0 comments

Strengthening F-Droid's Legal Resilience – Introducing the Research Series

https://f-droid.org/2025/08/04/legal-one.html
1•mgd•56m ago•0 comments

Welcome to the IPv4 Games

https://ipv4.games/
3•chillax•1h ago•0 comments

Ask HN: Parenting with Minecraft Coins?

1•p1anecrazy•1h ago•1 comments

Slopwatch: Fake Linux 'Articles' and Slopfarms with "Linux" in Their Names

https://techrights.org/n/2025/07/27/Slopwatch_Fake_Linux_Articles_and_Slopfarms_With_Linux_in_Their.shtml
1•jruohonen•1h ago•1 comments

Cheqbooq: Your Bank Transactions, Translated Into Insights

https://cheqbooq.com
1•soomrozaid•1h ago•1 comments

ChatGPT adds mental health guardrails after fell short in recognizing delusion

https://www.nbcnews.com/tech/tech-news/chatgpt-adds-mental-health-guardrails-openai-announces-rcna222999
3•nradov•1h ago•0 comments

Monitor your security cameras with locally processed AI

https://frigate.video/
60•zakki•1h ago•15 comments

Microsoft's Failed Strategy – Security as an Afterthought

https://securityboulevard.com/2025/08/microsofts-failed-strategy-security-as-an-afterthought/
3•WaitWaitWha•1h ago•0 comments

Show HN: A simple website to analyze mortgage called "Mortlab"

https://www.mortlab.com
2•branga•1h ago•0 comments

Polish Train Maker Is Suing the Hackers Who Exposed Its Anti-Repair Tricks

https://de.ifixit.com/News/112008/polish-train-maker-is-suing-the-hackers-who-exposed-its-anti-repair-tricks
6•xrayarx•1h ago•0 comments

Troubling scenes from an Arctic in full-tilt crisis

https://grist.org/climate/troubling-scenes-from-an-arctic-in-full-tilt-crisis/
2•minhduong243•1h ago•0 comments