10 ms·
PHP is damn fast now, no joke. And with all of the modern features it's actually not so bad to work in. I'm becoming increasingly puzzled every time I see PHP
by jonny383 6y ago
PHP is damn fast now, no joke. And with all of the modern features it's actually not so bad to work in.
I'm becoming increasingly puzzled every time I see PHP hate now, especially when I read tired comments like "just use rails". Laravel is arguably as good or even better than rails at this point, and PHP 7+ is definitely light years faster and lighter.
One thing that still sucks is package management / composer.
- geerlingguy 6y agoComposer 2 is coming, and so far it’s shaping up to be vastly improved. Also, many people are still using that ‘fractal of bad design’ article from years ago to bash on PHP, even though a number of the assertions are no longer applicable.
- juanuys 6y agoYears ago on GitHub when the new Composer logo was just pushed, I commented (on the relevant commit) that it looks more like a "conductor" than a "composer" or perhaps they meant "composer/conductor" which isn't uncommon in the music industry. My comment was promptly deleted. Oh, well.
- ben509 6y agoThe point of calling a "fractal" and talking about the "design" is that while you can only look at the surface in an article of reasonable length, it points toward strutural and systemic failings within the language itself. The problem is that PHP is built on bad foundations and while many of the superficial problems can be mitigated, the underlying foundations can't be fixed without breaking changes. (Or, as Python proved, even if you make breaking changes, you may still not fix many core issues.) All languages get this way over time, usually as decisions that made sense early on become baggage. But when a language makes poor decisions early on, it accelerates that timeline.
- thinkindie 6y agoyet you don't see articles about how bad python is, it still receive lot of praises and much love. This is telling a lot about how fair are some comments about PHP.
- ben509 6y agoPython gets love for a number of choices it made right early on, and that its core langauge is obviously well thought out. Even very old Python is generally readable and clear; except for some colons, it looks like pseudo-code. This is the same reason I think Java gets a lot of respect: they had a few core language design ideas and built the language around them. People will say COBOL's syntax is horribly verbose, but you can see what they were trying to do. So you might dislike those choices, but your critique becomes about the consequences of the choice, which implicitly is something the person making it can't know at the time. With PHP, people are complaining that users have to live with a whole host of accidents or poorly thought out ideas that are now baked in. Other languages get criticized for that, too. Python was hammered over their poorly thought out support for unicode in Py3K[4], which blocked many distros from supporting it until around 3.4. (And, generally, most people agreed Python3 was a mess until ~3.6 and the whole transition is widely seen as a case study in what not to do.) Java gets dislike for similar bad choices. Java's Date class is pretty notorious[2] as a how-not-to. Java arrays are covariant, and it was staring them in the face as they coded the ArrayStoreException[5] to deal with otherwise perfectly valid assignments. But the .NET one-upped them by knowingly making their arrays covariant, despite knowing it was a problem in Java. (Probably to make it possible to run Java on the CLR.) To pick on Javascript, critiques of promises[3] center around the fact that people proposed using monads, and the designers brushed it aside as theoretical. The famous 'wat' presentation[1] talks about behavior in Javascript (and others) that is magical and bizarre, and it's principally because Netscape has some neat ideas they didn't think through. [1]: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat [2]: https://codeblog.jonskeet.uk/2017/04/23/all-about-java-util-date/ https://codeblog.jonskeet.uk/2017/04/23/all-about-java-util-... [3]: https://github.com/promises-aplus/promises-spec/issues/94 https://github.com/promises-aplus/promises-spec/issues/94 [4]: https://click.palletsprojects.com/en/7.x/python3/ https://click.palletsprojects.com/en/7.x/python3/ [5]: https://docs.oracle.com/javase/7/docs/api/java/lang/ArrayStoreException.html https://docs.oracle.com/javase/7/docs/api/java/lang/ArraySto...
- cutler 6y agoAll languages? Ruby doesn't seem to have suffered this fate. Still as elegant and full-featured as ever. Clojure just goes from strength to strength.
- joelbluminator 6y agoWhat are the "modern" features of php? It looks like it's trying to shed it's dynamic nature and add types (with annotations etc). Also frameworks like Symfony / Laravel look more and more like java web frameworks to me. I'm not saying this is necessarily bad but there's nothing modern about types. Also, might make more sense to choose java if you need types.
- bouncycastle 6y agoThe biggest advantages of PHP over Java are build and deploy times, so coding a php app is much more rapid. You can test your app right away, even after a single line change and get immediate feedback on the screen, which I think is important in web dev because a lot of it is visual. The other advantage is the run-time. Java has a slow startup time and when you redeploy then you need to stop/start your entire app. With php you can fix / update one part of your app without the need for a server restart. Another advantage is that php runs each request with a clean state, that means all the variables get destroyed after the request, helping to avoiding memory leaks, and possibly issues with concurrency which Java exposes. Types are great, but sometimes they can get in the way too and slow you down, (I still haven't figured out what those <funny> types mean). In all, development in PHP is so much faster and easier over Java.
- joelbluminator 6y ago> Another advantage is that php runs each request with a clean state, that means all the variables get destroyed after the request, helping to avoiding memory leaks, and possibly issues with concurrency which Java exposes Care to elaborate? How is that different than java web frameworks?
- ben509 6y agoIn a Java web framework, your classes have static fields, so user code or any library can assign values to them. Language support for a request being ephemeral is far more effective than frameworks proposing it as a good practice. And everyone working on PHP libraries in C know what a request is and that it ought to be ephemeral, so even outside the core language there's a clearer understanding.
- raxxorrax 6y agoI took a look at it about 1,5 years ago while having worked with very early versions (2, 3 or 4?) as a teen. It was the first language I put some effort in to learn more about. Not that I remember too much, but it is a complete different language by now. I would have thought only dinosaurs like Algol or Fortran can be that old.
- deleted 6y ago[deleted]
- mschuster91 6y ago> One thing that still sucks is package management / composer. How? I mean, what are the problems with it?
- conradfr 6y agoPersonally it's mostly composer update and require that fail in docker or a VM because of the memory requirements, otherwise it works well. Also I hate json for config files because you can't comment things.
- rplnt 6y ago> not so bad to work in Yeah, if you know it well enough, maybe. It's horrible to work with as a newcomer or someone who only needs to touch it once in a while.
- kethinov 6y agoThe speed is the main reason I decided to experiment with building a Node.js module last week that allows you to use PHP as a templating engine for Express apps: https://www.npmjs.com/package/php https://www.npmjs.com/package/php I had guessed that PHP might be faster than mainstream JS-based templating systems like EJS and in my tests so far in an app I'm building it appears my guess was right. Even with the overhead of serializing and deserializing the data model from Node to PHP, on one of my more complex templates the PHP version outperforms the EJS version by around 10%.
- Ayesh 6y agoDid they seriously take the "php" namespace in the registry?!?! That shouldn't be allowed.
- kethinov 6y agoOriginally the php module on npm was used by a separate project that attempted to implement a PHP parser in JavaScript for Node.js, but was never finished. One work in progress version was published, then the project remained stale for 8 years. I spoke to the owner of the package and asked him to transfer it to me and he graciously agreed.
- rawoke083600 6y agoIs 10% enough to switch though ?
- Ayesh 6y ago> One thing that still sucks is package management / composer What about Composer? Sure is in par with Slack when it comes to memory usage, bit it's functional and feature rich. v2 has partial offline support, faster downloads, etc. (https://php.watch/articles/composer-2 https://php.watch/articles/composer-2). Composer IMHO is one of the best dependency managers for any language out there. Disclaimer: the link above is a for a site I maintain.
- plopz 6y agoHaving to setup 10gb swap to get it to work is pretty awful.
- Implicated 6y agoI've never had to setup swap for a composer install on any machine with >1gb of memory..
- shirshak55 6y agocomposer is so slow tbh. It takes ages to download package and well requires me to setup swap even when i have 4 gb ram in server.
- abdusco 6y agoHave you used prestissimo? It allows parallel downloads and makes the process much much faster. https://github.com/hirak/prestissimo https://github.com/hirak/prestissimo
- azeirah 6y agoYeah, using prestissimo makes package installation sooooo much faster. My Laravel project with over 100 dependencies downloads in under a minute, where it was like... 10 minutes before
- apocalyptic0n3 6y agoI'm not sure how it compares, but an alpha for Composer 2.0 was released last week[1] and the release notes seem to imply that it runs in parallel by default now. > Added support for parallel downloads of package metadata and zip files, this requires that the curl extension is present and we thus strongly recommend enabling curl 1: https://github.com/composer/composer/releases/tag/2.0.0-alpha1 https://github.com/composer/composer/releases/tag/2.0.0-alph...
- donatj 6y agoThis is honestly the first I’ve ever heard anyone complain about composer. Having experienced a number of other package managers, composer is by far my favorite. Like have you spent any time with npm? Composer is light years ahead in reliability and expectations matching reality.
- sfteus 6y agoThe amount of fighting I've had to do with setting up NPM for legacy applications, or with any sort of virtualization is insane. I no longer set up Node/NPM on anything automated without NVM, since they seem to drop support for old packages at random. You have to jump through a ton of hoops to make NVM play well when it's effectively installed by root but ran by another user within the container. Running NPM in a unix VM on Windows means you have to update everything with --no-bin-links since symlinks aren't well supported, and there is no fallback. It's baffling that they haven't had some sort of manual copy management when a symlink can't be created. Meanwhile, I setup composer in a docker file in 4 lines (download, run, move to bin, cleanup), and it works everywhere for any user, respects permissions, etc. I don't think I've run into a single error on composer that wasn't something like a mis-typed command, package, or a host being down.
- donatj 6y agoFunny! I'm dealing with a very similar problem right now. We're trying to port our CI workflow from DroneCI to GitHub Actions and our private NPM packages have been a literal nightmare. In comparison, our private composer packages worked fine with very little fuss.
- AegirLeet 6y agoWhat do you dislike about composer?
- fxleach 6y agoTo be fair most package managers suck.
- karatestomp 6y agoA lot of PHP work is digging around in Wordpress themes & plugins with a bunch of other (third-party) themes and plugins installed, some of them paid which can add another layer of annoyance to testing and deployment and such. Hosting's usually some managed thing rather than anything under your direct control, and usually quirky or limited in some way or another. It's a pretty miserable ecosystem to work in. PHP itself is, secretly, actually kinda OK. Some major codebases written in it are no fun at all to work with, including the 800lb gorilla that is WP.
- cutler 6y agoJust when you thought it couldn't get worse there's Magento.
- yurishimo 6y agoInterestingly enough, there was a commit to WordPress core to bump the recommended PHP version to 7.2 If users are running below that, they'll got a notice telling them to contact their hosting provider and get them to upgrade. https://twitter.com/schlessera/status/1270788445808537604?s=20 https://twitter.com/schlessera/status/1270788445808537604?s=... Combined with the JS work going on in WP, it's going to be an interesting 5 years I think. I would not be surprised if a lot of WordPress core starts to get rewritten. I know many of the large plugin authors are already pushing full steam ahead with modern PHP features and dropping support for old versions. Now that core can "take the blame" it's a lot easier to justify and I don't blame them.
- ralfhn 6y agoYou don't know how good you have it with composer until you try other package managers.
- cutler 6y agoI'd be interestd to see how much faster Laravel is compared with Rails and also how they compare in memory usage. Last time I looked on Techempower I was surprised to find Laravel performing more slowly than Rails in some of the examples.