Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I can't say I love PHP, but some of your criticisms are a little silly.

For example, about typing... your argument is that when you cast a string to an int, it returns 0. What would you have it return, null?

Typing is jank in a number of ways, but in most cases I See the logic in the original decision. To a noice, the idea that false == "false" (because "false" casts to 0) but true != "true" just seems broken. But what else would you have it do?

About namespaces, people are complaining that PHP should use the dot operator like every other language. PHP uses dot for concat, which eliminates the ambiguity of using + for both concat and addition that exists in other languages. Now, they're going to use a backslash for namespace resolution. And that does create operator ambiguity. So PHP trades one ambiguity (dot) for this other.

And what do you possibly mean by "older style language"? Do you mean functional features? As you probably know, lambad's and closures will be available in 5.3. I agree that Python (my language of choice) and even C# (my 2nd fave) seem cleaner. But of course they do. They're new. Java seemed clean in 1997, too.

And finally.. I do value consistency in userland code and in the runtime. And PHP is horribly inconsistent. A salvation army of a language. But that stopped actually affecting me about 8 years ago when I left behind VIM for a real IDE with intellisense.



What would you have it return, null?

I wouldn't have it return anything. I'd have it throw an exception (type error). Dynamic typing can be a Good Thing. Pretending types don't exist is probably a mistake.

PHP uses the backslash for escaping characters in strings and for line continuation. There's ambiguity being created any way you look at it.

Many languages much older than PHP seem much more modern. Scheme, Smalltalk, Haskell, Python and even Perl come to mind.


But what else would you have it do?

Well, to be fair, most programming languages don't have this problem so it isn't actually that hard to overcome. The problem is that PHP attempts to automatically re-cast variables to different type. So, you try to do int(0) == str("apple") and it says "hmm, we have different types here, but if I made them the same type, maybe they'd be equal. Well, strings should just be integer 0 and int(0) == int(0) so that makes true, right?"

Most languages won't automatically re-cast variables. In PHP, "0" == 0 and "1" == 1. In most languages, they are not equal because they are different types. PHP's auto re-cast gets you into a lot of trouble. What would I have it do? Not auto-recast things to different types. I wouldn't call it a silly criticism seeing as though Java, Python, Ruby, C# and I'm sure others lean my direction rather than PHP's direction.

I agree that Python (my language of choice) and even C# (my 2nd fave) seem cleaner. But of course they do. They're new.

Um, Python came on the scene in 1991. PHP's from 1995.

The reason I'd call PHP an "old style language" is that, while it may have new features, many of those new features are poorly implemented in a way that shows a lack of understanding of the value of those features and that none of PHP's library uses those features.

Strings are still primitive data types in PHP. Since strings are primitive data types and not objects in PHP, you can't have the little nice things that you get in ruby, python, java, c# without resorting to functions that take the string as a parameter. $string->match('/pattern/') is much nicer than match($string, '/pattern/') simply because you don't need to memorize the order the arguments are passed in. And, as I pointed out, PHP isn't even consistent about it. Sure, you can say that PHP has OO-capabilities, but it doesn't use them in the library which means that all the library stuff you'd do doesn't leverage any of that. PHP also doesn't support multiple-inheritance or mixins which makes OO a lot less useful.

PHP has added new stuff, but it's just not all that useful because everything is old stuff and most PHP programmers wouldn't know the difference between a reference and a copy even to have an opinion on it. Other languages are a lot nicer to use not just because of features, but because you actually get to use those features with the language's and library's built-ins.

It's not that PHP is terrible or anything. It's that it was originally meant for things that didn't require complexity. When people wanted to use it for more complex things, it seems like they said "object orientation, that does complexity" and didn't really know what the term meant or why it was useful when they implemented it. Part of it might be not wanting to break backward compatibility and so one can argue that those who originally created the language made a crappy tool and now the current people have to keep that all alive while other languages were designed better from the start.

And the real question is, what does PHP offer to overcome this crap? And it really doesn't offer (at least me) anything. I'm not going to be using a shared host and so PHP's run-anywhere-ness doesn't help me. Other than that, I can't see a reason to run PHP over a nicer language. It's not that PHP is so terrible. To be a bit of a troll here, PHP's like Windows 95. Awesome when it came out, but now it just looks old. When PHP4 was the in-thing, it was easy to cook up a hack-ish script and get it running on any shared host. Now, other languages have great libraries, much better deployment options, and just a nicer coding experience. I remember the time before other languages took the web seriously. PHP rocked then. It offered everything you needed to make a little web app with built-in functions. And other languages wanted me to jump through all sorts of hoops to do simple things like sessions. PHP was like a language and framework in one. The problem is that people coding in other languages started beating PHP at its own game. Making their frameworks better than what PHP offered and better than what PHP + PHP frameworks offered. And so PHP lost a lot of its appeal as things like mysql_query() and $_SESSION and $_REQUEST no longer held the awesome value that they did in the days of yore.

It's not that PHP's terrible, it's that the other languages have made up their ground and PHP hasn't in the areas that it was weak - it may have added features, but it never integrated them into the language and library and so it just seems old.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: