The problem with PHP

array_reverse() doesn’t maintain array keys.

The problem here isn’t this specific behavior, but it neatly encapsulates one of my core complaints with PHP. Which is: there’s an attitude of “do something dumb, unless the developer asks not to.” You see this over and over in the PHP world. Mangling keys unless you ask not to. Magic quotes being enabled by default. It’s lame, and stupid, and requires the developer to outsmart the language to get basic things done.

This is a problem, because developer time is expensive, and brainpower limited. When things don’t work optimally, that’s wasted developer effort and time. You have to know that there is a problem, and work around it. Or forget that there’s a problem, spend time debugging it, and get a “duh” moment when you remember. Problems like these should not rise to the level of needing attention, because developer attention is better focused on the larger problems.

It’s hard to trust the language to do the right thing for the big stuff when you have to outsmart it to get the small stuff to work.

Leave a Reply