Monday, October 27th, 2008 | Author: AHSauge

No, I’m not joking. As of last Saturday, the development team of PHP decided that backslash will be the new namespace separator in PHP, replacing :: which has been used up until now. The reason for this is quite alarming to be honest. A bug.

Because PHP basically fail to distinct between for instance foo::bar(); as in namespace foo with function bar vs. class foo with static function bar they’ve just decided to scrap the whole :: thing and instead use backslash. I can’t tell you how stupid I think this really is. Instead of actually fixing the problem, faulty look-up, they’ve taken the very easy way out. This just adds to the inconsistencies for PHP. There are several programing languages that I know of that don’t have these problems, and none of them have namespace separation in this way. Actually, I can’t even remember ever seeing any language using backslash for anything other than escaping, but that might just have something to do with other languages being consistent. This quote from a comment on slashdot really says it all:

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

Now I’m not quite done here. If you look at the RFC at PHP about the change they list “IDE compatibility” as criterion for the new namespace separator. This is just plain stupid. Who are you designing a language for, humans or IDEs? I would say it’s for humans, but it seems the PHP devs thinks otherwise …

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
Category: PHP
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses

  1. I agree, this is stupid

  2. First of all congratulation for such a great site. I learned a lot reading article here today. I will make sure i visit this site once a day so i can learn more.

  3. Stupid as it is…
    Darn, I don’t use classes in PHP only for the reason it’s too difficult to type “->” and “::” and it’s so C++’ish which I dislike from the bottom of my heart. Why can’t PHP be like other respectable object oriented languages? Why can’t we have the “.”s???

  4. Yeah, I agree. To be honost, it’s a bit weird really. -> are on most keyboards, if not all, a 1 + 2 key combination which really guaranties it to be a big disrupt in pace and typing. It would be a lot better if they’d use . as most other languages. It’s probably not a coincidence that most programming languages do use it. It’s a very common character which pretty much guaranties that it’s easily accessible on all keyboards, mean no use of shift, ctrl, alt or anything like that. Why they inspite of this went for -> is beond me. Might have something todo with PHP not being found of characters having multiple meanings depending on context, which would be quite lame considering there are other interpreted languages out there that don’t have that problem.

Leave a Reply