Slashdot Mirror


PHP Gets Namespace Separators, With a Twist

jeevesbond writes "PHP is finally getting support for namespaces. However, after a couple hours of conversation, the developers picked '\' as the separator, instead of the more popular '::'. Fredrik Holmström points out some problems with this approach. The criteria for selection were ease of typing and parsing, how hard it was to make a typo, IDE compatibility, and the number of characters."

18 of 523 comments (clear)

  1. Going back to DOS style... by joaommp · · Score: 5, Funny

    ... and comming full circle.

    1. Re:Going back to DOS style... by joaommp · · Score: 5, Funny

      Jeez, take a joke as it is, will you?

  2. Can\'t read summary by jspenguin1 · · Score: 5, Funny

    I couldn\'t read the summary because it had an unterminated string literal.

  3. But in PHP for Windows by Anonymous Coward · · Score: 5, Funny

    It'll be /, just to keep things interesting.

  4. I have to say they are working really hard.... by A+beautiful+mind · · Score: 5, Insightful

    ...to make PHP the most retarded computer programming language on the planet.

    --
    It takes a man to suffer ignorance and smile
    Be yourself no matter what they say
    1. Re:I have to say they are working really hard.... by FooAtWFU · · Score: 5, Informative

      Oh, they've been at it for a while now ;)

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
  5. The BASIC of the 21st century by mangu · · Score: 5, Insightful

    I once did a lot of work on PHP. Today, when people ask me for upgrades I just migrate it to Python.

    This unfortunate choice of the escape character for namespace separator is stupid, but seems almost irrelevant to me. How many nails do they need in the PHP coffin to bury it?

    1. Re:The BASIC of the 21st century by Dragonslicer · · Score: 5, Funny

      PHP is far from dead. PHP5, with support for real OO, was a huge improvement. There's been a lot of hard work put in to PHP in the last few years to make it a much more viable modern programming language.

      Then I see people suggesting \ for a namespace separator, and I wonder what happened to all the people that put so much work into making PHP5 good, and why we can't get them back.

  6. Re:A long overdue addition by FooAtWFU · · Score: 5, Funny

    I will happily adjust myself in this ONE manor

    While you're livin' it up at your stately manor, I'm coding PHP out of my garage, you insensitive clod!

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
  7. Today is a Wonderful Day by redink1 · · Score: 5, Funny

    The number of days that an old, crusty Perl developer can laugh at another language are few and far between.

    Thank you, PHP.

  8. Easier on which keyboard layout? by Anonymous Coward · · Score: 5, Insightful

    How is it possible for even American developers to be this clueless. Which characters are convenient to type depends entirely on the keyboard layout that is used. Case in point, $ is insanely painful to type on Scandinavian layout.

    If your choice of characters used in your programming language is affected by how easy/hard it is to parse the code, you probably shouldn't be involved in developing a programming language.

  9. Re:WTF? by caluml · · Score: 5, Insightful

    I think their decision to use '\' is very very dumb one.

    You've summed up my opinion concisely. That is *truly* retarded to use the (almost?) universal escape character for another reason. Almost as retarded as Microsoft going with \ for a directory separator.

  10. Re:so what's the problem here? by mysidia · · Score: 5, Informative

    The problem is not merely that it is different.

    The problem is they chose the ESCAPE character as a namespace separator.

    This is even worse than using $ as the namespace separator.

    Because of the problems it causes syntax highlighters, the problem it causes to programmer sanity when storing identifier names in a string.

    The problem it causes when searching through and sanitizing code.

    For example, since \ has a special meaning in the context of a regular expression, searching and replacing using regular expressions just got very painful.

    Copy and paste no longer works for searching and substituting.

    Refactoring just became a major bitch.

  11. Easy to fix this by sfjoe · · Score: 5, Funny

    Since PHP is open source, someone will make a fork with a different separator and the dumber of the two choices will wither away.

    --
    It's simple: I demand prosecution for torture.
  12. Re:what wrong with by moderatorrater · · Score: 5, Informative

    As I remember, everything more complex than just outputting the value of the variable (ie calling a method, accessing a property, etc) requires you to use brackets inside of the string. Namespaces would work the same way without adding any complexity that wasn't already there.

  13. Re:Another fashionable addition for PHP: by chrysalis · · Score: 5, Insightful

    GOTO is what your CPU is actually doing 80% of the time.
    You can pump up your ego by imagining that using a language without something explicitely called "GOTO" makes your code "up with the time". But what you actually do is nothing but GOTOs, just written in a different manner.

    Ironically, the VM that PHP uses is completely GOTO-based (well, you can pick several methods at compile-time, but GOTO is what a lot of distributions chose because performance is often better than CALL and it's very stable nowadays).

    Oh and even JAVA has GOTO and relies a lot on it. The compiler hides an explicit thing called "GOTO", but what you get after compilation is full of GOTO. And it's actually why apps can actually do something.

    Laughing at "GOTO" is ignorance, or just blind trolling because you read somewhere that BASIC had a "GOTO" keyword. I guess in a few years your children will laugh at those horrible "$", "$this", "->", ":" and "\" symbols, that would remind them the old time of a language called PHP. Though you are proud of them now.

    Using temporary variables like "$should_exit", dummy loops just to "break" at the right place, or named loops to work around "break" that would only exit the first loop is nothing but writing "GOTO" in an obfuscated and inefficient way. "GOTO" is not synonym for "spaghetti code" (the famous keyword always used by people blindly repeating that GOTO is bad).

    Oh and grep for "goto" in your Linux kernel or in any BSD operating system. Wow, tons of them. Really. But I guess this is just because these source codes are shits written by people who can barely write GW-BASIC, and of course none of these operating systems actually work. Glad you are there to help. Teach them how to code, tell them that their code is so passé.

    Or shut up.

    --
    {{.sig}}
  14. Re:Another fashionable addition for PHP: by Thuktun · · Score: 5, Insightful

    GOTO is what your CPU is actually doing 80% of the time.

    And your car's engine spends all of its time repeatedly causing small explosions with volatile petroleum.

    The driver is generally recommended to let the engine do this and not try to intervene or do it themselves.

  15. Re:It's all a joke by Requiem18th · · Score: 5, Informative

    And this is (one of) the many reasons PHP sucks:

    Java:
    Attribute/Method access: foo.bar
    Static method access:    Foo.bar
    Package access:          foo.bar.baz

    C#:
    Attribute/Method access: foo.bar
    Static method access:    Foo.bar
    Namespace access:        foo.bar.baz

    Python:
    Attribute/Method access: foo.bar
    Static method access:    Foo.bar
    Module access:           foo.bar.baz

    PHP:
    Attribute/Method access: $foo->bar
    Static method access:    Foo::bar
    Namespace access:        foo\bar\baz

    --
    But... the future refused to change.