5 ms·
PHP uses an imperative programming model and has a very clear URL->source file mapping. This means you can look at the URL, find the source file, start at the t
by erikpukinskis 10y ago
PHP uses an imperative programming model and has a very clear URL->source file mapping. This means you can look at the URL, find the source file, start at the top and trace your way to the problem.
Node (and Rails, and Java and lots of others) use a declarative router. The app boots. Shit happens. Routes exist. Middleware is involved. There's no way to know what code is implicated in a given URL.
If you're a pro and you can afford to spend a year or so learning framework internals while not getting much done, you develop a sixth sense for where in the codebase an error is likely to be, but you need to spend many weeks and months scratching your head to get there.
PHP is much more beginner friendly in this way.
- dcd0101 10y agoYep. It's just easier to start a basic site in PHP when you're new. The typical tutorial is "write these four lines in a file and upload it to any host." You're good to go. Now they shouldn't, but people jumping on JS often spin their wheels until they get pointed to a boilerplate project. It doesn't make for a fair comparison, but it doesn't matter. Now they're trying to wrap their heads around six major libs with loosely overlapping concepts, four build and orchestration tools, and ten-plus scattered files... for "hello world." Then comes the generally miserable process of figuring out how to put it online. Throughout this process the reference material is all at least three weeks old, making it hopelessly out-of-date. I mean, this stuff is often referred to (even here) as a kind of dumpster fire. I can't imagine what a truly new person would think. So while I'm not starting any new PHP projects these days, it isn't hard to see the general appeal.
- clubminsk 10y agoA very interesting... observation! I've never heard about it before... Thank you for sharing your professional expertise with us
- jayflux 10y agoWhen's the last time PHP has been used in this way? Don't people use frameworks these days such as symfony, silex and laravel etc? And then point the web server to the entry point like with any other language?
- developer2 10y agoEven if you're not using a full-fledged framework, a router is a must these days. Anyone dropping a dozen or more .php files in the webroot that all include the same dependencies or header/footer is not following modern practices. And by "modern", I don't mean the newest fad from the past 1-5 years. We're talking about a standard way of doing things that is 10-15 years old. WordPress is a perfect example of extremely poor code. Worth vomiting every time you think about it. No seasoned developer would put together a project the way they still have it. It has nothing to do with "backwards compatibility", or "easy to host with free/cheap hosts". It's not just "not modern", it's actually straight-up unacceptable. WordPress looks like it's put together by a group of php3 juniors writing their first script, having never held a professional job. That's not so much an opinion, as it is a factual assessment that any honest professional developer would give.
- erikpukinskis 10y agoI believe WordPress and Drupal still work this way by default? I'm not a PHP dev anymore.
- krapp 10y ago>Don't people use frameworks these days such as symfony, silex and laravel etc People should, Composer (with PSR autoloading) and nikic's FastRoute get you most of the way to a really nice, lightweight meta-framework barring anything else, for practically nothing. There really is no excuse for the "URL points to a file" model to be a thing anymore. But a lot of legacy PHP code doesn't do that, and likely a lot of newbie code doesn't, because they follow old tutorials, and that model is faster and simpler. Not even Wordpress uses routing AFAIK.
- mysterydip 10y agoHonest/naive question: why not? Plenty of mvp or weekend projects can get by easily with url=page. If it's faster and simpler, what's wrong with doing it? Surely there's room for both on the intetnet.
- 10y ago