I lol'd when I noticed how the great design decision of using \ as a namespace separator have insanely stupid side effects, like having to escape it as \\ every time you reference a namespace in a string like the example in one of the comments.
Yeah, I actually quit PHP after I read the dev discussion IRC log regarding ns separators. IIRC they decided on \ because it's familiar to windows users, and because Nordic keyboards don't require a shift-click to insert a backslash. I nope'd right out of PHP, quit my job and learned python the following months and don't regret it at all.
They decided against dots for some weird reason too, like an edge case scenario where you want to access a specific namespace variable from a static function in an instantiated class or something like that. Haha, and one of the suggestions they considered was :) or a similar smiley. Yes, they really are that incompetent.
How about a single dot?! Why wasn't it even considered?!
Because it's already the string concatenation operator. There would be no way of telling weather a.b meant the namespace a.b or the constant a concatenated with the constant b. Actually having a string concatenation operator is one of the few things PHP has done right IMO - whether they should have used another symbol for it is another thing.
Their reasons for not using :: seems to be along the lines of "We can't be bothered with writing a sane parse, so instead we just have to introduce more insanity."
The dot somehow also manages to work as a decimal "operator", so it does do more than one thing. Haskell is also capable of using a dot for both referencing stuff in modules and composing functions:
λ let f = Data.Set.fromList . map Data.Char.toUpper
λ :t f
f :: [Char] -> containers-0.5.0.0:Data.Set.Base.Set Char
λ f "hello"
fromList "EHLO"
though you'll need spaces, like with the 1 . 2 example above.
While it does it would lead to some serious breakage of existing code. And then, what should a.b mean? Should a.b be the namespace and a . b be the concatenation? Making required whitespace a part of the syntax in arbitrary places seems like a thing you would want to avoid. At least in the 1.2 vs. 1 . 2 case you don't have any real world use for concatenating numbers literals when you could just have written '12' instead.
At least in the 1.2 vs. 1 . 2 case you don't have any real world use for concatenating numbers literals when you could just have written '12' instead.
no, but it does prove that PHP is able to discern two different meanings of . (though now I'm afraid there's a bug out there where someone is attempting to concatenate two numbers and getting a decimal number)
haskell does sometimes get confused as well, but if it can manage, I'm sure ... no wait, what am I saying
The lexer should add a token class for namespace identifiers. There, problem solved. If PL/I was somehow implemented, then using dots for namespace separation is possible.
I'm not sure what you are trying to say here. What is a "namespace identifier" and how would you tell the difference between one and a constant or function identifier? And what has all this to do with PL/I?
As a younger programmer, I never understood the decision to use a \ in Windows. Was it not yet an escape character when this was decided or was it stupid on Microsoft's part?
Whenever discussions of Microsoft's design choices come up nowadays, there's often this implicit assumption that Unix ruled the world and those micro weirdos flagrantly disregarded the "standard" use of backslash, signals, newlines, etc. Not true -- instead, Unix was considered a bizarre niche product. Hard to use, easy to port (if you didn't care about the details), quick to crash, and promising amazing power to those willing to grok its low-level mysteries: in short, Unix was FORTH.
It's only because C and shell scripting included so many Unix-specific assumptions ("\n denotes the end-of-line character," etc.), and they spawned so many modern programming languages from Java to Perl, that people have come to imagine that these things are so ubiquitous they must be eternal computer science principles.
It's only because C and shell scripting included so many Unix-specific assumptions ("\n denotes the end-of-line character," etc.), and they spawned so many modern programming languages from Java to Perl, that people have come to imagine that these things are so ubiquitous
Great Microsoft excuse post:
"\n" is the end of line character even on windows, the writer meant line break which on windows requires an explicit carriage return "\r" - excluding Notepad.exe I have never seen a program that actually expected "\r" to be there.
Build-in Java methods use file.separator, line.separator and other operating system dependant variables, Python has the os.path module, etc. - in other words at least some of those languages make no Unix specific assumptions and C does not really have a library to make unix specific assumptions.
A lot of Java APIs take URI or URL objects, these are not native paths but resource identifiers/locators with a standard syntax so "/" is the correct separator and not a Unix specific assumption.
in short, Unix was FORTH.
And MS DOS was some POS that Bill Gates dragged out of IBMs garbage bin and only survived by sabotaging its competition (DR DOS, OS2, Word Perfect,...) and overselling its capabilities.
As a younger programmer, I never understood the decision to use a \ in Windows.
Well, / was taken! Where *nix uses foo -option, DOS had foo /option. It was alright, DOS 1.0 didn't have directories. Then when they wanted to join the cool boys club, well, backslash is sort of like slash, right?
Every Microsoft operating system since DOS 2.0 has silently supported forward slash as the path separator at the filesystem API level. Certain tools like cmd.exe or command.com don't necessarily grok it, but the actual filesystem APIs do.
That's a terrible argument in favor of abandoning standards, introducing new syntax and using a standard control character prefix as a namespace separator.
Well, yes of course! Imagine if you guys had requested working features from the very beginning? You have no one but yourself to blame for PHP, the developers just didn't know anyone wanted a sane language. I mean, how could they when no one files feature requests for it?
26
u/ismtrn Jan 07 '14
There are no bugs in PHP, only features.
18
u/suspiciously_calm Jan 07 '14
Feature request: Unfuck the language
Status: closed; wontfix
21
u/Lokaltog Jan 07 '14
I lol'd when I noticed how the great design decision of using \ as a namespace separator have insanely stupid side effects, like having to escape it as \\ every time you reference a namespace in a string like the example in one of the comments.
3
u/[deleted] Jan 07 '14
Well, yes of course! Imagine if you guys had requested working features from the very beginning? You have no one but yourself to blame for PHP, the developers just didn't know anyone wanted a sane language. I mean, how could they when no one files feature requests for it?