views:

131

answers:

2

Was asked in an interview yesterday to name three good and three bad things about PHP. It was a junior position and the interviewer wasn't expecting all questions to be answered/answered correctly.

I'm a hobbyist web developer mostly, so what are the good and bad points of PHP?

+5  A: 

Good points:

  1. It's everywhere, on every system/server meaning you don't have to worry about installing it.
  2. It's popular, there's a huge community of developers meaning you can easily get help and find reusable scripts to use
  3. php.net is a pretty good resource

Bad points:

  1. It has lacked features which other languages have had for dozens of years. For the most popular versions up until just recently ( closures, anonymous functions, namespaces ). They are available in 5.3+esque but that's not commonly used.
  2. Inconsistent function names, inconsistent function argument ordering. It's a mess without namespaces.
  3. Lacking in unicode support
  4. PHP4 lacks in the OO support and it's still widely used despite being officially dead, meaning for some client work in which you don't control hosting you are forced to code for PHP4's horrible OO.
  5. Not thread safe, can't take advantage of Apache2's multithreaded mode
  6. Fraking magic quotes
meder
+1 Great Summary
GWW
PHP is thread-safe, unless you compile it without thread-safety, which you would only do if you're not using it in a thread environment.
Artefacto
@Artefacto - The core may be thread safe, but it *isnt* practical to use PHP with worker MPM because most libraries aren't thread safe. That's why you pretty much *have* to use prefork with PHP. Maybe in 5-10 years the PHP community will catch up to other languages in that aspect. Disregarding this whole thread-thing, would you agree with the other bad points?
meder
@meder It's not true the majority of libraries are not thread-safe. All of the bundled libraries are thread-safe (well, except maybe the posix extension). The majority on pecl are too except when the libraries they're wrapping are not themselves thread-safe. As to the other points, I'd only agree with 3. (2. is true too, but it's inevitable when you have a code base that's only and whose scope changed through the years). 3. is bad but is manageable with the `mbstring` extension. All the other points have been resolved in the recent versions; magic quotes are deprecated and already not in trunk
Artefacto
@Artefacto - In what year did PHP get namespaces, lambdas and closures? Guestimate what percentage of PHP distros are setup to support those features?
meder
@Artefacto - I'm not sure how `mbstring` makes Unicode manageable compared to other languages. If `mbstring` is so good, why are they trying to rehaul the entire Unicode portion of PHP for PHP6? Magic quotes have been an issue for the majority of PHP's lifetime, just because a recent version has fixed it doesn't mean it still isn't an issue in modern day development since hundreds of thousands of servers still have it enabled.
meder
@Artefacto - Do you use apache? And if so do you use mpm worker or prefork and why?
meder
@meder What I use is irrelevant. The canonical way to run PHP nowadays is FastCGI (perhaps using the new FPM sapi) anyway, and the MPM is irrelevant there. But you'll notice that most PHP programmers have a Windows Apache+PHP dev environment (XAMPP) and that the Apache MPM for Windows is a threaded one. See http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html
Artefacto
+2  A: 

I like this post by Jonas Maurus describing PHP's bad points.

In summary the good points are:

  • PHP makes it easy for beginners to get things done
  • PHP is easy to install

Bad points: pretty much everything else. Jonas does give good reason to why they are bad points though.

Whisty
One could argue that the good points are catalysts for the bad ones. =D
Nathan Taylor
-1 That article contains wrong information, besides being outdated.
Artefacto
@Artefacto - what wrong information does it contain?
meder
@meder First of all, most of the article is composed by complaints about PHP 4, which has been dead for a long time and is no longer bundled by the distros. Then, the author clearly has no idea what references in PHP are (and uses PHP 4 code). Thread-safety: see above. As to no unsigned integers... Java doesn't have them too and they're avoid in C (for specific reasons). they're really not that really that needed. The `unpack` comment is also stupid; `unpack` has options that are machine-dependent (for performance) and machine independent ones.
Artefacto
@meder Other points: a loose type system will always have some conversions that people find strange; in retrospect some conversions are indeed odd, like `"4dd" == 4` being true, but attacking the concept in general is just disagreeing that the extra flexibility is not worth its problems. Finally, I don't know what he means with XML charset stuff. Probably an already fixed bug or someone that didn't know what he was doing.
Artefacto