this post was submitted on 30 Oct 2023
1009 points (96.2% liked)
Programmer Humor
32558 readers
459 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Honestly, php is actually pretty fucking sweet for functional programming and metaprogramming... other languages wish they had
__invoke
and__get
.I also think it has the "right" balance of library functions built in, you can do pretty much anything common and trivial with built-ins but the function list is short enough that you can comprehend most of it.
__invoke
is just for making a class Callable. Java has those with functional interfaces.__get
is just dynamic property resolution synax sugar. Instead of something likeobj.get("property")
you doobj->property
.Instead, I would like to see ADTs, generics, pattern matching, immutability, expressions everywhere and a better stdlib. Then one could call PHP functional.
It's like how people say Javascript is functional. Sure, it has lambdas, anonymous functions, closures,
const
. But those alone don't make it functional.Functional programming is very different (and at times hard). If you have the time you can check out F#, OCaml, Elixir, Erlang, Rust or Haskell (in order of difficulty imo). Those are more "pure" functional, rather than imperative/OOP with a touch of functional.
See how things work, what features they have and don't have. How problems are solved in these languages. I think learning about one of them can give you a different perspective on what functional means. I discovered F# one day, got curious and discovered a whole different paradigm, a new perspective on programming. And learning about functional programming really made me a better programmer, even on procedural/OOP.