📜 ⬆️ ⬇️

PHP: fractal bad design

Foreword


I am moody. I complain about many things. I do not like much in the world of technology and this is predictable: programming is a noisy young discipline, and none of us have any idea what he does. Given the law of Sturgeon , we have enough things to comprehend for life.

It's a different matter. PHP is not just inconvenient to use, does not suit me well, is suboptimal or does not correspond to my religious beliefs. I can tell you a lot of good things about languages ​​that I try to avoid, and a lot of bad things about languages ​​that I like. Go ahead, ask! Interesting discussions turn out.

PHP is the only exception. Virtually every part of PHP is somehow broken. Language, structure, ecosystem: everything is bad . And it is even impossible to point out one deadly thing, so systematic a defect. Every time I try to systematize the flaws of PHP, I’m lost in searching in depth to discover more and more terrible trifles (hence the fractal).
')
PHP is an obstacle, the bane of my craft. I am going crazy about how broken it is and how much every authorized amateur who is unwilling to learn anything else is chanted. He has very little excuse for positive qualities and I would like to forget that he exists at all.

Analogy


I just blurted it out Mel to describe my frustration and she insisted that I reproduce it here:

I can't even say what's wrong with PHP, because ... Okay. Imagine, um, a box of tools. Set of tools. Looks fine, tools like tools.

You take a screwdriver and see a cross with three petals. Okay, not very useful for you, but it may someday be needed.

Take the hammer and are horrified that it is bifurcated on both sides. Of course, it is still suitable, I mean, that you can hammer in nails in the middle of the striker, holding the handle in reverse.

Take pliers that do not have chipping; they are flat and smooth. Not as useful as it could be, but they can still unscrew the bolts.

And so on. All tools are something strange and twisted, but not enough to be completely useless. And in the whole set there is no specific problem; it has all the tools.

Now imagine millions of carpenters using such a set of tools and telling you: “What's wrong with these tools? I have never used anything else and they work great! ” And the carpenters show you the houses they built with pentagonal rooms and a roof upside down. You knock on the door, it just falls inside and they yell at you for breaking their door.

That's what's wrong with PHP.


Alignment of forces


I argue that the language must have the following qualities in order to be useful and productive, and PHP breaks them with wild ease. If you do not agree that they are critical, honestly, I can not imagine how we can reach agreement on anything with us.



My position is:



, , . , , , .


PHP. , . :(



: Python. , , . , ; , , .

PHP-, PHP. , - , PHP. .

PHP



CPAN « Perl». Perl, , .




PHP- . PHP, PHP . .

, : PHP — . , , , , (, , !). , - , , . , PHP: .

, .




















Perl «some assembly required»(. « »), Python — « », PHP — «, C ».




C


, . PHP — -, - . C API, :




. , PHP .

? Perl, sort {$b <=> $a}. Python .sort(reverse=True). PHP, rsort().






reflection








. , , awk Prolog C. , .








.











Web-






PHP; . , , Python, Ruby Perl. PHP .

, Web- - . : Web- , Web-, , Web-, , Web-, . Web- .




Web-. PHP, , «Web-», - .





PHP , . . "<script>" SQL, HTML.

« ». ; , «». : placeholder' SQL, .



PHP- SQL- , sprintf is_numeric, mysql_real_escape_string, addslashes ( « »!). PDO , . PHP . , … .





PHP .



-, , X — , , . . ; , .


, . , . , , :)

PHP - , Python Flask Web'. ( , .) , , . , , ; web- — .

- Pyramid Django, , , Django.

, - , , Learn Python The Hard Way.

Ruby on Rails , Perl Catalyst' . , , , .


:

Source: https://habr.com/ru/post/142140/


All Articles