Robert Tamayo

R
B
code

PHP is a Chimera

I don't get the hate for PHP. It's a decent language with cool features like variable variables.

But after working with PHP professionally for 5 years, I've noticed some strange things about the language. 

I didn't notice anything that made me hate the language -- I just noticed some things that made me a little confused. Writing in PHP isn't like writing in Java, because Java is a programming language. PHP is not a programming language -- PHP is many programming languages. PHP is the Chimera of programming languages.

PHP is a Chimera



Much like the chimera in classical mythology, PHP is programming language made up of the combination of a lion, a goat, and a snake.

PHP doesn't follow the normal rules of programming. If you ask a normal programming language to give you the position of a substring within a string, they give you an integer. If the substring isn't found in the string, then they return -1. But if you ask PHP to give you the position of a substring within a string, you end up holding its beer while it gives you booleans, integers, and even integers that are also booleans.

If you ask for a substring position in PHP, you write "strpos". But if you ask for a string replacement, you write "str_replace". It has nothing to do with the two r's, either, because for an array it's "in_array". 

What's worse is the order you pass in the arguments.

                1st param       2nd param       3rd param
strpos          haystack        needle          (offset)
str_replace     needle          replacement     haystack
in_array        needle          haystack        (strictness)

Again, I don't get the hate for the language. It's effective. It's just when I write in PHP, I feel like I'm writing in 3 different languages at once.


Comments:
Leave a Comment
Submit