Hacker News new | past | comments | ask | show | jobs | submit login

None of these languages except for PHP have their own string concatenation operator. They overload + for that purpose. They're also all strong typed languages while PHP is weakly typed. Overloading + for string concatenation in a weakly typed language is a recipe for disaster (see JavaScript).

> Who, after five major releases, decides that what a language really needs is `goto`.

It makes it a much easier compilation target.

> But, despite the tired claim that PHP takes cues from C/C++/Java, they did not reuse ::

They couldn't because unlike C/C++/Java the entire project isn't compiled at once. At compile time, PHP has no idea that the symbol preceding the operator is a class name or namespace from one run to the next. It might have been possible to resolve that with major changes to the underlying engine or maybe not. I absolutely hated the idea of the backslash when proposed but after using it for a while it seems fairly comfortable.




I know that there are reasons for this behavior. None of them are good, however. Why couldn't they reuse the same resolution operator for all three, even if it's not the period character?

Looking at your responses all over this post, there is a big disconnect. Other people -- who probably use and enjoy other languages -- raise issues with PHP that point at poor design. Then you respond with a rationale for why the well-designed thing couldn't be done. (Or, why the poorly-designed thing was done.)

But all designs have rationales. The point is that the people who make design decisions for PHP choose poorly. Even if you give us the rationale, that doesn't make it a good decision in retrospect.

Also, could you explain this statement please:

> It makes it a much easier compilation target.

Do you mean that other languages can be compiled to PHP more easily? Because I have never heard this rationalization before.


> Why couldn't they reuse the same resolution operator for all three, even if it's not the period character?

It may have been possible to do that when the language was originally designed but PHP has taking the long road to getting real OOP. PHP3 had objects but no inheritance; they were really just structs with functions. PHP4 added a lot more ability but, for reasons of compatibility, left a few things unchanged that should have been changed. PHP5 fixed most of those remaining issues and continues to add more features with every release. PHP wasn't designed all at once and things were added as developers demanded them. It was just supposed to be a procedural languages like ASP/VBScript but as a mix of C and Perl; all this object oriented stuff wasn't in the original plan. It now has namespaces and exceptions and all kinds of things that nobody imagined it would ever have. So they can't use one operator for all because each operation compiles down to something different (each from a different time) and that difference needs to be known at compile time without the benefit of knowing what the symbols resolve to.

> Other people -- who probably use and enjoy other languages -- raise issues with PHP that point at poor design.

This is a poor argument. I use and enjoy many other languages. In fact, I'm hardly doing any PHP development right now but I've got half-completed side project I'd like to finish. There's no argument: PHP has a poor design. But if you put things in the context of history, there is reason for that poor design.

> Then you respond with a rationale for why the well-designed thing couldn't be done.

I'm just stating the facts. In this case, it's not like they're going out of the way to be difficult but they have to work with what they have. If you have a time machine we could solve this once and for all.

> that doesn't make it a good decision in retrospect.

Of course, but hindsight is always 20/20. Perhaps Python should have had unicode to start with and should have never made print a statement instead of a function. Perhaps templates were not the best way to add generics to C++. See, we can play this game all night.

> Do you mean that other languages can be compiled to PHP more easily? Because I have never heard this rationalization before.

Yes. That rationalization was one of the reasons for adding it although more in the context of targeting parser generators (like lexx and yacc) to PHP. Even Dijkstra didn't think that goto should been banished from all languages forever.


> This is a poor argument. I use and enjoy many other languages.

Not suggesting that you don't use good languages (unless you use and enjoy PHP). Just saying where other people are coming from.

> Of course, but hindsight is always 20/20. Perhaps Python should have had unicode to start with and should have never made print a statement instead of a function. Perhaps templates were not the best way to add generics to C++. See, we can play this game all night.

The only response I really have to this is that, when some other language teams realize they need to change, they have a better process for setting the future direction of their language.

Much of the fail you describe as being the result of accumulation is really, in my mind, a failure to set or predict the direction of the language.


> unless you use and enjoy PHP

I use an enjoy PHP. I assume that you don't use PHP because if you did, you wouldn't be arguing over such trivial things. For example, the inconsistency of namespace/class/member access looks terrible in theory but in practice it hardly makes any difference. It's not like you get confused as to which one to use and having them look different is somewhat helpful in understanding what the code actually says.

I used to think the backslash was the worse possible thing that could ever been done to PHP but after using it extensively for a while, eh, it's not so bad. At this point, I'd gladly change a whole bunch of other stuff before I'd change that.

> Just saying where other people are coming from.

Hey, I know where other people are coming from. I think I might be more qualified to bitch about the language than those who don't use it day to day.


I use it every day at work, and have been a PHP programmer for years -- however, I don't suffer from the Stockholm syndrome that requires you perform the mental gymnastics involved in rationalizing away sheer volume of fail.

We both work daily with a horrible language, but at least one of us realizes it.


I don't think we're having the discussion you think we're having; I'm well aware of how "horrible" PHP is. But I program in plenty of languages and there is very little difference in code size, code organization, or pain between my code across those languages. I could translate my current PHP project in Python and the differences wouldn't be that great.

I imagine you haven't experience any real pain: programming large projects in VBScript, C++, or doing any work in COBOL. The minor irritations of PHP is just that.

I suspect your problem isn't so much PHP but the code that you have to work with written in PHP. Most PHP code is embarrassingly bad. I'm lucky that, for the most part, I don't have to deal with a lot of terrible PHP code. I bend PHP to my will, not the other way around. A lot of people fault the language design for the insane way people use it -- it doesn't have to be that way.


We're mostly on the same page.

I indict the language designers for making it easy to write bad code. I agree it doesn't have to be that way, people can write good(-ish) code in PHP. It's just that the language team seems to go out of their way to make a language that doesn't appeal to a programmer's sense of symmetry, elegance, consistency, flow, and ease.

All of these things are easily worked around. As a sum though, they contribute to the overwhelming sense that the tool is created by -- and by extension, for -- dumbasses :)

Thankfully, the amount of PHP I have to maintain is decreasing and the time I spend on my own projects is increasing, which is when I get to use better languages.

In previous lives I have had to maintain/develop C++ as well, and I understand that it's painful. All pain is relative, I suppose. I'm sure a woman who has given birth to quadruplets would scoff at this notion of pain.




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

Search: