JavaScript vs. PHP

Whomever wrote this article:

… doesn’t know PHP very well.

#1.The author claims PHP can work with “HTML only” while JavaScript can work with “HTML, XML, and Ajax.”

PHP has two major implementations of XML - a custom parsing framework and also SimpleXML. Then, cURL gives it the same general capabilities of Ajax and much more (e.g. IMAP/S, FTP/S, SFTP/SSH, etc), depending on the underlying libraries. On top of that, it can be used for simple shell scripts that have nothing to do with HTML. Saying it can only work with HTML is ridiculous.

#2. PHP has functionality for async scripting. The -default- way it runs is synchronous, since it was built with the architecture of a web server plugin. But saying it cannot run async is ridiculous.

#3. As far as speed goes, there are a variety of ways to implement it to your needs (e.g PHP-FPM to have a pool of processes ready to go) and on top of that, PHP can run custom-compiled extensions (which is made easy with some 3rd part tools). Those extensions are usually compiled with C++ or C, so they can perform like lightning compared to any JIT scripting.

So yeah, if you are a PHP novice, then you might not realize everything it can do, but you shouldn’t be trying to write an article on something you don’t know well.

#4. The article is titled PHP vs. JavaScript but it’s really PHP vs. NodeJS. Because if you are dealing with
nothing but client-side, browser-based JavaScript, then JavaScript would make no sense at all. It’s not even comparable.

NodeJS is great, but it should not be a “pick one” situation. They both have their strengths and weaknesses, and PHP should probably be equal to or one point ahead of NodeJS given the above points plus the sheer volume of historical knowledge on just about every question you can think of, plus the availability of PHP developers. There’s almost 25 years of people asking PHP questions and a ton of developers know PHP which means the business doesn’t have to pay a higher price for someone who has mastered a more recent technology like Node.

I do wish the author made plain that each and every claim was his own personal perspective. There are quite a few bits with which I disagree, even when I stop and “give it five minutes”. Both are very powerful languages, and I still code back and forth between them. I really enjoy coding PHP, and I very much love working with javascript.

Some of his points are valid, sure, but the article seems to start with, and stick to, a bias. He does make a solid case for the use of each, but I don’t think it’s an either-or. And honestly, the syntax between the two aren’t so different that there’s a painful learning curve in either direction.