Live data from Hacker News

PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

belitsoft.com

31–40 of 61 posts

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#31
post #19

Earlier quoted context omitted.

> unzip this file in that folder it's more like "copy these files via ftp to this host" (p.s. that also includes your config.php with plain text passwords of course)

The problem with the "copy these files" approach, even more than dealing with FTP, is that the upgrade process winds up being "copy these files, but be careful not to overwrite any changes you made". Applications like WordPress or Piwik come with a self-updater, but then you wind up with having to fiddle with the permissions to let the application overwrite itself. I got fed up with this a few years ago and started b…

>> Applications like WordPress or Piwik come with a self-updater, but then you wind up with having to fiddle with the permissions to let the application overwrite itself

Tell me about it! It took me an entire day to figure out how to configure a WordPress install in order to allow it to self-update (without ftp). To do it by only granting owner and/or group write permissions, you have to figure out that you need to modify wp-config.php to define the "FS_METHOD" constant with the value "direct". Without this, WordPress code tries to be super clever with its umask settings, which only makes things worse.

It quite literally took an entire day to set up WordPress to self update. It's easy if you chmod 0777 nuke the entire install, but extremely complicated to set up with acceptable filesystem permissions. WordPress is designed to be sloppily dropped in a webroot, not to be installed by intermediate users who care about security. Well, as "secure" as WordPress can be. And to be honest, the most secure WordPress installation would be incapable of self-updating, as you're granting the web user write access to the entire installation - not just for updates, but for any vulnerability.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#32
post #19
post #17

Earlier quoted context omitted.

> in your terminal You just lost a nontrivial percentage of PHP developers. Far and away the most compelling feature of PHP for a lot of their target audience is that the deploy model is "unzip this file in that folder". If I want to host my own web site but I don't want to "learn to program" there is no alternative.

> unzip this file in that folder it's more like "copy these files via ftp to this host" (p.s. that also includes your config.php with plain text passwords of course)

A lot of things happened in php world,since you last checked, which is apparently ~ 5 years back. for starters go read about Magento 2 codebase and its code organization and deployment strategy. Whether you do FTP based file deployment or sophisticated CI/CD build, it all depends on developer not programming language you are using.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#33
post #29

There's still people working on Visual Basic 6 as well. That doesn't mean there are no viable alternatives.

Faced VB6 professionally, there are viable alternatives, but end users don't buy your software because of what technology you made it with, or originally made it with. They buy it if it works and does what they need. It comes down to viable transitions and the resources needed to make it happen. Indeed from the last 6 years, companies are more willing to try out new technologies, like node, or even docker! But only p…

You can imply node.js is not a viable production server solution. But you should rather be more explicit why. I am curious about your perspective.

PHP as a project includes a templating engine, a scripting language, and a lot of native code built without a modern approach.

node is a more scoped project. Doesn't implement its own scripting language, and doesn't include a templating engine and a lot of the stuff PHP does. It focus on doing a single thing well. The native part of it is libuv, which uses a consistent approach: non-blocking asynchronous I/O.

Many other projects also build on top of libuv and v8, and any improvements coming from those integrations ultimately benefit node.

In comparison, PHP is one large project encompassing everything. As a result, I won't expect PHP to move as fast. It's a larger project with lots of backward compatibility concerns to take care of.

I know that PHP has known large deployments but none of those run on the reference implementation. node.js does have large deployments running on its default implementation.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#34
post #9

Earlier quoted context omitted.

TBH, PHP is viable for pretty much exactly as long as Wordpress survives and uses it. If that changed, I wouldn't fancy PHPs chances.

The vast majority of web sites run PHP for better or worse and that code ain't going nowhere. The performance characteristics of Node are completely irrelevant for most sites. The developments model's inherent complexity and the moving target, however, matters very much.

> The vast majority of web sites run PHP for better or worse and that code ain't going nowhere.

The vast majority of blogs that are build in Wordpress. Remove all the blogs and corporate websites and I bet that's not the case anymore.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#35
post #9

Earlier quoted context omitted.

TBH, PHP is viable for pretty much exactly as long as Wordpress survives and uses it. If that changed, I wouldn't fancy PHPs chances.

I disagree. I've been using PHP for about eleven years now, even since the bad old days of PHP3, and I have never used, and generally advise against using, wordpress. PHP will be around long after wordpress. I do concede that if PHP went away, WP would somehow survive, like some kind of post-nuclear cockroach.

I'm in the same boat. I cranked a lot of things out with CodeIgniter back in the day. Expression Engine is superior to WordPress but if you like either I'd suggest Craft CMS now and moving forward. For general apps, I use Laravel or Lumen. And React PHP for scraping. And don't forget The League [1]. Lots of great PHP stuff out there.

[1] https://thephpleague.com

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#36
post #12

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…

When'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?

Even 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.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#37
post #23

Earlier quoted context omitted.

Honest/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.

Having a router allows you to not have all of your files be web accessible, by using a single point of entry and a whitelist for all possible paths. Most projects which map PHP files to URLs have everything in the web root. If it's just a small brochure site with a few pages then it's no problem, but forums and larger projects built like this can leak information and expose vulnerabilities when PHP files which weren'…

>> not have all of your files be web accessible

cough wp-config.php cough

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#38
post #23

Earlier quoted context omitted.

Honest/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.

Having a router allows you to not have all of your files be web accessible, by using a single point of entry and a whitelist for all possible paths. Most projects which map PHP files to URLs have everything in the web root. If it's just a small brochure site with a few pages then it's no problem, but forums and larger projects built like this can leak information and expose vulnerabilities when PHP files which weren'…

> Having a router allows you to not have all of your files be web accessible

Having a router may make it easier, but it's not the only way.

You can just put your libraries, passwords, etc., in some directory outside the document root.

    /var/www/example.com/public
    /var/www/example.com/lib
Then you use "include" to get them.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#39
I maintain a mountain of PHP. What attracts me to JavaScript is its syntax:

PHP:

    $fruit = array('apple', 'banana', 'orange');

    $fruit_colors = array(
        'apple' => 'red',
        'banana' => 'yellow',
        'orange' => 'orange'
    );
JavaScript:

    var fruits = [ 'apple', 'banana', 'orange' ],

        fruit_colors = {
            apple: 'red',
            banana: 'yellow',
            oranage: 'orange'
        };
That's like 20,000 fewer keystrokes and much easier to read. My favorite new feature in PHP is the short array syntax.

Even those less minimalistic than me, I think the draw to Node is the language, the consistency of having the same language front and back.

Much ado is made about which one is faster. But I would say roughly 99% of web apps are CRUD apps, with a few users per hour, and the bottleneck would be the database anyway.

For me what PHP has going for it is my familiarity with it. Plus, despite all the nitpicking articles, it is rock solid, especially compared to Node. And compared to Node, PHP is a hyper-organized library of everything you need, just an arm-length away.

Re: PHP vs Node js... Let's be honest: Node.js couldn't kill PHP. Why?

#40

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…

Yep. 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.

Post reply on HN