DEV Community

Discussion on: Three reasons I like PHP more than Modern Javascript

Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

The reason I like PHP better is the fact that it runs on the server, which means you have ultimate control over what it sends to the client. JavaScript, however, runs on the client, unless you use Node.js. This means it's subject to how the browser interprets your code and displays something accordingly. I like the ultimate control the server side code gives me.

If you're looking at syntax, I honestly don't have a favorite. They're both different and I appreciate both ES2015 and PHP 7.4 for what they are.

Collapse
 
tonipetre_13 profile image
tonipetre

In a simplified manner, you wrote your comment as if php has clearly the advantage because it can't run on client. What? :)

Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

I mean...yes, essentially! It's a benefit to me personally because I like to control every little aspect of the application environment. With PHP you can, because you control everything on the server. With JavaScript (on the client-side) you're at the mercy of the specific implementations of the browsers and hope they interpret your code exactly as you have intended it to.

I'm not saying one is better than the other because I work with both on a daily basis. But to answer your question, yes, to me it has an advantage that PHP doesn't run on the client-side.

If we're talking about Node.js on the server they're equal, because PHP no longer has the benefit over JavaScript in that scenario.

Thread Thread
 
tonipetre_13 profile image
tonipetre

You're talking about node.js as if it is another language and php just works on thin air. And you compare bananas with carrots.

Let me put it this way. With php you can control only bananas. With javascript you can control both banana and carrots.

Thread Thread
 
roelofjanelsinga profile image
Roelof Jan Elsinga

I don't think I've explained myself correctly because that's not what I mean. Let me try again.

PHP doesn't run on thin air and I never meant to suggest that it does. It runs on a server than I can configure and I can control exactly which software packages should be installed.

I understand why you think that I'm saying Node.js is completely different from JavaScript. Of course, it's all just JavaScript and it's not different at all. The reason that I mentioned it, is that it's the way to run JavaScript on the server and that's why I'm only comparing Node.js to PHP because they both only run on the server. PHP can't be compared to client-side Javascript. As you said, they're apples and oranges.

JavaScript is much more versatile and you can do a lot more with it than PHP. It's great on the server and also on the client.

PHP is only on the server. I personally like this much better because I can control everything about the server, which means I control everything that's going on. I like the control, but this doesn't mean it's clearly better than JavaScript. Just because I like control doesn't mean I urge others to only use PHP. Use the right tool for the job.

I'm not saying in any way that PHP is better than JavaScript. They're both great, I use them both with great joy. So I completely agree with you that they're not completely comparable and only compare on one aspect, the server.

I was initially only thinking of JavaScript on the client-side, which is why my point of view might have been very confusing. Apologies for this confusion.

These are all my own preferences and I'm not implying that one is better than the other and therefore everyone should pick one over the other.

I hope this explains my point of view a little bit better. Just know that I completely agree with your comment about the banana and the carrots, you're right.