4 ms·
What would you say are the advantages to php over node, python, or golang?
by qudat 9y ago
What would you say are the advantages to php over node, python, or golang?
- tyingq 9y agoMostly quicker out of the box prototyping. That scales to a reasonable degree. To me, there's a threshold where the others take over. What many people miss is that very few projects ever cross that threshold. Kind of like a table saw vs a CAD router.
- NightlyDev 9y agoWhat do you mean by "scales to a reasonable degree"? How does others take over?
- tyingq 9y agoFastCGI vs, for example, node.js and their pretty nice async model where the engine is warm for every request. With php, I have to do stuff like caching responses with apcu to get something similar, but inferior. Which doesn't scale beyond a single server host. I can serve a lot of requests with apcu, but the curve does drop off at some point.
- andrewmackrodt 9y agoHave you tried a node/express like PHP framework such as amp/aerys?
- tyingq 9y agoHave not, will check out aeyrs though.
- NightlyDev 9y agoNodejs out of the box would ofc. be faster than PHP on something nodejs is born to do. But lets say we needed to do a bit of CPU work on each of these requests, then nodejs might struggle compared to PHP. Both should be able to scale well in a "create a website and return the HTML"-scenario, and it's not unlikely that a PHP setup would be faster. In a single page app thats mostly based on fetching data from an API nodejs would probably be faster. About APCu: It's damn fast and very unlikely to slow you down, other stuff will probably bottleneck you way before APCu becomes a problem. Use PHP as PHP, and nodejs as nodejs. If you really need async in PHP or want to use PHP somewhat like nodejs then you should probably go for an extension and serve requests directly from PHP. I've had great experiences with that, serving over 500K simple HTTP req/s on a low end server. But again, if max performance on a single server is so important then you should probably go for a compiled language anyways.
- tyingq 9y agoGreat observations, and better stated than what I said. Often the answer is "it depends". Which is usually unsatisfactory for the HN crowd. I just hate uninformed and unnuanced PHP hating. There are use cases where it's actually the best answer by a large degree.
- tylerjwilk00 9y agoMost projects never reach a point where PHP can't handle the scale the project will reach.
- amq 9y agoPHP 7 is probably going to be faster than Node.js and Python. Arguably, it is also more approachable to host it. Easier to find developers for it.
- joshribakoff 9y agoBut php is going to have some inherent latency starting up a process for each request and an overhead of spinning up a new process for every request. If you need speed you shouldn't use any of three languages you just mentioned though. These days I think it's easier to find nodeJS developers. You can take a frontend developer and teach them nodeJS very quickly also. It's arguably just as easy to proxy from nginx as it is to setup a PHP sapi
- tyingq 9y ago"spinning up a new process for every request" It's not that bad anymore. We do have fcgi, fpm, and also user space caches like apcu. You would have to try pretty hard to find a default set up that resulted in process per request these days. It scales very well on a single host. Which has limits, but limits that exceed some percentile that most projects need. And things like redis take it even further. If you're pushing the limits of php, you probably have a nice-to-have problem tied to lots of incoming revenue. Similar to FB and HHVM. I agree there's a scaling issue, but nobody is doing process per request anymore. Process pooling is a decade old or more.
- repsilat 9y agoSome people now boot an OS to serve each request, and reinstall the OS to deploy new changes. It's funny, even the objections to PHP haven't kept up with the trendy software practices. I guess the objection to "spinning up a process" is actually a problem with slow PHP initialisation, though? A dinky server can spin up many thousands of processes a second. I'm pretty sure OS process overhead is nothing compared to whatever PHP or Rails or whatever else puts into your critical path, but the language/library/parsing requirements could kill you. (Though people still make this objection to CGI itself, not just PHP...)
- JepZ 9y agoI think the biggest pro for PHP is its simplicity. By default you don't have to care about the server. You just place some text-files in a web server directory and open a website, easy. And dynamic languages tend to be easier accessible for newbies too. It is also a con, as some things are just not available (e.g. multi-threading), but in general that lets you focus on the application logic and lowers the entry barrier. Traditionally, a major pro for PHP was also its broad availability for web space but that doesn't seem to be so important nowadays anymore. Putting node, python and Go in the same place against PHP is kinda hard as those three are very distinct from each other already ;-)
- kilburn 9y ago- Sane, easy to use package/dependency manager that just works, every time (none of node/python/golang really have that, for entirely different reasons). - Large stdlib that, while inconsistent, frees you from searching packages for everything (vs nodejs). - I'm sure some will disagree, but php's documentation is top notch, easy to navigate, and with nice completion from user examples (you could say it is a mini-stackoverflow by itself). Golang's docs are good, python's are good but hard to navigate, node's are typically worse. - PHP's ordered, possibly hash-backed possibly plain arrays are an abomination from a data structures point of view, but god are they handy! Golang is terrible here with its static types (fine) but lack of generics (just check how to sort a list of a non-primitive type).
- dullgiulio 9y agoSorting a list of a non primitive type in Go can be done inline. To this day there is no generic list sorting function in PHP proper.
- andybak 9y ago1. I rarely have problems with package management in Python. I know pip has flaws but it's not enough of a pain point for me to see it as an issue. 2. I'd say Python is an easy match in this regard 3. Agreed about the docs - I still find the organisation of Python's docs a bit peculiar. 4. Handy data structures, you say? I think Python might have the edge here. It's strange you don't mention PHP's biggest strengths: deployment and learning curve: You can begin on almost any commodity hosting with a simple text editor and no knowledge of Unix internals. The amount of extra stuff I had to learn to be productive in Python was huge at the time. It's got a bit better now with various simple deployment options but PHP still wins out for the beginner.
- wolco 9y agoThe speed of development, larger ecosystem, and the speed of php 7. Many problems have been solved in php that still exist those other communities.