Live data from Hacker News

Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

phoronix.com

121–130 of 144 posts

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#121

I don't think PHP's main problem is speed. It's generally used for websites, and a few milliseconds aren't going to make a difference when pages are so bloated by JavaScript libraries to often be 5-10MB. PHP's problem IMHO is that I wouldn't be able to use it if it wasn't for autocomplete: inconsistent function names, inconsistent parameter order. The ecosystem is fine, there's Composer, PSR, Laravel. The problem is…

Well, the speed improvements unlock new kinds of things you can do. Old-style PHP code had to off-load any significant work to extensions, which made PHP a glue layer between the browser and the thing that did the real work. Now it's fast enough you can actually write all the code that does the real work in PHP.

I spent 10 years writing PHP, and lately I'm writing Java, Scala and Node code instead. In each case it was due to needing specific libraries that PHP didn't have, but it did give me some insight into what PHP is missing to no longer be the glue layer but a real platform for "serious code":

1. No more ugly mix of procedural and OO code. I want all of PHP's stdlib to become object-oriented, including the primitive types. Also, I need a real type-hinted collections API, not just all-purpose arrays with global functions as primary API. Yes, it's just syntax. Yes, it does matter, a lot, even if you use phpstorm and auto-complete all the things.

2. Generics. Without generics it's impossible to do a properly type-hinted collections API, or a type-hinted FP library. Don't get me wrong, I don't want to type-hint all the things, but I do want to have type-hinted API's to build my own code on top of, and PHP's lack of generics makes this mostly impossible. I can't fix in userland what it misses in its stdlib.

3. A standard story for async and long-running code. Yes, I know about things like pthreads, curl_multi, amp and react-php. I never really felt like any of that stuff was really suited for mature production code and real-world deployment patterns, which is why I always ended up with architectures that boiled down to handing off anything long-running to a queue with separately launched workers processing it in series. I would like an extension to the standard PHP execution model and core language that gives a path towards fully non-blocking architectures as a standard feature.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#122
post #62
post #44

Earlier quoted context omitted.

PHP has some design decisions (e.g. shared nothing architecture) that used to be laughed about - nowadays it's obviously known as a big advantage - PHP can scale linearly with no overhead. [Edit: read what Slack devs wrote about PHP, their server side is written in PHP https://slack.engineering/taking-php-seriously-cf7a60065329 and beside that Facebook uses PHP/Hack and MySQL as core tech) The syntax is inspired by P…

Unless you are using ReactPHP it's not really for real time apps.

I get the sense that Laravel will come out with an async option next year based on small clues I've been seeing. It will probably end up in 5.6.

I been porting over a game from node/express to phpsocket.io. I'm finding the async server more stable.

https://github.com/walkor/phpsocket.io

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#123
post #108

Earlier quoted context omitted.

"As for coding yes—one issue I have is that not using PHP exclusively I get confused by the fact that the opposite of html_entity_decode is htmlentities and not html_entity_encode" Ah yes. You will probably have to hit 'tab' on your IDE with php - to type "html_entity_encode". But if this is too hard - Here you go, Try it out in python (careful of the 2/3 quirks!): Python: https://stackoverflow.com/questions/275174/h…

The guy literally said "PHP's problem IMHO is that I wouldn't be able to use it if it wasn't for autocomplete" Why are you arguing against a strawman?

I meant productively, but whatever you say.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#124

it's really astonishing to see PHP still alive and kicking, despite all the backlashes it has received over the years. whatever it is they are doing, they must be doing something right.

Long time PHP dev here. Note: These are my personal observation and opinion. The usage you see are mostly from people already invested in PHP. However, I'm starting to see fewer new PHP devs. Some of the talented devs I know of have migrated to other "cool" languages. There are fewer PHP jobs than they use to be. I also observed less activity in PHP related subreddits. Its position as the #1 web server language has a…

Very long time php dev here. What you are seeing is the relative fall from the crowd that moved in after the facebook social network movie. Much of the php hate started around this time. Over the last year people are moving back because of things like Laravel, composer, PHP 7 and issues in other languages. Will take 4 years to reach a peak.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#125
post #108

Earlier quoted context omitted.

The guy literally said "PHP's problem IMHO is that I wouldn't be able to use it if it wasn't for autocomplete" Why are you arguing against a strawman?

I meant productively, but whatever you say.

Huh, I was responsing to ransom that he agreed with you but attacked a stawman.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#126
post #119
post #88

Earlier quoted context omitted.

Do you have a public example that illustrates how PHP/Hack code in Facebook looks like? My problem with PHP is that most of modern frameworks seem to take a lot from Java, and people have started to use type hinting whenever they can, so the code looks like (uglier) Java, but without advantages of performance (being made worse by having to setup everything on every request) or compile time type safety.

1) php doesn't have to setup everything on every request - opcode caches, process pooling et al exist 2) the benefit of php over java is that php is going to run everywhere with no effort, and running that same java based website/service is going to start with some doc on installing tomcat or similar, which will devolve into chaos as you start working with ssl certs or shared servers

Bootstrapping a project with Spring Boot is 10x easier than dealing with some modern PHP framework's setup and nginx stuff.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#127
post #95

Earlier quoted context omitted.

I think that the cheap VPS is the ultimate cause. 15 years ago (when, BTW, Python was already a thing) you _had_ to use PHP, unless you had extra money to spend on a more "scalable" technology (so enterprises, who had money, frequently chose Java). It was a monopoly like JS was/is a monopoly - you want to write code for a browser - you'd better know JS. Now, between AWS and DO, you can with relative ease start up in…

Or Linode with 2x the RAM Digital Ocean offers.

or vulr half the cost

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#128
post #90

On my 4-year-old Macbook Pro PHP 7.1 parses a 19Mb log file with the regex "\b\w{15}\b" 5 times faster than Python and Ruby. It's even 3 times faster than Perl which is hard to believe given Perl's insanely fast startup time.

Regex engine for all of those languages are coded in C, so that's probably not a good benchmark. That said CPython and Ruby MRI are slower than PHP5, so yeah PHP7 should be even faster.

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#129
post #119

Earlier quoted context omitted.

1) php doesn't have to setup everything on every request - opcode caches, process pooling et al exist 2) the benefit of php over java is that php is going to run everywhere with no effort, and running that same java based website/service is going to start with some doc on installing tomcat or similar, which will devolve into chaos as you start working with ssl certs or shared servers

Bootstrapping a project with Spring Boot is 10x easier than dealing with some modern PHP framework's setup and nginx stuff.

I usually just create a VM from a DO template and that's it, no NGINX stuff (although it's very easy, NGINX has good documentation and sane and working default configuration).

Re: Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster

#130
post #117

Earlier quoted context omitted.

My biggest complaint is that it's associative arrays are different than objects. So serializing and unserializing json can become a nightmare. This is easily circumvented by being careful to be consistent. But big libraries like symfony will change your json around and break things. In node it's just not an issue

When you decode json there is an option to set a flag that will allow you to use arrays or objects.

Yes I am well aware but the rest of the community didn't get the memo

https://github.com/FriendsOfSymfony/FOSRestBundle/issues/980

Post reply on HN