Ambush Commander wrote:Sounds like you want to use Java.
Actually, no. I love PHP. I just think that namespaces make sense and keep things organized. I'm not a fan of many things in Java. Here's some things I dislike very much about Java:
* Strict typing. How many of you tried Java and left it because this drove you crazy? This especially comes into play when using the Swing API, for instance. So you find that widget you need, and want to feed it some data, but then you find it only requires a certain type of data type. Fine, so how do you get that data type? You may have to jump through two or three more functions with that data just to coerce the right kind of data type to feed to the API you found in the first place. That's aggravating and slows things way, way down.
* The community. It's filled with OOP academic types who don't want to get anything done and would rather sit in meetings way, way too long, perhaps for as long as a month, working out the purity of their design pattern and APIs before they even right a lick of code. Sounds nice and all, but managers want results. With PHP, I can have my OOP with a couple morning coffees, be done with it, and move on.
* The MVC model. This is very convoluted. You'll see what I mean when you try to write a Java Swing project that collects a query on a form, hits the database, and tries to print nice reports. The MVC model to me, when I did that, was very strange. I couldn't think in this mode. It was like trying to put a large square peg in a small round hole. I thought if I had done it in VB or C#, I would have been done by then. That's before I discovered PHP.
* Having to compile. I hated having to compile, and the compiler was very picky where all the files were. Making jars was an aggravating process for me when I just wanted to make code changes and be done with it. With PHP, I had none of these problems.
* Everything is an object. This made reading the code confusing and also slowed things down. It's hard to believe that Java slightly beats PHP in some kinds of time tests, although that's what I think I see now. I don't know how they do it because for awhile there, PHP was faster. I just can't fathom how the "everything is an object" philosophy in language design can speed up the language.
* funkyVariableNames. Pleeeze. That's just silly and illogical. Instead of what the Java purists wanted, I like to stick with variable names like:
$nNumber
$sString
$dDate
$bBoolean
$cChar
$oObject
$hHandle
$asArrayOfString
$anArrayOfNumber
$xsByRefString (returns an updated value -- x means "xfer" or "transfer")
...And I like my function names like GetAnswer().
I'm "old school". Sorry.
* Missing libraries. I sure do have trouble in PHP when I try to run something but I'm missing a library, but it happens a heck of a lot more in Java. This was also the case of some really crazy sounding errors.
* Deprecated APIs. I got sick of writing my Java projects for 6 months, only to find it reviewed by peers saying, "Um, dude, you can't use foo() -- it's been deprecated (or is planned to be deprecated next year)." PHP has far, far less of this.
* APIs not working on certain versions of Java. Unlike PHP, where there's really only one good engine out there, Java has splintered into many versions. I got sick of sending my code to someone and then they said, "I can't run your stuff on my version of Java." And it was either the version or the vendor of Java that was the culprit. Augh!!!
So, let's get this out of the way, I adore PHP. I just think that every once in a millennium, some language designer introduces a feature that even old schoolers like me think is cool, and namespaces is one of them.
I've been doing some reading on the web, and it looks like the only discussions going on right now are to use a namespace you can implement easily in PHP4, 5, 6, and beyond. It just uses static methods and properties to simulate it. If you're careful and use a "property bag" concept in your static methods, you can create something similar to how namespace objects work. It looks sort of like:
$sResult = XML::Document::Parse(blah blah blah);
and
$sResult = Server::Property('HTTP_REFERER');
And then it's up to Zend and/or the top level community guys to create a set of libraries that use this new namespace system, and which introduce GCC C/C++ PHP extension modules to carry out the tasks.
However, this could suffer a speed hit. The faster technique, in my opinion, would be to permit normal namespace separators like "." and require that strings be concatenated with <space>.<space>. That way, the interpreter could still run fast even though "." is used as a namespace separator for something like:
$sResult = XML.Document.Parse(blah blah blah);
and
$sResult = Server.Property('HTTP_REFERER');