4 ms·
PHP earned its reputation. Whether the reputation earned by previous versions is relevant to the current version is a different question. I'm going to assume i
by Zak 6y ago
PHP earned its reputation. Whether the reputation earned by previous versions is relevant to the current version is a different question.
I'm going to assume it's a decent modern language now, but what's the argument for using it instead of another mature dynamic language like Ruby or Python?
- coding_lobster 6y agoI have no metrics on this but I was under the impression that due to the size of the PHP community the package ecosystem specifically for web is probably larger. The community itself being larger is of course another plus as it means you're able to get easier access to the knowledge of others. Thirdly of course the shared hosting providers (by what I've seen in the past) usually support PHP almost always - this is not the case for either Ruby or Python.
- nicoburns 6y agoPerformance is also better than Ruby and Python. While providing comparable development experience / ease of use.
- antonf 6y ago> While providing comparable development experience / ease of use. I would argue with that. Part of my job is writing a lot of PHP currently (Hack actually, but they are very similar). Sometimes it's OK, but sometimes early PHP design decision to make code always appear working correctly and avoid raising user-visible errors really make me wish I was coding in another language. One of latest examples: when converting string to floating point number, sometimes you get 0.0 in case of parsing error, sometimes part of string is ignored.
- kilburn 6y agoYes, PHP has some warts, but so do ruby & javascript [1], python [2], and all other similar languages. The keyword to look for people explaining some of these warts is "wat" (popularized by the talk at [1] I think). [1] https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat [2] https://github.com/cosmologicon/pywat https://github.com/cosmologicon/pywat
- muglug 6y agoYup, for web stuff you’re right. Python has a larger overall user base, but much of that usage is in non-web contexts, whereas PHP is pretty single-mindedly focussed on websites.
- OJFord 6y ago'larger' in terms of what? I don't know what you'd have to do 'specifically for web' that you'd find yourself writing python and thinking 'damn shame there's no package for this'; and JavaScript's must be way (overly) 'larger' (package count) than that.
- fnord123 6y agoI didn't even realize shared hosting providers still existed. I thought everything was virtualized and containerized. But indeed, sites like Gandi.net sell shared hosting.
- wtracy 6y ago> what's the argument for using it instead of another mature dynamic language like Ruby or Python? A massive body of existing code that you can leverage. I keep putting off picking up PHP, but when you look at the number of off-the-shelf easily-extensible solutions for CMSs, CRMs, and e-commerce platforms, there's no contest. PHP wins. If anyone can point me at a Python e-commerce solution that will let you deliver an MVP in an afternoon, and your first original feature within a week, that would make my month.
- robertlagrant 6y agoIt's not exactly a language choice at that point. That's like saying C++ is a good language because Excel exists.
- Zak 6y agoIt's an argument for a particular tech stack that may have PHP in it. Excel is a bad example because it's closed-source and does not put a developer building a solution on top of it on equal footing with its creators. Wordpress is probably the best example here; if it does 90% of what someone wants, it may be easier to add that 10% than to use a different solution. I'd be surprised, however if there aren't solutions written in other languages that provide that same 90% in most cases. None of them are as famous, but that shouldn't hinder someone working as a consultant to help small businesses get online.
- robertlagrant 6y agoExcel enables even less technical people than Wordpress configurers. It provides 99.999999% of the solution, and the rest can be done with macros, pivot tables, etc. That's why it's a good example, I'd say.
- Zak 6y agoExtending Excel is a reason to use VBA, not the C/C++/C# most of Excel itself is written in. Extending Wordpress is a reason to use PHP. In both cases, the merits of the extension language are almost irrelevant; people use them because they're the extension language for a popular platform.
- hkt 6y agoUnless I'm drastically mistaken, PHP is faster than both ruby and python. There's no consideration of what we call technical correctness, only business value, and on the whole that is a good thing.
- Zak 6y agoMost web applications are not bottlenecked by the execution speed of their backend language. > There's no consideration of what we call technical correctness, only business value, and on the whole that is a good thing. That's called technical debt. Taking some on may not always be a bad decision, but if there's a short-term gain (and I'm skeptical PHP provides one), it may come at a cost of future development slowdowns, downtime, a full rewrite, or a data breach.
- noir_lord 6y agoIn the case of PHP (a language I've used as day job for the last decade on large enterprise projects and other stuff) the speed of PHP isn't its issue. Building the world to throw it away on every request is..compounded by the sheer size of the stack between the PHP runtime and a response (laravel is a particular problem here out the box). You can do sorts of interesting things to get around this but there is no free lunch, they add complexity (caching, shared state, connection pooling) or change the execution model in ways you don't expect. For all that modern PHP isn't a bad language, it's not C# (my favourite pragmatic language) but it's also not as bad as 5 was and certainly not 4. It's biggest 'issue' on a wide scale is the massive disparity in skill levels covered by "PHP programmer" and how hard that makes hiring. My advice is if you are building a small system or one that is tightly constrained then Laravel isn't bad but if you are building a big system or one that will grow over time, go with Symfony, it's more work up front (though not a huge amount) but in every other way future you will thank you.
- mgkimsal 6y ago> Building the world to throw it away on every request is "Shared nothing" architecture has positive benefits too.
- a-saleh 6y agoI'd vager Wordpress? Maybe Laravel? So not that different from choosing i.e. Ruby to do your business-focused monolith and get payed :)
- hrktb 6y agoPHP has been optimized to death so performance wise it’s excellent (same as javascript, it should not have become so fast, but the sheer amount of work done on it gives it an edge). The other advantage over ruby (python too?) is the server models bootstrap and trash everything on each request, meaning way less weird memory issues and more predictable behavior. Nowadays nobody’s gonna run a php server ad hoc, so it will be wrapped in a container anyway, but IMO it’s still easier to manage than ruby/puma. Last but not least, it’s very subjective but I think php has better enterprisy trade-offs than ruby: you’re not free to rewrite the whole language but have a decent degree of freedom in writing code with few boilerplate. Ruby gives way more freedom which is not always an advantage depending on the work culture. I say that having left php for ruby.