Live data from Hacker News

Taking PHP Seriously

slack.engineering

601–610 of 673 posts

Re: Taking PHP Seriously

#601
A while back I found myself doing a Laravel project and found it totally adequate and not at all painful, so I don't have the same old flinch reflex whenever someone asks about PHP these days.

That said, nobody will ever convince my that the style of structureless, start-at-the-top, run-to-the-bottom monolithic PHP pages has any merit at all for real apps. I have seen many projects fail, or slowly mire themselves, by creating these monstrosities, with the opening tag 1200 lines down the file. But I assume these days that's not common.

Re: Taking PHP Seriously

#602

This is nonsense. As someone who has had to work in PHP environments that were a mess, just write Python or Go they are worlds better

as someone who has been in the industry for over a decade:

when i hear people say stuff like this, I assume they are a rookie dev. Have passed on many interview candidates for it.

Re: Taking PHP Seriously

#603
PHP engineer of 10 years here - all things being equal, I cannot, in good faith, recommend a person use PHP for anything. General rule of thumb is, if you can, use Python. We still see folks actively choosing it though.. mostly because it's a language we already know and better to create an MVP in something folks know rather than struggle with something "better" that will take a person 5x longer to write while they learn it.

I would bet a donut that Slack is off PHP within 2 years.

Re: Taking PHP Seriously

#604

Earlier quoted context omitted.

Or Etsy. I think your comment about C is right, however in many cases mercifully the C code isn't facing the internet :) When it does, it can go very wrong, e.g. OpenSSL. The extra cognitive load doesn't guarantee failure, it just makes it easier to slip up. Even with Python or Rust, you can put insecure code in there (e.g. with Python's subprocess.call(..., shell=True)). Realistically, strict modes and linters are a…

Of course C is facing the internet. The entire Linux networking stack is written in C. Damn near every request on the internet touches that code.

And nginx, and apache, and php, and ...

Re: Taking PHP Seriously

#605

Earlier quoted context omitted.

Performance? You need to update your act. PHP7 is 3x faster than python and now faster than Java 8 . The only people that can call php slow are masochistic c++ web hacks. https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-...

I don't care about performance. Unless we are speaking about orders of magnitude and my use case has an absolute need for performance. If I only cared about performance I would write everything in assembly optimised for every specific architecture. But strangely I'm much, much, much more productive writing in c#, Java, groovy, f#, ruby and whatever language is appropriate for what I need to do at a certain time. For…

Most professional PHP developers I've anecdotally worked with use a Model-View-Controller pattern these days, where the SQL is abstracted away in the model under something like Doctrine2-DBAL, Propel2 or PDO. If I was hiring for a developer and they suggested putting raw SQL in the view layer, I would reject them. If I received a pull request from my team which did the same, I would reject it.

You seem unnecessarily argumentative about this, almost like you're angry and I really don't understand why. There really isn't that much difference between languages like Ruby and PHP to warrant this and almost anything can be expressed in almost the same way, the only real differences are syntactic sugars and the "flexible" type system.

Re: Taking PHP Seriously

#606

Earlier quoted context omitted.

Performance? You need to update your act. PHP7 is 3x faster than python and now faster than Java 8 . The only people that can call php slow are masochistic c++ web hacks. https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-...

This benchmark shows things a little bit differently. http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... But I think, what's important to note is that PHP 7 has improved in speed department by a great deal.

It's probably worth mentioning that the regex-dna test time is kind of incorrect and provides an inaccurate view of what's happening.

Java-8 is using java.util.regex which is written in Java, PHP is passing the regex requests to it's own regex process which is actually a C package and performs a lot faster.

What we're actually comparing here is:

time(java.util.regex) > time(php compilation + c regex package)

Re: Taking PHP Seriously

#607

Earlier quoted context omitted.

I'll offer an alternate hypothesis. Some companies are succeeding in spite of php. There are many, many users of php, and we'd expect that there would be considerable variance, with some users doing awful (no traction, buggy sites, etc) and some hitting home runs (facebook). Because it's such a popular language, it will have users across this entire spectrum. It's easy to cherry-pick the winners and miss all of the t…

It would be an outlier company indeed who held an 'all hands on deck' meeting and said, "We're succeeding in spite of PHP everyone!" Only engineers care about programming languages. Seriously. That's it. No one else cares about them. I work in a large public university alongside a revolving door of student interns who are always 19. In 10+ years of work, I've still yet to meet the person who talked about their favour…

"Only engineers care about programming languages."

It's sadly quite common for non-engineers to make technical decisions such as what language, tool, or hardware will be used, and everyone else just has to live with it.

Re: Taking PHP Seriously

#608
post #440
post #331

Earlier quoted context omitted.

Can you set up Python to have the same pattern as PHP? I've always had to proxy the web server to the Python process running HTTP.

Python via fastcgi, wscgi, etc, is the same pattern. Or mod_python inside Apache.

  import cgi
Also, the httpd communicates to the CGI program via environment variables so one can also write their program in assembly.

Re: Taking PHP Seriously

#609

The article points out that arguably the best part of PHP is the "shared nothing lifecycle". That each request starts new, and the process dies at the end of the request. It's by far my favorite part, and I completely agree that it makes "reasoning about" (boy do I hate that phrase...) your program much easier. Why are there no other "competitors" in this space? Why do most other languages go with the alternative rou…

It's interesting that so little know what is Cgi here. It's the Common Gateway Interface and it uses environment variables to communicate to the Cgi scripts and thus the Cgi script can be in whatever language you wish. You don't even need a lib, reading env is enough. Its possible to write your Cgi scripts in assembly.

So this process-per-request thing is not exclusively a Php thing.

Re: Taking PHP Seriously

#610

Earlier quoted context omitted.

Or Etsy. I think your comment about C is right, however in many cases mercifully the C code isn't facing the internet :) When it does, it can go very wrong, e.g. OpenSSL. The extra cognitive load doesn't guarantee failure, it just makes it easier to slip up. Even with Python or Rust, you can put insecure code in there (e.g. with Python's subprocess.call(..., shell=True)). Realistically, strict modes and linters are a…

Of course C is facing the internet. The entire Linux networking stack is written in C. Damn near every request on the internet touches that code.

At which point did you decide not to read the comments properly?

The gist was that PHP was designed for web use, so it's almost always facing the internet. C on the other hand is very much multi-purpose. Both can be made secure, but maybe it's less effort using something that helps you with security (Hack, Rust, etc.).

(BTW, your comment contains a huge fallacy: Just because a majority of packets touches something written in C, that doesn't mean a majority of C code written is exposed to the internet. This is arguably the entire point of e.g. iptables.)

Post reply on HN