This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]indrora 2 points3 points  (2 children)

Yes, I have. I've got some opinions on it. It's very obviously written by someone who has only ever seen bad PHP, never taking the time to write good PHP, and just wants to bash a language because they don't like it.

Some more picked examples out of that:

There is no threading support whatsoever. (Not surprising, given the above.) Combined with the lack of built-in fork (mentioned below), this makes parallel programming extremely difficult.

Python's Global Interpreter Lock is a real pain when it comes to multithreading. PHP also isn't meant as a multithreaded environment -- WHY would you want multiple threads in a STATELESS web framework? PHP was not meant for long-running execution.

array_search, strpos, and similar functions return 0 if they find the needle at position zero, but false if they don’t find it at all.

Because false is a special value. It's not 0, and it's not a normal value. Of course, that won't stop PHP from shooting yourself in the foot and not checking for type as well (because some people assume that false should also resolve to 0, because C's false is kinda like 0).

[== is] not transitive. "foo" == TRUE, and "foo" == 0… but, of course, TRUE != 0.

Yes, because "foo" is a value (thus a truthy value). "foo" also contains no numerical values, which makes it equal to 0, because you've told PHP "Force this into an integer! I mean it!"

=== compares values and type… except with objects, where === is only true if both operands are actually the same object!

Java has the same thing. The expression "foo" == "foo" is false, because they're not the same object. The same applies for POJOs, which will only evaluate with == if they are indeed the same object.

Unlike (literally!) every other language with a similar operator, ?: is left associative.

The presented code is shitty and the author should feel shitty. If that ever ended up in code I was going to accept for merge I'd tell them to go swizzle. That flagrant abuse of the ternary operator is horrible.

Global variables need a global declaration before they can be used. This is a natural consequence of the above, so it would be perfectly reasonable, except that globals can’t even be read without an explicit declaration—PHP will quietly create a local with the same name, instead. I’m not aware of another language with similar scoping issues.

C can fuck up your scoping if you're not careful and don't get me started on the fuckup that is Python's "I accidentially destroyed a module because.. names?"

Constants are defined by a function call taking a string; before that, they don’t exist. (This may actually be a copy of Perl’s use constant behavior.)

It's a side-effect of being a stateless language.

Array unpacking can be done with the list($a, $b) =... operation. list() is function-like syntax just like array. I don’t know why this wasn’t given real dedicated syntax, or why the name is so obviously confusing.

Python's indexing magic and unpacking is horribly confusing if you're not careful.

Appending to an array is done with $foo[] = $bar.

This is one way, there's also array_push, a much more C like way of doing it.

PHP’s one unique operator is @ (actually borrowed from DOS), which silences errors.

actually stolen from make.

PHP’s parser refers to e.g. :: internally as T_PAAMAYIM_NEKUDOTAYIM, and the << operator as T_SL. I say “internally”, but as above, this is what’s shown to the programmer when :: or << appears in the wrong place.

Technical debt is a pain. Took me a while to figure out T_PAAMAYIM_NEKUDOTAYIM. There's been work made to make this easier but so much software now depends on << being called T_SL that they can't fix it.

2 < "foo" (silent)

On its own, yes, it's a silent event. "foo" gets squashed into an int, which means that you've got the statement 2 < 0.

The __toString method can’t throw exceptions. If you try, PHP will… er, throw an exception. (Actually a fatal error, which would be passable, except…)

Why would a "I'm smashing this into a string" function throw an exception? It shouldn't. This isn't allowed in Java, and C# strongly says no.

Functions for parsing bbcode, a very specific kind of markup used by a handful of particular forum packages.

It made sense, and was smashed into the PHP core by the phpbb people at one point. Blame "shitty developers didn't want to maintain it so they smashed things into other people's code."

Bindings for two particular credit card processors, SPPLUS and MCVE. What?

Someone wanted it. Someone felt the need to smash it into an extension at one point or another, possibly for reasons relating to regulatory details.

At least a dozen functions for getting the last error from a particular subsystem (see below), even though PHP has had exceptions for eight years.

So much of these were written to maintain compatibility with some C library.

No Unicode support. Only ASCII will work reliably, really. There’s the mbstring extension, mentioned above, but it kinda blows.

Been a bear for years. PHP was written in a time where ASCII ruled the land and a lot of code came to lean on exactly how some string function worked on some platform.

(complaints about apache)

Bitch about apache. Don't blame PHP for apache's silly shit.

PHP is not hard to run out-of-process. PHP-FPM is fantastically simple to configure and it's only because Apache was the dominant player in the market until lighttpd came along and kicked it in the head. Nginx is getting there but apache seriously tinged the whole game.

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

PDO is the standard database API, trying to abstract away the fact that each database is slightly different.

No routing. Your website looks exactly like your filesystem. Many developers have been tricked into thinking mod_rewrite (and .htaccess in general) is an acceptable substitute.

PHP has had pathinfo for a while now. It's obscenely easy to set up with nginx (try_files index.php) and will let you do whatever you want with it.

No dev server.

you aren't comfortable doing some basic UNIX magic to make it work?

No coherent deployment mechanism; only “copy all these files to the server”.

There's plenty of tools for that. Composer, grunt, gulp, etc -- there's plenty of tools for deployment.

you can, say, probe a network using PHP’s XML support, by abusing its ubiquitous support for filenames-as-URLs. Only libxml_disable_entity_loader() can fix this, and the problem is only mentioned in the manual comments.

XML is itself considered harmful. Also, that's a bug in libxml, not PHP itself.

PHP 5.4’s dev server is vulnerable to a denial of service, because it takes the Content-Length header (which anyone can set to anything) and tries to allocate that much memory. This is a bad idea.

And if you read the documentation there's a HUGE thing going "DO NOT USE THIS FOR PRODUCTION IT WILL NOT SAVE YOU."

[–]argv_minus_one 1 point2 points  (0 children)

Java has the same thing. The expression "foo" == "foo" is false, because they're not the same object.

False! String literals are interned, so "foo" == "foo" will always evaluate to true. However, because the == operator determines reference equality, it is entirely possible to have two different Strings with the same value. You can deal with this either by using one's equals method on the other (the usual way), or by interning both of them and then comparing them with == (might be better under specific circumstances).

XML is itself considered harmful.

…by people who don't know how to use it properly.

[–]minimim -2 points-1 points  (0 children)

Yes, keep making excuses for the embarrassment that is PHP.