Would a compiled version of PHP be great, that's the question that i've asked myself alot. Perhaps making softwares in PHP is pointless because the language is very, very slow but some people who doesn't know other languages than PHP would find it useful, what do you think.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (23)
Okay, you found my trigger, here is my rant: your assumption is incorrect: PHP is not very, very, slow. Already in 2016 comparsions showed that PHP 7+ is going to be one of the fastest scripting languages. In 2018, PHP 7.2 is the current, and fast, version.
But this is not even the end: It is also incorrect to assume, PHP is always not compiled. PHP 7.+ uses optimized Operation-Code-Cache by default, which can be looked at as the compiled code. This cache got big improvements in PHP 7.2+, which makes it an even faster language, at least upon repeated execution (which is clearly given by most scenarios in which PHP is used).
PHP is not bad, they made it great again. PHP is not even slow (whatever that means) anymore. It is even fast, compared to other scripting languages. Also, consider the fact that not every slow language is bad. It is a feature, not a bug, for a scripting language to be a little slower (NodeJS, Python, R ... all slow!). It is simply not all about them microseconds.
Totally agree, PHP 7.2 is very fast and it works great. Also, php being a scripting language it has many advantages over a compiled language. When I need stuff done fast and simple (lets say a web page that consumes a public JSON API and shows it on the page) it is so much faster to do it in PHP that in .Net Core.
When was the last time you did serious PHP? Your claims are random rants at best. PHP is not very very sloooooooow, your I/O ops, DB queries are.
PHP7.2 with opcache is a breeze. There are also frameworks like phalcon, yaf etc which are probably what you meant by "compiled" (or analogous). PHP8 with JIT will be a different animal.
Have you even tried swoole?
Iโll echo the words of others: PHP is not slow.
If you create N levels of abstraction, donโt optimize, etc - youโre making it slow. I run PHP infrastructure for my customers, we service an average of 2M unique requests per day per customer, thatโs per 1 pave hit, average is 15 complex pages. We do this with a homemade framework, tons of dB queries due to site builder container logic, and hardly cache anything - each machine only uses about 1 GB ram at peak. PHP is not slow, the abstractions are.
Facebook first released HPHPc in 2010 to transpile PHP to C++ for its website. Then they released HHVM in 2011 which is a VM with a JIT compiler the sole goal is to make PHP faster. They also created Hack which is a PHP dialect with static typing supported by HHVM.
I believe it's still how they build the Facebook website.
I think this covers your use case.
Another benefit of Hack is an implementation of asynchronous programming
It wouldn't make very much difference at all.
It's been my experience that when an application is slow, the bottleneck is nearly always one of the following:
These are all issues that can be resolved by refactoring queries, using eager loading, and caching responses where appropriate. A compiled version of PHP wouldn't help with these.
In addition, if you have the opcode cache enabled (which you should in production), your PHP code gets compiled into bytecode anyway, so in a sense it is compiled.
In the extremely unlikely event that you do come across a situation where the language itself is the bottleneck, it is possible to write an extension to do it in a lower-level language. I've tried Zephir before for this as it's easier than writing a PHP extension in C, but to be honest, I found it was very hard to get better performance out of a Zephir class than an equivalent PHP and not worth the effort.
PHP 7 is pretty fast (certainly fast enough for my needs) as long as you don't have other bottlenecks in your code.
People talk of language and speed as if they're handling loads of Facebook, twitter etc. Btw Facebook was built on Php and still uses in some parts. If you write good clean code by following the standards even using Ruby won't matter. Plus when you scale you can always take those decisions. I also feel those devs who are emotionally too attached with their software tools, programming language, coding patterns etc shut themselves up from learning and hence their service become obsolete. As evident in the answers, before branding Php as very very slow, the guy owning this thread not even did a basic courtesy of searching Google. Be it MEDIUM, dev.to, hackernews some random guy posts this kind of question and developer communities jump to thrash / defend programming languages.
It seems this post started with kind of a troll statement (PHP being very very slow) and some people are now doing flame wars in the comments.
I'm pretty sure this kind of behavior it helps no one. If we like to be in this community it's because we care about each other and try not to repeat the same mistakes as every other tech community (hey Reddit and IRC!).
It would be very cool to stay close to the facts (benchmarking? Clever answers?) and avoid things like "Oh please, don't compare Python to PHP".
Facebook's Hack?
what facebook's hack are you talking about
hacklang.org/
look into PeachPie, They compile PHP to .NET Core IL and it runs very fast... IIRC, it's the fastest way to run PHP.
oh thanks, i've never heard of it before.
Not to devalue what PHP has done, but you're greatly underestimating the amount of COBOL code that still exists and runs the financial sector.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.