
PHP: a fractal of bad design (2012) - kilroy123
https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
======
t0mbstone
Yes. PHP sucks. So why has it been so successful?

Maybe that's what all these other "amazing" languages need to be asking
(instead of pointing at all of PHP's flaws).

My current working theory: PHP.net has the most amazing set of contextual user
comments for function reference. PHP.net was stack overflow before stack
overflow existed. Yes, PHP has a ton of flaws, but there are workarounds for a
lot of those flaws, and those workarounds are often found in a comment right
there next to the function.

~~~
rbrtrbrt
Does anyone know of articles attempting to explain the huge success of PHP?

My first guess would be a combination of (1) making simple things easy -- by
the time you start experiencing the warts and flaws, you've already been
successful, and willing to work around them. And (2) (later on) ubiquitous
availability on web hosters, giving it a much lower barrier to entry than
other languages in the web space.

Other aspects could be a community that's welcoming to novices and
autodidacts, or its integration into a "default" infrastructure (Apache,
MySQL).

But it would be interesting if some aspects of the languages design itself
could be shown to have contributed. Perhaps the mixing of HTML and imperative
code? Not having (at first) object orientation? Could its unorthodox semantics
for passing by value/reference have been helpful to beginners?

Getting a handle on such design issues for programming languages could be
helpful in trying to come up with "better" languages that could be accessible
to beginners and end-user programmers, and PHP is an interesting case here.

------
labster
I've been fooling around on code-golf.io, and PHP is the only language where
it feels like I'm fighting with the interpreter every time I refactor. Swap
array_filter for array_map? Gotta switch the order of the arguments. They also
have a barely-documented, binary version of the ternary operator[0], which is
certainly a unique idea.

Lua doesn't give you much, but it stays out of your way. Perl has batteries
included. Perl 6 does too, but also asks if you'd like more batteries. Python
looks sane. But PHP is one little edge case after another.

[0]:
[https://secure.php.net/manual/en/language.operators.comparis...](https://secure.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary)

------
kyriakos
PHP is the most criticised programming language and yet still one of the most
popular. Maybe its our measure of a good programming language that is wrong
after all.

------
tzs
> No generic standard database API. Stuff like PDO has to wrap every
> individual database’s API to abstract the differences away

I don't understand. What languages have generic standard database APIs that do
wrap the individual database APIs?

------
kenhwang
This always gets posted every few months, and the PHP people always come
around and say, wait, PHP7 is different now. I wonder how it differs on the
predictable, consistent, concise, reliable, debuggable rating scale now.

Similarly, I wonder how the current crop of "modern" languages fare.

~~~
etu
Well, PHP7 still got some of the issues mentioned in the article. But it's
mostly due to backward compatibility reasons I believe.

But then there's also a good rule. Don't write shit code. It pretty much works
in most of the languages.

Don't use the bad parts of the language. Most languages have something that's
weird.

