TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Functional PHP (2015)

55 pointsby luu7 months ago

6 comments

sourcecodeplz7 months ago
I've tried Node when the trend started and it was okay. But the problem was that the actual script was also the server. So if the script hanged, the whole server hanged. Went back to PHP and never looked back.
评论 #41828400 未加载
评论 #41828748 未加载
评论 #41828350 未加载
评论 #41829083 未加载
评论 #41828949 未加载
评论 #41829984 未加载
skrebbel7 months ago
(2015)<p>Btw while this code doesn&#x27;t win a prize, I agree with the author that functional style is worth it in many cases, even for a language as wordy and cumbersome as PHP. I still love PHP - its deployment story is still unparalleled and its standard library came batteries included since forever.
评论 #41828516 未加载
huqedato7 months ago
writing&#x2F;thinking in FP style since 2020. Elixir, Js, F#, Julia and even PhP. Never got back to OOP. Never needed to. I realized what a waste of time and frustration had been OOP for me for almost 15 years (Java, C#).
cies7 months ago
You can write OOP-style in C, FP-style in C&#x2F;C++&#x2F;Java or even PHP. Sure.<p>Writing pure FP code (pushing all the side effects to the &quot;edges of the program&quot; in C is possible! But it&#x27;s going to take a lot of discipline from the programmers: there is no safety-net and lots of dreadful boilerplate.<p>Impracticle, but possible.
chx7 months ago
tl;dr: Hardware is cheap. Engineers are expensive.<p>&gt; Instead of fearing the overhead in PHP for function calls,<p>Already in 2015 in almost all applications this is a premature optimization which is rightly known as the root of all evil. Please. Your app will talk to the network, likely run a database query which is like thousands or millions of times slower than a function call. Further, even if there is a measurable difference the cost of hardware which makes that difference go away is very likely to be smaller and much smaller at that than the cost of the engineering hours wasted during maintenance when wrestling with code which was written with a &quot;function calls are expensive&quot; mindset.<p>This doesn&#x27;t mean you don&#x27;t need to worry about performance and scalability but even that is going to be much easier if you have a well structured code.
评论 #41830134 未加载
评论 #41828489 未加载
cynicalsecurity7 months ago
His code is crap, I&#x27;m not even sorry for saying this. For the case he is working with, OOP is absolute must.
评论 #41829064 未加载
评论 #41830221 未加载