DEV Community

Discussion on: What are your thoughts on functional programming? In PHP?

Collapse
 
drewknab profile image
Drew Knab • Edited

Pipeline and pattern matching. There’s probably some more syntactic sugar I’m not thinking of right now.

Basically it just results in “uglier” code.

You could probably approximate pipeline with some method chaining if you didn’t want to nest array functions as arguments to other array functions.

Thread Thread
 
underscorefunk profile image
John Funk

You can simulate pipeline type stuff with array reduce and unary functions.

What I really miss is built in currying/partial application, less verbose anonymous function syntax, and auto closures.

Oh, and auto return statements.

When you get used to writing JS and other FP stuff like (x,y)=> x + y and you can do (x) => (y) => x + y, it's really nice.

Thread Thread
 
drewknab profile image
Drew Knab • Edited

Pretty sure you can curry in PHP?

Edit: never mind, read your post wrong.

Thread Thread
 
underscorefunk profile image
John Funk

All good. :D I'm no FP expert and welcome corrections. Who knows... maybe my comments will yield some answers and it'll turn out that what I didn't think you could do easily, you can.