I have read that PHP is falling by the wayside to make room for newer, better scripting languages. I hope that this is not true because PHP has served me well for many years. I find it difficult to believe that another server-side scripting language can provide more than PHP does and has done over the years.
That said, what scripting language should I be aware of that may be - or is - a current replacement for PHP?
I donāt know anything for certain, but I canāt imagine PHP disappearing any time soon. When you consider the sheer number of websites that rely on it, and a number of popular CMS and frameworks, it would leave a big hole in the web if it went away.
There are other languages you can try, I donāt know a lot about them, as I have not tried anything else, Ruby is one, but Iām sure there are more.
I was surprised when I heard a very well know/respected web instructor say that there were more modern alternatives to using PHP. He was not ranting, he just mentioned it in passing and this gave me pause. Thus my query here.
My head hurts from all of the ānewā web āappsā running loose in the wild. PHP suits me just fine, but I am open to anything that will make my web building easier. I am assuming that the end result will be superior in some way.
PHP will not disappear anytime soon, so I would not worry about that.
The fact that X said that, does not mean that it is correct. It can be their personal opinion, but no means does this mean you should drop PHP and move on.
There is no best/worst language, of course, different languages are better/worse at specific tasks. This is why you need to make a decision based on the task at hand, and decide if you will use language Y that is faster to do this, or stick with language X, that while it is slower at executing the task the development will go quicker since you know the language.
On a side note, if you are looking for a different language, I would not recommend Ruby. Instead, look at Node.js it complement PHP very well, is quite popular now and can also very easily be used as sole language for a project.
Keep in mind that PHP runs a significant portion of the Internet. It runs WordPress which has between 35-40% of the world sites and about 15-17% of the top 500 websites. Besides WordPress, it also runs the number 2 and 3 CMSā which include Drupal and Joomla.
Believe me, it is not going anywhere anytime soon.
Ah, Node.js. That was mentioned in the conversation about PHP as I recall. So that was probably why the statement about PHP was made, if indeed, Node.js is superior to PHP in some way. I know very little about Node.js, which is why I never made the connection.
I am truly comfortable with PHP and appreciate all that it enables me to do. I do have plans to take a look at Node.js, but if PHP āaināt brokeā, why bother fixing it?
class Author {
public function __construct(public string $first_name = '', public string $middle_name = '', public string $last_name = '') {}
public function name(): string {
$middleName = ($this->middle_name != '') ? ' ' . $this->middle_name : '';
return $this->first_name . $middleName . ' ' . $this->last_name;
}
}
$author = new Author();
$author->first_name = 'Edgar';
$author->middle_name = 'Allan';
$author->last_name = 'Poe';
print $author->name() . "\r\n";
And this is the class I wrote for PHP.
<?php
class Author {
public function __construct(public string $first_name = '', public string $middle_name = '', public string $last_name = '') {}
public function name(): string {
$middleName = ($this->middle_name != '') ? ' ' . $this->middle_name : '';
return $this->first_name . $middleName . ' ' . $this->last_name;
}
}
$author = new Author();
$author->first_name = 'Edgar';
$author->middle_name = 'Allan';
$author->last_name = 'Poe';
print $author->name() . "\r\n";
The only difference between the 2 different codes are that for the PHP one, it has the starting PHP tag. Other than that, identical code syntax. And if you look at the version of HHVM Iām using, itās 4.8.8 which should supposedly have removed support for PHP because Hack version 4.0 was supposed to have dropped support for PHP.
More Importantly, PHP is still being updated. The argument that 60% of the web is based on PHP, would only mean legacy support for an ever dwindling number of sites. PHP is still evolving forward and new sites are being written in the language and new implementations are being created.
PHP has always had itās lovers and haters, but there is no need to worry for its existence.
No, itās def not dying. Despite the rumors circulating, PHP is still going strong in 2021. The thing is that there is a wider choice of backend languages than it used to be years ago. Therefore, PHP is not just omnipresent anymore in the backend, but is still among the popular alternatives.
āI donāt like how language X does this.ā āSo write your own.ā āā¦ okayā
-The birth of 90% of programming languages.
It would be foolish to suggest that programming languages are stagnant; theyāre not. are there āmore modern alternativesā? Yup. There always will be; there are āmore modern alternativesā to python, and java, and C++, and C#ā¦ but theyāre all still used.
Just because an alternative exists, doesnāt mean it will supplant the previous language.
My personal opinion is that there is no āsuperiorā language, some are just better suited for a task.
For node.js, the advantage is that it is asynchronous which means it is very quick as long as you have nonblocking operations.
On the other side, the second you have something you want to do that needs to be blocking, it is more difficult to work with. For example create an set of database records where one depends on the other, and they need to be entered into order. (Still possible, but require more work than in PHP).
On this note it is possible to create non blocking PHP as well, and there is several interesting libraries that does that, giving you a similar speed boost that you would get with Node.js.
There have been chicken little cries of āthe sky is fallingā with regards to PHPās pending demise for decades. The only way PHP could die is if browsers decided they would no longer interpret and render PHP code, right? I mean, with version 8.0, you have the most robust version available, ever. And I do believe there is not much that cannot be developed using PHP and javascript, so Iāll be using it till Iām done, I would guess. If browsers decided to stop using PHP, it would make the Y2K crisis-non-crisis seem like a hang nail, by comparison. I, of course, have already done my own stream-lined browser to package with my web apps, so, even the lack of popular browser support would not accomplish much to stop PHP. So, when you hear these rumors, be a smarty pants and just laugh at the perpetratorā¦
I came from a C and Pascal background which are/were remarkably difficult to build web pages so had to learn PHP because it could handle databases! First impressions were to be amazed at the "weak typeing (Wiki) and learnt to accept but strongly objected to the programming methods.
PHP has certainly changed since the early days Iām delighted to say and not only introduced Strict_typing but also now has a JIT compiler. This is certainly a vast improvement and looking forward to experimenting.
Unfortunately for PHP the Internet/World Wide Web has vastly changed since first starting late last century. PHP now struggles to handle web-pages that have many hits per second. New languages have been developed to cater for sites that have vast traffic and subsequent computer processing. The Stock Market springs to mind as one such site and also Facebook.
New languages such as Golang, Rust are example languages that have been developed to cater for these cases.
It will be a very long time before PHP āfalls by the waysideā.
yes, PHP, a Hypertext Pre-Processor (Dont ask me why that translates into PHP instead of HPP), processes the file at the server end, and returnsā¦ i will say browser-interpretable code (again, PHP is perfectly capable of mimicing any output; javascript, HTML, jpg data, etc. Itās perfectly valid to put into your img tagās src a PHP URL, as long as the PHP page returns something that looks like an image).