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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

“Hello, (real) world” in PHP in 2017

172 点作者 skazka16大约 8 年前

33 条评论

vectorpush大约 8 年前
I get that this article is satire, but I think the deepest (perhaps) unintentional insight presented by the author&#x27;s veiled criticism is that the justification for using these tools is presented as &quot;it&#x27;s 2017&quot; and not as a solution to any particular problem. The issue isn&#x27;t the 2017 ecosystem, the issue is the 2017 programmer&#x27;s deference to vanity instead of engineering. All these individual tools exist for a reason, and if your project is already functioning to specification without the use of these tools, <i>you shouldn&#x27;t be using them</i>; doing otherwise is the developer&#x27;s fault, not the tool&#x27;s or the ecosystem&#x27;s.
评论 #13848586 未加载
评论 #13848083 未加载
评论 #13848716 未加载
评论 #13850077 未加载
评论 #13849986 未加载
评论 #13850056 未加载
sixdimensional大约 8 年前
Maybe I am old fashioned and outdated. I don&#x27;t know about anyone else, but it makes me pretty sad that the &quot;modern&quot; way as presented in this article is no longer simple and straightforward and has some severe dependency hell.<p>Not that I&#x27;m saying the structure of modern web applications isn&#x27;t needed and that we haven&#x27;t advanced. Just that the overhead and knowledge required to set up a modern web application is crazy.<p>I am working on a larger .NET web application in my day job... and it requires things like.. Typescript + typings files, Webpack&#x2F;Gulp&#x2F;Grunt&#x2F;etc. and therefore Node.js and NPM, NuGet, .NET Framework, onion architecture, front-end framework (Angular, or React, or..), Entity Framework, multiple databases, web services&#x2F;web API, ASP.NET MVC.. I mean, it&#x27;s just crazy if you step back and think about it.<p>Sometimes I long for the simpler &quot;bad old days&quot;? Oh well, back to my enterprise single page application framework-laden monster.<p>DISCLAIMER: I know we&#x27;re better off today in many ways, and maybe I&#x27;m just getting older and the cognitive load is higher.
评论 #13847765 未加载
评论 #13847608 未加载
评论 #13847566 未加载
评论 #13850006 未加载
评论 #13847909 未加载
robbiewxyz大约 8 年前
Everyone&#x27;s trying to take this literally as the &quot;right way to display plaintext&quot; in modern PHP. In that sense, it is absolutely absurd.<p>But if the idea of a &quot;hello world&quot; is to learn the basic boilerplate that you&#x27;ll need before you start implementing real features, unfortunately for us web developers, this quite accurately represents the minimum before we can even start implementing business logic. With the <i>baseline expectation</i> for a lot of modern SPA-type applications including caching scripts, client-side routing, server-side rendering, working offline, supporting IE9 to iOS to Firefox and all the quirks in between, etc it really is getting to this point.<p>I wish like nothing else that most of this could come out of the box so &quot;hello world&quot; really was a one-liner, but that just doesn&#x27;t seem to be the reality that 2017 webapps live in.
评论 #13848468 未加载
评论 #13849369 未加载
bikamonki大约 8 年前
99% of <i>real-world</i> apps out there could be implemented with a BAAS and some simple JS MVC framework (good ol&#x27; BackboneJS in my flavor, if not jQuery fancy). I am not talking about building million-user-base facebooks and twitters, I am taking about a fuckzillion apps with a dozen at best concurrent users that will thrive in Firebase&#x27;s free tier, a damnzillion worpress sites that never-fucking-ever get updated and would do just fine with good ol&#x27; static html, forever spared from bitcoin ramsomware.<p>Simply put: we forgot how to be engineers (the right solution for the problem). We are all Zuckergified into the fucking hype. Aren&#x27;t we? We forgot that it is WE the experts that should tell clients how to solve their damn problems not just echo some buzz words so we get the damn contracts.<p>This post is NOT satire. It is the very state of current affairs.
评论 #13849992 未加载
kuschku大约 8 年前
We’ve gone full circle.<p>Truly look at the PHP code in this article, the JS dependency hell here and in the recent JS article.<p>Look at the code. At the environment. At the libraries.<p>Who isn’t reminded of what Java looked like years ago?<p>We’ve come full circle.<p><pre><code> ------------------------ </code></pre> Now, if one asks why this is, the answer is pretty simple – enterprise products.<p>To build software of a certain scale, certain technology, patterns, etc are required. These are what we see here again – ORMs, complex dependency systems, complicated frameworks, etc.<p>One might wonder why people even write PHP and JS nowadays, if Java is still faster, JS and PHP are now equally complicated, and Java ported all of the advantages of the others.<p>And, in fact, the Play Framework (which supports Java and Scala) is growing.<p>At the same time, Google’s go is copying the same mistakes Java did in the beginning, with almost all new methods in the standard library taking interface{} – the equivalent of void* or Object, and a simplistic typesystem.<p><pre><code> ------------------------ </code></pre> Why do we, as a profession, create new tools for a new purpose, then force them to adapt to another purpose, until they’ve become identical to the tools we tried to replace?
评论 #13848026 未加载
评论 #13848629 未加载
评论 #13850352 未加载
libeclipse大约 8 年前
Ahahaha I legitimately cannot tell if this is a sarcastic blog post. To me it just sounds like such a joke. It&#x27;s quite confusing.<p>I hope it&#x27;s a joke...
评论 #13847556 未加载
评论 #13847657 未加载
评论 #13848754 未加载
okket大约 8 年前
This is a bit like<p><pre><code> $ echo &#x27;Hello World!&#x27; </code></pre> which if, you think about it, requires a kernel, multitasking, driver independence on various level, many drivers, memory management, possible resource accounting, binary api, dynamic linker, interpreter, etc, etc, etc.<p>All (or at least most) of this seems overkill if you just want to print out &#x27;hello world&#x27;. But it makes total sense if you want to do a little more complex stuff.
评论 #13847981 未加载
ponyfleisch大约 8 年前
While reading i was thinking &quot;..but that all makes sense for any project that&#x27;s larger than a few hundred lines..&quot; and thought the author was just ignorant and needlessly cynical.<p>But at the end of the article, he makes a good point:<p><i>Disputes like “Why do I need PHP if there’s Java?” have become more frequent nowadays. I don’t know who’s in the right, Holly Wars are tricky. But each dispute has an argument in favor of PHP — it’s easy for beginners. To my mind, this argument isn’t valid anymore, which is exactly what I was trying to say in this article.</i><p>The notion of PHP as a beginner-friendly language has in my opinion been a harmful one for a while now. There are still people writing old school PHP apps, and there is the (mildly displeasing) wordpress ecosystem. But for anything serious, Symfony is invaluable. And the gap between old school PHP to modern PHP is almost the same as the one between old school PHP and Java&#x2F;Spring&#x2F;Hibernate, which is kind of what Symfony&#x2F;Doctrine is cloning anyway. Plus if you do Java, you don&#x27;t get the stigma of being in the same category as a professional wordpress template tweaker.
评论 #13849764 未加载
Entangled大约 8 年前
Call me old fashioned but I prefer my code naked, plain php and postgres, nothing else, not even JS. So for me, echo &#x27;Hello world&#x27; is good enough.
评论 #13847726 未加载
评论 #13848903 未加载
lohengramm大约 8 年前
Coincidentally I recently began a new project involving a user-facing PHP app, and even though I have enough ES6 + webpack + react blablabla experience (and some angular, but I didn&#x27;t particularly enjoy it), I decided to just go with good old synchronous requests. It makes things easier and, in this case, development time is key.
DanHulton大约 8 年前
So many people not getting the joke here. This article is a send-off of the idea that PHP is &quot;just easy&quot; anymore, but frankly, misses its shot.<p>Of course it&#x27;s complex when you introduce complexity. So is <i>anything</i> by <i>definition</i>. If you don&#x27;t want to do complex things, you&#x27;re fine. But if you want to have a database, have a framework abstract away the truly dangerous and boring shit, use a modern, type-safe version of Javascript, write CSS in something approaching a maintainable fashion, and deliver a responsive, reactive site, you&#x27;ll have to do something like this, <i>regardless of language.</i><p>Also, the author neglected to set up database migrations, to say nothing of a Dockerfile.
评论 #13848765 未加载
megous大约 8 年前
Hello world! in PHP is simply:<p>Hello world!<p>People forget PHP is still a template language for the web.
camus2大约 8 年前
&gt; But each dispute has an argument in favor of PHP — it’s easy for beginners. To my mind, this argument isn’t valid anymore, which is exactly what I was trying to say in this article.<p>It&#x27;s still is easier AND cheaper to deploy a Hello World in PHP than a Hello World in any other language. You can get a cheap Apache&#x2F;PHP hosting for $2&#x2F;month, use SFTP a get a working app in minutes. The default PHP distribution comes with a lot of extensions.<p>The problem is that PHP doesn&#x27;t help a beginner graduate from a basic webpage to a secure and robust application without having to download a complex framework and meddle with configuration files. IMHO by the time you are tempted to use Symfony you might switch to Java or ASP.net directly.<p>If PHP was really beginner oriented, it would actually do everything it could to use the most secure defaults for every feature, like templating, or sessions.<p>Microsoft attempted to do that with WebPages, which is kinda what PHP should have been if it was really intended for beginners. WebPages mostly use secure defaults. While it doesn&#x27;t prevent spaghetti code it makes having to rely on a complex framework unnecessary.
评论 #13847792 未加载
z92大约 8 年前
Just write &quot;Hello, world!&quot; in a file without the quotation marks, and nothing else. Save, then run. Will print what you asked it to.<p>Default in PHP is to output the bare text. Unless you wrap it in special markup &#x27;&lt;?php&#x27;. That&#x27;s an unique feature in the top languages.
_nalply大约 8 年前
When I first read that I saw the nice girl with the red T-Shirt and thought, wow, the simplest way of writing Hello World in PHP is literally<p><pre><code> Hello World </code></pre> (no &lt;?php and so on).<p>Of course this would be broken HTML but first it displays, and second you could configure the web server to send<p><pre><code> Content-Type: text&#x2F;plain </code></pre> without charset parameter because YAGNI.
quickben大约 8 年前
&#x27;old&#x27; vs &#x27;modern&#x27;:<p>I run a search engine. It is big enough that it needs drives, caches, firewalls, VMs etc.<p>The front end is php. No classes, no phpadmin, etc. Just pure vanilla php.<p>Sometimes I tail &#x2F;var access logs. People try all kinds of urls routinely fishing for weaknesses.<p>It&#x27;s 2017. It is slow to code and keep the attack surface that minimal.<p>0 intrusions so far.
xchaotic大约 8 年前
A bit like the other submission on learning JS in 2016. I find that I am getting dragged down by complexity. Even simple tic tac toe game that I was planning to write in vanilla js took me via jQuery, npm, Firebase etc. Sure its production ready but I just wanted to write something for fun. Wasn&#x27;t really fun.
评论 #13847737 未加载
评论 #13848702 未加载
iamdave大约 8 年前
This seems like a decent primer for someone who already has their heads wrapped around application development, but absolutely horrid for someone who wants to pick up a web language for the first time and create that first simple output.<p>That first simple output IMO is critical for retention and engaging the language knowing exactly what you&#x27;re going to get by looking at dirt simple code like echo hello world; at least it was for me as PHP was one of my very first languages<p>The intent is well meaning in this &quot;real world&quot; hello world, but I feel like taking the espoused mentality in the opening paragraph, one is throwing construction tools at a toddler who asked for a box of legos for christmas.<p>Curious what others think
评论 #13847540 未加载
partycoder大约 8 年前
I am going to leave this here...<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rule_of_least_power" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rule_of_least_power</a><p>If you enjoy overengineered code, check:<p>- Fizzbuzz Enterprise Edition: <a href="https:&#x2F;&#x2F;github.com&#x2F;EnterpriseQualityCoding&#x2F;FizzBuzzEnterpriseEdition" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;EnterpriseQualityCoding&#x2F;FizzBuzzEnterpris...</a><p>- Fizzbuzz in Tensorflow: <a href="https:&#x2F;&#x2F;github.com&#x2F;joelgrus&#x2F;fizz-buzz-tensorflow&#x2F;blob&#x2F;master&#x2F;fizz_buzz.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joelgrus&#x2F;fizz-buzz-tensorflow&#x2F;blob&#x2F;master...</a>
mike503大约 8 年前
I don&#x27;t mind this article as long as it&#x27;s classified as satire.
评论 #13847729 未加载
评论 #13848440 未加载
wanderr大约 8 年前
&quot;You can’t build a decent modern application without frameworks.&quot;<p>Bullshit, especially on the PHP &#x2F; backend side. It&#x27;s 2017, we should know how to avoid over engineering simple things.
hugodahl大约 8 年前
Then, come peer code review&#x2F;pull request by a senior&#x2F;lead person, will be declined with the comment &lt;? echo &quot;Hello, overengineered world.&quot; ?&gt;
mndewitt大约 8 年前
Using React, TypeScript, and Webpack in this context is ridiculous. Use tools that solve the problem at hand, not just because someone else is doing it...
评论 #13848583 未加载
iDemonix大约 8 年前
Nailed it.<p>I love PHP and it&#x27;s still my main language, but the reason so many projects never get completed is because of this. Really I should just accept that for an MVP, Laravel and a static front end with some old school jQuery where required is fine.
评论 #13847757 未加载
methodin大约 8 年前
I enjoy that the concept of Hello World engulfs a full-stack deployment. Every one of these dependencies has a Hello World and the fact that people might not be aware of them is a real problem.
buro9大约 8 年前
The only thing missing from projects I&#x27;ve seen up close is that the value would be selected from the database using a stored procedure.
评论 #13847731 未加载
CCing大约 8 年前
Sometimes I miss the old good days with PHP mixed in HTML.<p>Maybe wasn&#x27;t the best solution but it worked...and was fast too.
评论 #13847835 未加载
评论 #13847839 未加载
wernercd大约 8 年前
&gt; Summary: Disputes like “Why do I need PHP if there’s Java?” have become more frequent nowadays. I don’t know who’s in the right, Holly Wars are tricky.<p>Who is this Holly and why are we starting a war over her?<p>All this talk about &quot;Enterprise over engineering&quot;, is all this needed, tool-overload-hell, etc... and I just can&#x27;t stop thinking about Holly and how to stop the war over her...
guillem_lefait大约 8 年前
What about internationalisation ? You have to add i18n.
trhway大约 8 年前
well, it is our job as programmers is to waste ... err ... utilize all that hardware power&#x2F;bandwidth that Moore law has been showering us with...
nillawafer大约 8 年前
Once you&#x27;ve spent all this time setting up a NodeJS stack.... why use PHP at all? Ie. just use Node for the API&#x2F;Server, you&#x27;re already setup, and the stack would be 100% one language.
评论 #13850088 未加载
jakon89大约 8 年前
What is the point in writing blog posts like this?
评论 #13849035 未加载
Ambrosia大约 8 年前
Right. Let&#x27;s just delete everything and go back to a world where even more websites are packed full of vulnerabilities, written in spaghetti PHP!
评论 #13850277 未加载