Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

PHP Gets Namespace Separators, With a Twist

Soulskill posted more than 5 years ago | from the or-maybe-more-of-a-slant dept.

PHP 523

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."

cancel ×

523 comments

Sorry! There are no comments related to the filter you selected.

Going back to DOS style... (5, Funny)

joaommp (685612) | more than 5 years ago | (#25518371)

... and comming full circle.

Re:Going back to DOS style... (0, Troll)

Dogtanian (588974) | more than 5 years ago | (#25518459)

Going back to DOS style...

No; DOS used the backslash as a directory separator (since- apparently- someone had permitted forward slash to be a legal filename character before subdirectories had been introduced).

AFAIK PHP uses the forward slash for that purpose (or does this depend upon the server/OS it's running under?) Either way, namespaces have nothing to do with the infamous DOS usage.

Re:Going back to DOS style... (4, Informative)

Anonymous Coward | more than 5 years ago | (#25518491)

Uhm no. Because the DOS commands used '/' for indicating options as opposed to the '-' of the UNIX world.

Re:Going back to DOS style... (2, Informative)

larry bagina (561269) | more than 5 years ago | (#25518507)

which was based on CPM and VMS.

Re:Going back to DOS style... (5, Funny)

joaommp (685612) | more than 5 years ago | (#25518509)

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

Re:Going back to DOS style... (0)

Anonymous Coward | more than 5 years ago | (#25519093)

It isn't much of a stretch to consider a subdirectory as a namespace for file names. It's hard to believe now, but back then we had plenty of systems with no directory support - all files had to have a unique name. In this context, a subdirectory was a wonderful new feature, with much the same advantages as a namespace has in programming.

Re:Going back to DOS style... (-1, Troll)

Pikiwedia.net (1392595) | more than 5 years ago | (#25518523)

Well, DOS didn't really have namespaces [pikiwedia.net] and this is a nice improvement of PHP. Namespaces has some disadvantages, it doesn't scale very well and it allows inconsistent nameing conventions but this increases developer's freedom.

Re:Going back to DOS style... (1)

lysergic.acid (845423) | more than 5 years ago | (#25518911)

what exactly is Pikiwedia? just a static non-editable version of Wikipedia? it looks exactly like Wikipedia but with all collaborative editing features/links, Wikipedia branding, and basic navigation elements(i.e. search) removed.

the content is copied directly from Wikipedia, and though it doesn't seem completely up to date, it's only about a month outdated. therefore it's not completely static, so you wouldn't be able to cite Pikiwedia pages as a fixed source any more than you could Wikipedia.

at least Answers.com adds additional content/features (dictionary results & pronounciation audio clips) to the Wikipedia articles--and they also have a search feature. frankly, i don't see what value Pikiwedia has aside from being yet another Wikipedia mirror.

Re:Going back to DOS style... (1)

NemosomeN (670035) | more than 5 years ago | (#25518977)

I was wondering the same, Google helped very little, maybe lower bandwidth? Seems useless to link to. Not sure why Wikipedia is mirrored so often, what is Wikipedia's uptime? I'd be shocked if it were below 99.9%, maybe even a 5-niner.

Re:Going back to DOS style... (2, Insightful)

The Bender (801382) | more than 5 years ago | (#25518955)

Geez, you have a website that just mirrors Wikipedia and dumps google ads all over it? You must be some kind of a business genius. Particularly since you seem to think that spamming /. will get you clicks. Bandwidth usage and hatred maybe, but clicks, nope.

FRIST PSOT (-1, Troll)

Anonymous Coward | more than 5 years ago | (#25518381)

where is it?

what wrong with (0, Offtopic)

netdur (816698) | more than 5 years ago | (#25518385)

dot?

php now is anti-slash dot?

Re:what wrong with (2, Funny)

FooAtWFU (699187) | more than 5 years ago | (#25518499)

Slashcode runs off of Perl. They must hates it with a passion.

[sic]

Re:what wrong with (4, Insightful)

anotherone (132088) | more than 5 years ago | (#25518501)

PHP uses the . as the concatenation operator. PHP does not support operator overloading...

Re:what wrong with (2, Informative)

mysidia (191772) | more than 5 years ago | (#25518853)

PHP uses the . as the concatenation operator. PHP does not support operator overloading...

You don't need operator overloading. To use the same symbol in different contexts.

You need a parser worth its salt.

a.one = $b.two . $a.one

Only has one use of the concatenation operator if 'a' and 'b' are namespaces.

A good convention is to simply require space around the concatenation operator. Or to require both operands meet the lexical conventions of a variable or string constant, for it to be interpreted as a concatenation.

I.e. $X = $A . $B

Is a concatenation

$X = $A.$B

Is a parse error

$X = $A.B

Is an assignment of 'X' to the 'B' variable within the 'A' namespace

Re:what wrong with (4, Insightful)

moderatorrater (1095745) | more than 5 years ago | (#25519017)

The whole purpose behind using '.' as string concatenation instead of '+' is that it eliminates ambiguity. What you're suggesting throws the ambiguity back in. Remember, if it's more complex for the parser to understand, it's more complex for a human to understand. As a programmer who moves between PHP and Javascript a lot, I can tell you that I miss being able to use a dot for objects when I'm in PHP, but the ambiguity in string concatenation/addition in javascript is an order of magnitude more annoying.

I suspect they're doing the same thing with namespaces. The backslash isn't used for anything except escaping strings, and I doubt that's going to add any ambiguity at all. There are a lot of problems with PHP, and it's well worth your ridicule, but making sure that separate operations have separate operators isn't one of those problems.

Another fashionable addition for PHP: (4, Insightful)

Anonymous Coward | more than 5 years ago | (#25518387)

PHP 5.3 also adds support for local GOTOs. This langauge is so up with the times.

Can\'t read summary (5, Funny)

jspenguin1 (883588) | more than 5 years ago | (#25518391)

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

WTF? (1, Insightful)

Anonymous Coward | more than 5 years ago | (#25518403)

Being different to be different, aren't we?

Re:WTF? (4, Interesting)

ThePhilips (752041) | more than 5 years ago | (#25518723)

You should say "thanks" they haven't chosen something else. e.g Jam (build system; make analog) uses "!" as a "platform neutral" path separator. During evaluations for new build system I joked that I oppose jam since we do not need a "platform neutral" system - we need one for *nix and cygwin. To my surprise many supported me.

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

I'm still huge fan of Objective-C in that aspect. Unlike C++, which tried to marry C and objects, ObjC took more pragmatic approach: C constructs remains C constructs and object oriented constructs got new distinctive syntax so that you can never mix up what code you are looking at.

In that aspect, I think PHP folks would regret their decision in future: '\' isn't distinctive enough and they would need to introduce more silly syntax hacks when extending language further.

Re:WTF? (5, Insightful)

caluml (551744) | more than 5 years ago | (#25518819)

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.

Re:WTF? (1)

dascritch (808772) | more than 5 years ago | (#25519043)

Having an AZERTY keyboard, living in France, I do remember the difficulty to have \ characters on certains small keyboard in MSDOS.
Two methods : AltGr + 8
or Alt + 9 + 2

And PHP group thinks it's easer to use ?
that is soooooooooooo simple to use it instead of "::"

Re:WTF? (2, Funny)

moderatorrater (1095745) | more than 5 years ago | (#25519055)

When are you going to use the escape character outside of a string? I agree that it's dumb, and it's going to make for ugly looking code, but saying that it shouldn't be used because it's an escape character seems like an empty criticism. It's like saying that Elisabeth Taylor's personal life is messed up because she doesn't pay enough attention to her hair.

That's because.. (1, Insightful)

Anonymous Coward | more than 5 years ago | (#25518405)

There's obvious drawbacks for using a period (.) as a string concatenator, it's easy to put strings together since typing a period is a lot easier than a plus (+), but this means you can't use a period for namespaces as many OO coders are used to..

Re:That's because.. (4, Insightful)

SoapBox17 (1020345) | more than 5 years ago | (#25518883)

Since PHP is a weakly typed language, using + for string concatenation would introduce a number of problems. + is used numeric addition, and thus automatically converts the operands to numbers before adding them.

So using + for string concat too would be basically impossible... When would you decide to concat the operands, and when would they be added? If you base it on the results of the string to number conversion, you get situations where the same line of code sometimes adds numbers and other times concatenates strings, or where it is impossible to concat two strings which contain only digits.

Re:That's because.. (1)

Tablizer (95088) | more than 5 years ago | (#25518939)

What about VB-style "&" for concatenation?

Re:That's because.. (1)

moderatorrater (1095745) | more than 5 years ago | (#25519107)

Case in point, javascript. Concatenating instead of adding causes a lot more bugs than anything else I've seen about the language.

Re:That's because.. (1)

coryking (104614) | more than 5 years ago | (#25518957)

Personally, I get annoyed with languages like Javascript that use + for string concatenation. VB did it back in the day, and you would sometimes run into issues where you'd combine two variables and it would treat one as an integer or a decimal and do the wrong or unexpected thing. IIRC you could do this:

Dim myInt as Variant
Dim myStr as string

myInt = 1
myStr = "hi"

myStr = myStr + myInt

And you'd get something like "hi1.0"

It just doesn't feel right to do the same thing in modern languages. What should be the result of this bit of javascript?


var myInt = 1.0;
var myStr = "hello"
alert(myStr + myInt);

What should that return?

I dunno, maybe I'm full of it, but I just dont like when dynamic languages use "+" for both addition and concatenation.

Re:That's because.. (1)

Fweeky (41046) | more than 5 years ago | (#25519119)

Python: TypeError: cannot concatenate 'str' and 'float' objects
Ruby: TypeError: can't convert Float into String

Weak typing is the problem, not dynamic typing.

But in PHP for Windows (5, Funny)

Anonymous Coward | more than 5 years ago | (#25518409)

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

Re:But in PHP for Windows (1, Funny)

Anonymous Coward | more than 5 years ago | (#25518969)

I thought they chose \ to make windows users feel like at home..

HOLY FUCKING SHIT!?!?! (-1, Redundant)

Anonymous Coward | more than 5 years ago | (#25518419)

/ not ::??? What the fuck were they on?!?!

Re:HOLY FUCKING SHIT!?!?! (-1, Redundant)

Anonymous Coward | more than 5 years ago | (#25518751)

How the FUCK did you get modded insightful?

Re:HOLY FUCKING SHIT!?!?! (1, Funny)

mweather (1089505) | more than 5 years ago | (#25518979)

Yeah, you don't need insight to know the developers were high as a kite.

Re:HOLY FUCKING SHIT!?!?! (4, Informative)

coryking (104614) | more than 5 years ago | (#25518825)

Except you just made a typo. It is "\" instead.

Either way, most languages use either "." or "::" for namespaces

# perl looks like
use My::CPAN::Module qw();
my $instance = My::CPAN::Module->new("junk");

# c# looks like
using System.Windows.Controls;

System.Windows.Controls.ListBox box = new System.Windows.Controls.ListBox();

# c++ looks like (I think)
namespace Blah::Blah;

# php will now look like
$object_instance = new My\PEAR\Module("myvar");

I'll leave the "looks" of PHP's method to the reader.

I have to say they are working really hard.... (5, Insightful)

A beautiful mind (821714) | more than 5 years ago | (#25518443)

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

Re:I have to say they are working really hard.... (5, Informative)

FooAtWFU (699187) | more than 5 years ago | (#25518457)

Oh, they've been at it for a while now [www.tnx.nl] ;)

Re:I have to say they are working really hard.... (1)

ThePhilips (752041) | more than 5 years ago | (#25518831)

Hm... Thanks for the link. Enlightening reading.

Now I'm slowly getting why people even bother to use Python for Web. Pretty much natural choice for all who can't (or refuses) to grok Perl, yet want to have a real language at their disposal.

I used PHP around year 2000. It was simple like toy. But it seems that its developers didn't realize that the language did outgrow the sandbox they were living in. Also - the responsibility they carry before all the web developers who invested time into learning PHP.

It seems that the PHP developers had chosen path of M$VB.

Re:I have to say they are working really hard.... (1)

Just Some Guy (3352) | more than 5 years ago | (#25519111)

For the record, I grok Perl just fine, but fell in love with Python because it felt like "Perl done right". I don't avoid Perl because I have to, but because I can. I just mentioned that because a lot of people really seem to believe that Python is for people who can't handle anything else.

Re:I have to say they are working really hard.... (1)

-noefordeg- (697342) | more than 5 years ago | (#25518987)

Seriously...
That link compares PHP to Perl.

I spit on Perl and so does everybody else I know. Had it at least been Python, Java or something, but Perl?!

My biggest gripe with PHP now, is the lack of support for good IDE with -GOOD- debugging capabilities. God damn !"#%@-Zend...

The BASIC of the 21st century (5, Insightful)

mangu (126918) | more than 5 years ago | (#25518505)

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?

Re:The BASIC of the 21st century (1)

rawg (23000) | more than 5 years ago | (#25518575)

and I'm migrating them over to Ruby on Rails or Merb. PHP is lame.

Re:The BASIC of the 21st century (5, Funny)

Dragonslicer (991472) | more than 5 years ago | (#25518627)

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.

Re:The BASIC of the 21st century (2, Insightful)

mangu (126918) | more than 5 years ago | (#25518703)

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.

The last one was seen downloading a Ruby On Rails development environment.

Re:The BASIC of the 21st century (0)

Anonymous Coward | more than 5 years ago | (#25518755)

Well, it's apparent that they rejected double-colon ("::") because they didn't want folks to be confused with DECnet node names.

And Python is better? (0, Troll)

Anonymous Coward | more than 5 years ago | (#25518699)

OK, yes Python is better than PHP but they're both a pain in the ass for the web/text based world of web development. I mean really, both PHP and Python are not that much easier to use than just writing a program in C/C++. Things like regular expressions are stupidly annoying to use (compare to Perl or Lua+LPeg). I don't even get the point of Python because it's a slow scripting language with almost all the verbose complexity of a compiled language. Just weird.

Unfortunately there aren't a lot of options. Perl isn't all that great because while it's awesome at the usability and text processing part it's not so good from a structured design point of view. It's difficult to design complicated software in Perl. Plus Perl is basically dead since they decided to start that idiotic Perl 6 project that will never be finished (and even if it is I'm sure it will suck).

My personal choice would be something like Lua with LPeg and a nice large supporting library. I know the Kepler project does work in this space but their stuff isn't anywhere near as nice as what is available in PHP and Perl API's. Their designs are just odd because they approach things from a Lua point of view instead of a web developer point of view.

Re:And Python is better? (1)

eric2hill (33085) | more than 5 years ago | (#25518815)

You could write your web application in C++ [tntnet.org] but I'm not sure if anyone other than you would be able to understand it in 5 years... :)

Re:The BASIC of the 21st century (0)

bjtuna (70129) | more than 5 years ago | (#25518707)

So, when people ask you for minor upgrades on their existing PHP websites, you rewrite the whole thing in Python. Do you really? I'm not buying it.

Re:The BASIC of the 21st century (0, Flamebait)

Anonymous Coward | more than 5 years ago | (#25518767)

Notice how he said "when people ask me", meaning he's just yet another college guy who has done a few pages for some club or whatnot and therefore thinks he's hot shit. He has obviously never worked in a professional development environment, where the technology used to create the web front end is largely totally irrelevant as that layer is given so little control that anything will work. I get happy just thinking about this guy then he leaves his college with his worthless degree, getting hit right in the face when he comes out and realizes that web developers are the IT world's equivalence to fluffers in porn.

Re:The BASIC of the 21st century (1)

mangu (126918) | more than 5 years ago | (#25518777)

I don't do minor upgrades, there are other people for that. When a major upgrade is needed, let's say from version "2.7" to "3.0" they call me.

Re:The BASIC of the 21st century (2, Funny)

faraway (174370) | more than 5 years ago | (#25519059)

I don't do minor upgrades, there are other people for that. When a major upgrade is needed, let's say from version "2.7" to "3.0" they call me.

Wow. So you're the guy that does those small changes huh? They usually call me for "3" to "4". I write it all in machine language for optimized speeds and job protection.

Re:The BASIC of the 21st century (2, Interesting)

mweather (1089505) | more than 5 years ago | (#25519085)

It's not that hard to convert existing websites into Django, Pylons or TurboGears apps. Usually it's much faster than familiarizing yourself with the PHP code enough to make the needed changes.

Re:The BASIC of the 21st century (0)

Anonymous Coward | more than 5 years ago | (#25519005)

Since PHP is so widely spread:

I'm just waiting for some nutcase to develop a "sensible programming language to PHP" compiler.

That would make things even more interesting. =)

Re:I have to say they are working really hard.... (1)

thc4k (951561) | more than 5 years ago | (#25518927)

... on collecting every bad design choice in one place, to serve as a warning to others. Php has beem the prime source for how-not-to's for ages now, and still manage to come up with new stuff .. respect!

While at it... (1)

Shados (741919) | more than 5 years ago | (#25518477)

While at it, they should have picked a page from the W3C and made namespaces full, compliant URIs.

That would have been epic! /sarcasm.

.NET / WPF is going this way (2, Interesting)

coryking (104614) | more than 5 years ago | (#25518909)

At least in a sense. You can map a .NET namespace to an XML namespace. Say you have namespace that is:

Shados.Awesome.Controls

You can map that into:

http://www.shados.com/controls

In c# you'd plunk this into your AssemblyInfo.cs file:
[XmlnsDefinition("Shadows.Awesome.Controls","http://www.shados.com/controls")]
And thus add it to your XAML code:


<UserControl xmlns="http://www.microsoft.com/xml/something"
xmlns:shadow="http://www.shados.com/controls">
<shadow:AwesomeControl x:Name="myControl" param="aParam" />
</UserControl>

You can even get multiple .NET namespaces to map into a single XML namespace.

yet another wtf (3, Interesting)

larry bagina (561269) | more than 5 years ago | (#25518489)

The rfc [php.net] claims that typing "**" is easier than typing "%%" or "^^".

Re:yet another wtf (1, Insightful)

Anonymous Coward | more than 5 years ago | (#25518557)

All I can say is that "\" is a key combination of a right hand key with AltGr on a German keyboard. How is that easy to type? "::" is Shift-. on all keyboards that I know of.

Re:yet another wtf (2, Funny)

Mental Maelstrom (1268890) | more than 5 years ago | (#25518659)

AltGr + Plus [the key right of number 0] on Estonian layout also. This is so discriminatory! :P

We should use a character present on most keyboard layouts. I propose the use of the Space-key for this purpose.

Re:yet another wtf (1)

Televiper2000 (1145415) | more than 5 years ago | (#25518735)

This sounds similar to some programmers complaining about case sensitivity. If there is a typo risk in typing the same same character two or three times in a row ala ::: or ** how in the world are you having any success with the other 20,000,000 characters you're stringing together?

Re:yet another wtf (1)

e4g4 (533831) | more than 5 years ago | (#25518869)

The rfc [php.net] claims that typing "**" is easier than typing "%%" or "^^".

But it is! ... if your right shift key is broken...

A long overdue addition (2, Insightful)

DontLickJesus (1141027) | more than 5 years ago | (#25518495)

As a developer who primarily works with C#/.Net, with a little PHP on the side, IMO this addition is long overdue. It would be nice to have a more standard separator, but when I RTFA they seem to have a just reason for it, and it's using semantics that PHP coders are used to. I will happily adjust myself in this ONE manor in order to reap the MANY benefits of namespaces.

Just my 2 cents.

Re:A long overdue addition (5, Funny)

FooAtWFU (699187) | more than 5 years ago | (#25518533)

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!

Re:A long overdue addition (4, Insightful)

Shados (741919) | more than 5 years ago | (#25518617)

Thats all good. I personally feel its just easier to avoid PHP altogether and not have to adjust to all of the language's quirks for little to no benefits from other offerings. Simpler that way.

Backslash! (3, Funny)

SEWilco (27983) | more than 5 years ago | (#25518537)

Just make sure they name it a backslash in the documentation, not a slash.

Well now we all know what trouble this is going .. (4, Funny)

3seas (184403) | more than 5 years ago | (#25518561)

... to cause for windows servers...

imagine what directories will be deleted due to a typo!

F\ck (1)

vawarayer (1035638) | more than 5 years ago | (#25518567)

F\ck :P

Well, That Does It! (0, Flamebait)

maz2331 (1104901) | more than 5 years ago | (#25518573)

OMFG - this addition is just so horrid that everyone's going to give up on PHP and start coding Web apps in C++ through CGI interfaces again. /Sarcasm

Seriously, who cares what charater they are using? Developers are smart enough to adapt.

Re:Well, That Does It! (0)

Anonymous Coward | more than 5 years ago | (#25518667)

OMFG - this addition is just so horrid that everyone's going to give up on PHP and start coding Web apps in C++ through CGI interfaces again. /Sarcasm

Seriously, who cares what charater they are using? Developers are smart enough to adapt.

I would love to agree with you and formerly would have done but judging by some of these comments... *shudders*

Re:Well, That Does It! (3, Insightful)

Zontar The Mindless (9002) | more than 5 years ago | (#25518695)

It's not just developers, it's things like IDEs which highlight anything starting with '\' as an escape sequence.

Which - since nearly every other common programming or scripting language uses '\' to mark the beginning of an escape sequence - is something you might reasonably expect.

Come to think of it, so does PHP... ooops...

Re:Well, That Does It! (1, Funny)

TheRaven64 (641858) | more than 5 years ago | (#25518745)

There are lots of valid reasons for hating any given language, but syntax is rarely one of them. (Lisp excepted)

Re:Well, That Does It! (2, Interesting)

larry bagina (561269) | more than 5 years ago | (#25518803)

This isn't the first (or last) time PHP developers have implemented a stupid workaround rather than fixing problems with the language/runtime/interpreter/parser/scanner.

Re:Well, That Does It! (1, Funny)

Anonymous Coward | more than 5 years ago | (#25518945)

You mean "language\runtime\interpreter\parser\scanner".

\ instead of :: ? (1)

AdmiralXyz (1378985) | more than 5 years ago | (#25518599)

This means eternal war!

other issues (4, Insightful)

adamruck (638131) | more than 5 years ago | (#25518613)

Maybe they could starting fixing the noun-verb vs verb-noun problems instead.

Re:other issues (1)

mdmkolbe (944892) | more than 5 years ago | (#25519087)

I speak an subject-object-verb [wikipedia.org] language you insensitive clod. RPN is the One True Way.

Re:other issues (1)

dascritch (808772) | more than 5 years ago | (#25519091)

or (needle,array) / (array,neddle) confusion

Even with years of coding, I can't remember exactly function names or attributes, which is blaming when PHP.net site is down.

I bet having better naming/call conventions will save them wagons of bandwith !

Today is a Wonderful Day (5, Funny)

redink1 (519766) | more than 5 years ago | (#25518689)

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

Thank you, PHP.

Re:Today is a Wonderful Day (3, Interesting)

siride (974284) | more than 5 years ago | (#25518967)

Perl once used "'" to separate package name parts. Still does for backwards compatibility. Really annoying. Oops! I love Perl, btw.

so what's the problem here? (1)

Tumbleweed (3706) | more than 5 years ago | (#25518693)

Is the problem that they chose something 'different' than what everyone else uses, or is there a real technical reason behind the snarkiness? I think it's a good thing they even considered the issues involved, though I'd disagree with the 'ease of typing' issue - once your fingers leave the home row, you dramatically increase the chances of a typo. People who aren't touch typists have some pretty serious misunderstandings about typing ease. (Hello, Apple keyboard designers, I'm looking at you.)

Re:so what's the problem here? (5, Informative)

mysidia (191772) | more than 5 years ago | (#25518959)

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.

What about Eval? (3, Funny)

coryking (104614) | more than 5 years ago | (#25519121)

Now do you have to escape your namespaces before passing them through eval?

eval("$instance = new My\\Super\\Class(\"blah\"););

Since they now are using the escape character for namespaces, I wonder what kinds of security implications this might have? What happens when a PHP program for some reason evals() some user input that doesn't properly escape the namespaces?

oh my... (-1, Flamebait)

Anonymous Coward | more than 5 years ago | (#25518709)

oh my....

what's the problem with php, it seems to me a quintessential "just another language", without interesting features, and disposable by design. they keep it that way intentionally, it seems.

recently i saw several performance comparisons and it seems at least useless even by that point of view.

of course it's one of the most used languages in the web world.

i hope it dies, horribly and SOON.

All languages (1)

symbolset (646467) | more than 5 years ago | (#25518791)

... are just another language. They all do the same stuff and 95% of what you want to do happens in the library anyway, so the language is just a framework for iterating your library calls or instantiating your objects if you prefer. They all have corners of stupidity you have to work around - some more than others, but what does it matter really?

Phalanger (1)

shutdown -p now (807394) | more than 5 years ago | (#25518725)

It's interesting to see what the Phalanger [php-compiler.net] guys are going to do now. They've already been using ":::" as a namespace separator for their .NET/CLR language extensions, as the next most logical choice. And now this.

On the whole, though, this is probably just as bad as using "." for string concatenation (it was sort of okay for Perl because back then it wasn't yet used ubiquitously as a member access operator, but for PHP, it was a dumb choice). Backslash has a near-universal meaning as an escape character for several large language families now (all curly-braces family languages - C/C++/Java/C#/EcmaScript, and almost all modern popular scripting languages - Python, Ruby, Lua...). It's even used as the same in PHP, given that it is also a curly-braces language. Reusing it outside string literals in an entirely different capacity is not a good idea (especially when other languages of the family have already applied different meaning to backslash outside string literals - in C# and Java it's used to escape Unicode characters in identifiers).

Re:Phalanger (1)

mysidia (191772) | more than 5 years ago | (#25519037)

C# and Java it's used to escape Unicode characters in identifiers

Ok.. I was wrong there IS something worse than using the ESCAPE character to delineate namespaces.

Allowing unicode characters in identifiers is SICK and not to be encouraged by any programming language or any compiler for any reason, as the issues are even more widespread than with this PHP issue.

The need to ever escape the unicode character in identifier name should be ample evidence to that effect.

#irc.trooltalk.com (-1, Offtopic)

Anonymous Coward | more than 5 years ago | (#25518759)

= 1440 NetBSD yes, I work fo8 Preferrably with an to fight what has

Easier on which keyboard layout? (5, Insightful)

Anonymous Coward | more than 5 years ago | (#25518761)

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.

Gripe Moan Bitch and Holler! (-1, Troll)

FlyingGuy (989135) | more than 5 years ago | (#25518807)

Seriously, I mean WTF! It is a scripting language for fucks sake, why does it matter to you what they use? If you use the language, thats the deal, if you don't then use whatever C clone you like, there are plenty of them out there, or better yet, just program in C, why screw around with all the intermediate shite? You can write smaller, more compact & light weight server side programs in C then you can for just about anything else.

Scripting languages are for convenience, nothing more nothing less. Anything you can do in ANY scripting language be it Perl, Python, PHP, Rails or whatever, pick any of them, you can build faster, smaller and better programs in C.

Native binary languages for *nix system have all the same goodies in them just written at lower levels and you have to do a little work, or god forbid, some memory management, a horrific thought I know, but what do you think all this stuff is written in? Uhmm mostly C or its bastard stepchild, C++

Scripting languages are for those of a weak mind and poor technical skills and the singular lack of the ability to plan a system out before you write one line of code.

Re:Gripe Moan Bitch and Holler! (3, Insightful)

SUB7IME (604466) | more than 5 years ago | (#25518899)

Scripting languages are for those of a weak mind and poor technical skills and the singular lack of the ability to plan a system out before you write one line of code.

Or for projects that need to be compiled at runtime. But, nice magnanimity.

Re:Gripe Moan Bitch and Holler! (1)

aftk2 (556992) | more than 5 years ago | (#25518903)

Ahaha...this comment cracked me up. You must not do any client work, huh.

Re:Gripe Moan Bitch and Holler! (1)

maxume (22995) | more than 5 years ago | (#25519139)

I took it as an extremely well crafted troll.

Re:Gripe Moan Bitch and Holler! (0)

Anonymous Coward | more than 5 years ago | (#25518915)

Sure, why not, right? Let's reinvent the wheel EVERY FUCKING TIME we write the specs for a language. We don't want anyone getting comfortable now. Shit, let's make sure we use EBCDIC encoding for PHP7, too -- hey, don't complain, it's a scripting language! That's the deal!

You are a narrow-minded BUFFOON, sir.

Re:Gripe Moan Bitch and Holler! (0, Flamebait)

siride (974284) | more than 5 years ago | (#25519053)

Let me know when C has closures and introspection. Sure, you can do it, but the result is so ugly and messy it severely obscures the meaning of the code. That, my friend, is the problem with C. Unless you really really need that last ounce of performance, or you are writing systems software, C is almost never a good choice.

Classes, namespaces, and subnamespaces (4, Informative)

janwedekind (778872) | more than 5 years ago | (#25518833)

Looking at the IRC discussion [php.net] it seems that they didn't have much of a choice.

Other suggestions (3, Interesting)

lepidosteus (1102443) | more than 5 years ago | (#25519029)

For additionnal fun, read this: http://wiki.php.net/rfc/namespaceseparator [php.net]

Looks like they considered stuff like :> and :) as separators for namespace. Seriously.
Also, they don't give any malus for tybe-ability to \ while on most european keyboards it's a lot harder than any other suggested separator. Way to go !

Well... (1)

Tablizer (95088) | more than 5 years ago | (#25519047)

You know what they say:

If you don't like it, you can go fork yourself.
       

\ vs / (1)

fahrbot-bot (874524) | more than 5 years ago | (#25519069)

From the TFA:

\ looks a lot like / and is easy to accidentally flip, especially for unix users

Um, that should be "especially for DOS / Windows users". Unix was here first dumb asses

Furthermore, using the character, that just about every other programming language uses for the escape character, as an operator (or separator) is just plain stupid -- I'm also talking to you Microsoft, but that horse has definitely left the barn...

The real question is (0)

Anonymous Coward | more than 5 years ago | (#25519131)

The real question is: will they admit their mistake and correct it before it destroys the community?

The linked blog showing the example: spl_autoload_register(array("Foo\tBar", "loader")); highlights the fact that this is an epic blunder that will fracture the community.

The language designers who spent only "hours" debating the solution need to swallow their pride and admit they made a mistake. Then they should take public comments on how to solve the problem, and put it to a popular vote among the user community.

yuck (1)

ColoBikerDude (947706) | more than 5 years ago | (#25519165)

Stupid choice. I guess I will just endeavor to avoid namespaces altogether.

Does this mean that writing "eval" statements in regular expressions would have to be triple-escaped then?

preg_replace("/oldtext/e", "ns\\\pick_new_text()");

That makes my head hurt.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>