PHP is great if you need to get some small thing up and running yesterday. PHP is also great if an out of the box solution will almost fit the bill due to the fact that there are so many. Just take a box and do some small modifications, voila, done!
Stack Overflow: Defend PHP - convince me it isn't horrible
11–20 of 74 posts
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#12Use it yourself and keep using it for as long as you like it. When you stop liking it, stop using it.
That doubles as a recipe for learning any new thing.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#13Back in 04, I already felt some reservations against PHP, but that's what I knew best and that's what was most used for the web (Rails might have been around, but not really known - other ruby options were not quite there yet. Python I disliked and Java I. don't. touch.).
The application was written in PHP5, initially developed on some RC of 5.0.0 and I was careful to keep a clean style and not using deprecated code.
This lead to a quite clean application that I could really be proud of. And still: While it has suffered from sometimes not quite reasonable customer demands, it's still very good at what it's doing and while there might be some dead bodies rotting in the code, it's nowhere near daily WTF material (aside of some bugs we have a good laugh at and fix shamefully).
Still. I have some bad gripes with PHP that made me stop doing anything new in that language.
I can easily live with the usually quoted problems though:
- parameter order in library function? I don't care - my IDE lists them.
- Huge base library? I don't care as the stuff I don't need doesn't cost me anything but disk space and the stuff I do need, I'm glad is there.
- No namespaces? Yeah. Bit me a couple of times, but I can work around that - besides, with 5.3 we got namespaces, so this doesn't count any more
- Performance issues? It's fast enough for said application.
- Security? It's just as secure as any other language you can write insecure code in (i.e. all of them).
- Allows intermixing of layout and code? Sure, but you don't have to. If you have any sense what so ever, all requests go through a central /index.php and all other code is in some not-publicly accessible location and emits no html what so ever. All output is generated using any of the thousands of templating libraries.
What really disturbs me about PHP is its type conversion rules. 1 == '1' or even worse 'foobar' == 0, or '123n' == 123. This is cause for so many subtle bugs.
Just use === you tell me? Sure, but then you clutter your code with an insane amount of isset()'s and isint()'s and whatnot - the fact that the database library I'm using (pgsql) returns everything as strings doesn't help that cause either.
The other thing is the really clumsy syntax. Array literals, anonymous functions, closures (with explicit declaration of all variables of the outer scope you want access to), operators, even just the lack of named function parameters. The syntax is clumsy and all the elegant code you see even from JavaScript just gets bloated and unreadable once you port it to PHP.
These two issues made me do stuff in Ruby, Python(3) and lately a lot of Node.js, but the maintenance of that huge application remains to be the main part of my day-job and even though the two issues really bug me, it's still not painful enough to really be complaining (or, heaven forbid, port the thing to whatever-other-language-thats-currently-hip).
So in retrospect, while I'm as die-hard a PHP user as you can get with many, many lines of PHP under my belt and while I do find some of the stuff highly enjoyable (php's arrays that are also ordered hashes for example. Or the really easy and accessible web-server/HTTP integration), I also dislike it quite a bit to the point of being unwilling to start something new in PHP.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#14PHP is great if you need to get some small thing up and running yesterday. PHP is also great if an out of the box solution will almost fit the bill due to the fact that there are so many. Just take a box and do some small modifications, voila, done!
...or big thing running yesterday, right? Take Facebook for an example. To me, Facebook seems like a pretty complicated piece of software. The concept isn't very complicated but there are so many features all over the place.
For example, I would rather build a Facebook-sized app in Rails than a PHP framework, especially with Rails 3's new features. There are some very capable PHP frameworks out there, but you'll still end up writing much larger models and a lot more code than if you were using Rails.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#15I love PHP and have used it for years since moving away from asp.net and agree with some of the posters arguments as a theoretical principle, but as day-to-day PHP developer I also say so what. Naming and parameter inconsistencies? Yes, my libraries have that too and I can at least learn the PHP ones with some experiernce. I don't know any asp.net developer that doesn't have to use some kind of tool to help them find where System.Obscure.FoundItOnline.Function exists in the monster .net namespace system. It allows me to be productive and allows me to be the gatekeeper of how well or poorly I implement things. This is a crucial point of the constant argument about poor PHP logic/presentation support for me, I can happily write mixed and messy code for a £500 job or I can write some clever system that implements caching and output buffer manipulation and have a great template system.
There are far too many people spending far too much time thinking that academic level programming considerations are applicable in every detail to every day programming practices of web developers.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#16To be honest I don't think case insensitivity is really that much of an issue. Common Lisp is case insensitive as well and I have never had any problems with that.
foobar() == FOOBAR()
but $foobar != $fooBar
And then there was that fun issue with the Turkish locale and function names...Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#17The fact of the matter is PHP is ugly and that's really it. I can live with ugly because I know it and it does everything I've ever asked it to.
Frankly, it's no different than me switching from English because it has quirks.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#18Bill, hates PHP with the heat of a thousand suns.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#19Do you consider yourself a purist or pragmatic? In the latter case, PHP may be worth dating for a while.
Re: Stack Overflow: Defend PHP - convince me it isn't horrible
#20From a programming language perspective, PHP is somewhat horrible (PHP 5.3 less so, but still). I guess nobody will deny that. But from practical perspective, PHP is very suitable tool for many tasks and has huge ecosystem behind it. Complex real-world websites and applications have been successfully built with PHP. Isn't that proof enough? Do you consider yourself a purist or pragmatic? In the latter case, PHP may b…
Thanks to PHP or in spite of PHP?