Possible addition to array syntax in PHP

Feb 4, 10:18 pm
tags:

Andi Gutmans approached the php-internals mailing list with a proposal to add a new syntax for array declaration. The current split among the big players in PHP development looks to be about 50/50. The general thought of the opposition is that it is an unnecessary change that will only lead to confusion in the future. Why create two ways of doing the same thing? I personally agree with the opposition. I don’t see anything more elegant about the new proposed syntax. Adding such a new syntax will only makes scripts less readable (because you would have to pay attention for two different methods). Those for the change cite that other languages have this syntax and they personally believe it is more clear. Are those two reasons really enough to justify such an addition?



    1. Even though I understand why the people would be for this change, I personally share the opinion of the opposition: It adds confusion for new people and also for people already into PHP. PHP is not the other languages, so I don’t feel we should try to copy the other languages. PHP has this approach, fine, let’s stick with it and not add other ways. We have too many “aliases” already in the language.



    1. Stefan..I agree totally. Too many ways to do the same thing is just confusing. Do one thing (or one way) and do it well…



    1. While I still think it’s true that people migrate more towards shorter lines of code, I don’t think PHP necessarily needs the short-hand method which resembles JS. It makes sense for a client-side language, because of filesize and whatnot, but since PHP is optimized on the server-side, it is not as crucial. I agree that while it might help in the short-term, it will make things harder in the long-run, with divergent styles of coding. If I had a vote, I’d vote against it.


    1. Andrew Ingram says:

      I’m in favour of it for the following reasons:

      * It looks neater, I like code that looks neat.

      * I’ve used that syntax in other languages and liked it, I see no problem with using syntax from other languages if it works.

      * It strengthens the notion of arrays being a fundamental part of the language by taking away the “array” method which I feel clouds the concept.



    1. I agree with this statement so much so that I’m just going to restate it and leave it as is:

      “PHP has this approach, fine, let’s stick with it and not add other ways. We have too many ‘aliases’ already in the language.”


    1. Sebastia Deutsch says:

      Hey guys… Keep an eye on ruby – there you have a short syntax for arrays. [1,2,3] would make life lots easier and another alias in the language won’t hurt.



    1. I totally agree as well – why make two methods to do the same thing? This is one of the problems with the open source community, to be honest. There are just too many versions of everything, most of them with such subtle changes that I can’t figure out why they even bothered. Although it’s cool that everyone gets to contribute, or have an opinion, some people think that their methods are better than everyone else’s, and this is why we have so many hundreds of versions for everything. To split it here is highly unnecessary.



    1. Is it possible for you to list down the pros and cons of adhering to this over PHP? I guess it is known to everybody that most web working people are into PHP. So, why switch to this?



    1. Thanks for the really usefully Informations Guys. Greetings from Germany,

      Webdesign Agentur




Add your comments

Please keep your comments relevant to this blog entry: inappropriate or purely promotional comments may be removed. To add hyperlink, please follow this example: "your link text":http://your.link.url