TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Taking PHP Seriously (2016)

139 点作者 ziodave超过 4 年前

31 条评论

pqb超过 4 年前
Discussed previously:<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12703751" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12703751</a><p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15262981" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15262981</a><p>PS. Would you mind adding a [2016] in the title? It will show readers they probably need to take a historic context to understand the article correctly.
paxys超过 4 年前
The best language for a startup is one the founders know the best. Every other discussion will at best make a 1% difference.
评论 #25283056 未加载
评论 #25282708 未加载
评论 #25283028 未加载
评论 #25283439 未加载
评论 #25284387 未加载
评论 #25284047 未加载
评论 #25283097 未加载
评论 #25282781 未加载
评论 #25282836 未加载
评论 #25282787 未加载
kypro超过 4 年前
PHP was the first language I learnt and although I don&#x27;t use it as much today I still think it&#x27;s a great language for startups.<p>Languages like Java, Node, C#, etc are great but unlike PHP you can&#x27;t just drag and drop a .php file on a webserver, point your browser at it and go.<p>Basic things required for web development like connecting to a MySQL database are made trivial in PHP.<p>Code is executed synchronously in PHP and as mentioned in this article requests are stateless which makes the logic much easier to follow and debug than say Java where you have state or Node where you have callbacks and promises.<p>PHP also gives you the flexibility to write procedural, OO, or even functional code. This flexibility is off putting to some, but it allows the language to be useful no matter what your skill level or preferences are.<p>Another thing that&#x27;s easy with PHP is debugging. You don&#x27;t have to worry about compiling code or accidentally taking down your entire server (most of the time) if you encounter a critical error. If one of your PHP pages runs into an issue you can enable debugging with a line of code, make your fix then hit the refresh to see if it&#x27;s working.<p>I learnt to code writing PHP when I was 16 years old. Me and my friend had an idea for a startup but neither of knew how to program beyond a little bit of ActionScript. We were good with computers, but if we decided to use Java I&#x27;m certain the project would have never have gotten off the ground because of the steep learning curve.<p>PHP allowed us to skill up with the language and enabled us to move fast despite not really knowing what we were doing. Writing PHP in the ICT room at lunch with my friend was some of the best memories I have of school... I doubt I&#x27;d be doing this today if it wasn&#x27;t for how much fun I had learning and building stuff with PHP when I was younger.
评论 #25290255 未加载
blunte超过 4 年前
It&#x27;s like an ugly C.<p>It&#x27;s a perfectly reasonable choice for web development, just like a Chevy Caprice is a perfectly reasonable car for a taxi service (as evidenced by the thousands of them in NYC, still plodding along). You&#x27;d still rather ride in a Mercedes E430 taxi (long time European standard)... unless you had never experienced both, in which case you probably think the Caprice is just fine.<p>And if you knew Ruby, Python, Java, C#, Kotlin, or better yet F#, Clojure, or Elixir, you&#x27;d most likely enjoy using one of them rather than PHP.<p>There are three reasons to use PHP.<p>1. it works<p>2. it is well integrated with web servers<p>3. you can find some of the cheapest contract labor who know how to program in it (compared to other, less common&#x2F;popular languages)<p>Bonus 4. you need to extend Wordpress by writing a plugin or theme (and Wordpress is the Caprice of CMSs...)
评论 #25283823 未加载
评论 #25286734 未加载
ransom1538超过 4 年前
Long live PHP.<p>15 years of PHP dev work. Games, mobile apps, health care, etc. I have been unemployed for 2 days in 15 years. PHP runs %80 of the internet. Talk to anyone at facebook that wears a suit on friday -- they code PHP (and it seems to scale for them). I think I will be 90 years old hacking on PHP.If you really don&#x27;t like how the arguments are passed just use an IDE. Or get stuck with real problems like a transition from python2 to 3. (wtf)
评论 #25283221 未加载
评论 #25284835 未加载
评论 #25282985 未加载
评论 #25283811 未加载
评论 #25289704 未加载
latenightcoding超过 4 年前
Somewhat unrelated comment, but the fact that PHP got so good and most people are still not willing to give it a second chance goes to show how hard it is for a language to regain market share after people left for greener pastures.
评论 #25283825 未加载
评论 #25282952 未加载
评论 #25284297 未加载
评论 #25282871 未加载
评论 #25290550 未加载
hardwaregeek超过 4 年前
I don&#x27;t doubt that PHP has some benefits. That said, the reasons cited in the blog post don&#x27;t seem that unique to PHP.<p>&gt; By starting each request from a known state, we get a kind of organic fault isolation; if request t encounters a software defect and fails, this bug does not directly interfere with the execution of subsequent request t+1.<p>Is there a modern web framework where a failed request can crash the entire server? I&#x27;m not sure this is a problem in other languages.<p>&gt; Second, concurrency. An individual web request runs in a single PHP thread.<p>Huh, so maybe this could be an interesting concurrency model. But it&#x27;s not that different than say, Node&#x27;s promises. The only difference is Node&#x27;s promises aren&#x27;t tied to literally making a web request.<p>The restarting the server problem also is not an issue. Almost every mature web stack I&#x27;ve seen has hot reloading. Yes, even in 2016.<p>There are certainly reasons to use PHP, but the trap I see a lot of PHP proponents fall into is assuming that the benefits they see are somehow unique to PHP. Laravel fans love to cite packages, migrations, the ORM, etc. as reasons to use PHP. I certainly think all of these are great features but they&#x27;re not unique to PHP.
评论 #25290637 未加载
评论 #25286698 未加载
rabuse超过 4 年前
This seems to be an unpopular opinion in the tech world, but I honestly enjoy working with PHP. It&#x27;s such a simple, robust language, and you can use it in many different ways, depending on what you&#x27;re building (OOP, scripting, microservices, etc).
评论 #25284762 未加载
评论 #25282749 未加载
评论 #25283093 未加载
评论 #25283264 未加载
apeace超过 4 年前
So the entire argument is that PHP is single threaded and each request starts with no state? Am I missing anything else?<p>I’m trying so hard not to rant here, so I just wanted to confirm that those are the only positives he outlines about the language.
评论 #25282746 未加载
评论 #25282667 未加载
评论 #25282548 未加载
评论 #25282552 未加载
bastawhiz超过 4 年前
Besides the common gripes, the thing that ruined PHP for me was learning that empty(&quot;0&quot;) is true. I learned this the hard way when this edge case caused an incident and I spent half a week rewriting code to be...not that.<p>PHP has some great properties, and if you&#x27;re tolerant of its sharp edges, great. But up until recently (and perhaps still?) it&#x27;s got many of its safeties turned off by default. When I left PHP, (insecure) mysql bindings still came included pretty much universally, but often not PDO. They have every amazing helper function under the sun at your fingertips (urlencode and htmlentities!) but also some tremendously dangerous ones (backticks! variable variables!).<p>What&#x27;s most striking to me is that Slack is 100% off of PHP now (onto Hack). There&#x27;s something telling when neither the syntax nor the runtime nor the standard library are sufficient for the biggest users of a language. With recent versions of the core runtime finally getting fast, I wonder if they&#x27;ll rip off the bandaid and break backwards compatibility to dull some of the larger sharp edges.
tomxor超过 4 年前
I&#x27;ve ended up treating PHP like shell scripting, with that mind set it becomes much more bearable for writing new code in... much like bash, you don&#x27;t dare write anything <i>too</i> complex, yet can appreciate it for being a well positioned language for the specific type of task (and I say that having written lots of quite long but well composed bash scripts).<p>Unfortunately PHP <i>is</i> more capable as a language than shells while still having all those poorly thought out parts that will make you hate it if you try to exploit it to it&#x27;s full capability.<p>Of course this mind set doesn&#x27;t help much for existing massive code bases where all of the application logic is written in PHP.
tyingq超过 4 年前
<i>&quot;First, state. Every web request starts from a completely blank slate. Its namespace and globals are uninitialized, except for the standard globals, functions and classes that provide primitive functionality and life support.&quot;</i><p>It was somewhat amusing to see some of the same people that made fun of this later espouse the virtues of AWS Lambda.
andreygrehov超过 4 年前
Given PHP 8 has been released, does Hack provide enough value to consider it as an alternative? My take on it is no, but I&#x27;m curious about other people&#x27;s opinions.
评论 #25282685 未加载
评论 #25282604 未加载
aussieguy1234超过 4 年前
This was written 4 years ago. Since then, PHP7 and PHP8 have incorporated many of the benefits of HHVM.
评论 #25282874 未加载
nickthemagicman超过 4 年前
PHP after 5 is great. I guess from PHP 7 on things changed pretty significantly.<p>Combine it with Laravel and nginx, and you&#x27;ve got an enjoyable stack in my opinion.
评论 #25283242 未加载
asamarin超过 4 年前
Article written in 2016, mind you
ThePadawan超过 4 年前
I get it. Old PHP was a joke, so people (including me) are biased against it.<p>I would personally love to get beyond that bias. However, every single time I install any piece of software written in PHP, it&#x27;s simply a nightmare (e.g. Matomo, rss-bridge).<p>Unhelpful error messages, unexplained or undocumented features, all held together with metaphorical duct tape.<p>I always have to dive into the source code to figure out things that a README or tutorial should be able to help me with.<p>I can&#x27;t recall ever doing that with tools written in any other language.<p>Is it simply that PHP programmers care so little about their products?
评论 #25291948 未加载
huskyr超过 4 年前
As a language i enjoy Python and Javascript a lot more than PHP. Especially the major PHP frameworks and libraries tend to be too complicated and Java-esque for my liking. There are some nice simpler alternatives, but they tend to get abandoned in favour of the larger projects.<p>But when looking at PHP in terms of deployment and making traditional SQL-based websites&#x2F;API&#x27;s it&#x27;s unmatched. Just reading up on deploying Python code using uWSGI, or connecting to a SQL database gives me headaches, and the confusing package management and versioning system makes things even worse. Running Node feels unpredictable, with the server crashing because you forgot to catch an exception somewhere or having some weird state.<p>With PHP it&#x27;s just: write the code, copy the files to a server and stuff (usually) just works. That&#x27;s why i keep using it. Not that pretty, but it always gets the job done.
Superfrag超过 4 年前
&quot;For instance, 123 == “123foo” evaluates to true (see what it’s doing there?), but 0123 == “0123foo” is false (hmm).&quot;<p>Can anyone explain this to me? I know if a string starts with the number, PHP takes the number part and throws the rest, so &quot;0123foo&quot; should be 0123 for the comparison, so why is that false?
评论 #25282718 未加载
okareaman超过 4 年前
I&#x27;ve used a lot of PHP in my life and now feel Go is better suited for my needs. My gut tells me Go libs are written by professionals, while there is a ton of PHP code written by amateurs to contend with. I&#x27;ll know more once I get further into Go.
评论 #25283079 未加载
spacemanmatt超过 4 年前
How seriously am I supposed to take a language that executes after numerous syntax errors that should be fatal compile&#x2F;runtime errors in every other language? It keeps on trucking no matter what &quot;code&quot; you give it.
评论 #25283150 未加载
rangoon626超过 4 年前
I&#x27;m admitting it. I LIKE PHP. It&#x27;s fun and incredibly easy to work with. I have inherited messy code bases. I have inherited nice code bases. But getting it up and running is _never_ a problem that I have had.
hashamali超过 4 年前
I hated PHP for the longest time (worked extensively with PHP5 and various homebrewed frameworks in the early 2010s), but I gotta admit, it&#x27;s come a long way with PHP7+ and great frameworks like Laravel.
ed25519FUUU超过 4 年前
&gt; <i>Slack uses PHP for most of its server-side application logic, which is an unusual choice these days. Why did we choose to build a new project in this language? Should you?</i><p>We already know the painfully obvious answer to this question even if it&#x27;s not listed in the &quot;reasons&quot;: because the technology decision makers were comfortable with PHP and they <i>wanted</i> to use it.
评论 #25282520 未加载
haffla超过 4 年前
The argument that you don&#x27;t have to restart the server after editing a file? I mean I&#x27;ve used a couple of web dev environments and I know for a fact that Rails, Django and Express all come with some sort of automatic reloading in development - provided by the framework itself or by a library. Quite sure there is a solution for most environments.
评论 #25283259 未加载
blibble超过 4 年前
how&#x27;s PHP&#x27;s websocket support?<p>presumably if it&#x27;s a thread per websocket then they&#x27;re using something else to serve that?
评论 #25283159 未加载
评论 #25282992 未加载
评论 #25282657 未加载
zapt02超过 4 年前
A bit sad that despite Slack being (or being built) on top of PHP, there is still no official PHP SDK four years later.
postalrat超过 4 年前
Anyone here want to share their opinion&#x27;s on Magento? The small time I spent with it left me with a feeling it was the most over engineering piece of software I&#x27;ve ever worked with. It&#x27;s made to build a market for modules to buy and isn&#x27;t made to run an e-commerce site.<p>All written in PHP.
评论 #25284233 未加载
评论 #25284549 未加载
hu3超过 4 年前
Do they still create new backend code mainly in PHP or have they also adopted other languages for new code?
fmakunbound超过 4 年前
Why do engineering blogs have to share this stuff? Is it an attempt to hire?
评论 #25287166 未加载
say_it_as_it_is超过 4 年前
I thought Slack was running on Perl CGI..