PHP - No Container libraries?
Most compiled languages that I have used have some kind of container implementation, Lists, Maps, Trees, Stacks and all their many variations. PHP has arrays and the SPL.
This post is more of a question than anything else, are there disadvantages that I can't see to having a standard container library for PHP? One problem that I can see is that containers built in user code will definitely be slower than a native implementation.
Am I overlooking something that already exists? Google fails me!
Comments
10 Responses to “PHP - No Container libraries?”
Leave a Reply
AFAIK Etienne (http://www.colder.ch) is already working on reincarnation of PECL/adt (see http://cvs.php.net/viewvc.cgi/pecl/adt/), which is to be included into SPL.
I don't know what are his plans or estimations, feel free to contact him (and give a hand).
While not exactly what you may be looking for, SPL's ArrayObject offers many features that allow you to work with lists, maps, and stacks easily in an OOP fashion as well as in an array-like fashion.
PHP Addiction Blog: PHP - No Container libraries?…
On the PHP Addiction blog today, there's a new post where ……
I don't mean to sound blunt, but PHP isn't Java, so the need for such an extensive list of containers speaks of a misunderstanding of the best way of doing things in PHP. In PHP you are servicing a request, unlike Java where you have a stateful app server sitting there, pre-compiled and ready to rock and roll. Despite all the layers of abstraction that frameworks want to put on top of it, PHP's most basic purpose is servicing a single request and I'm of the fundamental belief that your code should echo that, meaning it should be fit and trim and very narrowly focused in its purpose - if that makes sense.
The array in PHP is a map, despite its name, and you can treat it like a stack with array_pop/push/etc. Trees can be emulated with recursive population of the array.
PHP is not a compiled language…..its a script language.
That's what I said, Donald.
Jon:
"Program into your language not in it." — Steve McConnell. I was more curious than anything.
Yeah, I'm aware of that
Donald:
Uh huh, I said that "compiled" languages that I've used had container libraries… not that PHP was a compiled language.
Doug
Then why are you compairing PHP to a compiled language, or why do you want it to?
I'm not comparing them, I was curious if any existed, when I searched I didn't find any, PECL/adt was pointed out to me in one of the comments here.
I can see some disadvantages, in user code it would be bloat. In a native extension it might be nice, who knows, I was just wondering what was out there.
Thanks everybody for the input. I was looking for opinions and found strong ones!
Very nice! Kudos for the post.