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?”

  1. Antony Dovgal on December 2nd, 2007 7:24 pm
    Gravatar

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

  2. Matthew Weier O'Phinney on December 2nd, 2007 7:44 pm
    Gravatar

    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.

  3. PHPDeveloper.org on December 3rd, 2007 2:14 pm
    Gravatar

    PHP Addiction Blog: PHP - No Container libraries?…

    On the PHP Addiction blog today, there's a new post where ……

  4. Jon Gilkison on December 3rd, 2007 7:20 pm
    Gravatar

    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.

  5. Donald Organ on December 3rd, 2007 8:18 pm
    Gravatar

    PHP is not a compiled language…..its a script language.

  6. Jon Gilkison on December 3rd, 2007 8:23 pm
    Gravatar

    That's what I said, Donald.

  7. Doug Hill on December 3rd, 2007 8:31 pm
    Gravatar

    Jon:
    Yeah, I'm aware of that :) "Program into your language not in it." — Steve McConnell. I was more curious than anything.

    Donald:
    Uh huh, I said that "compiled" languages that I've used had container libraries… not that PHP was a compiled language.

    Doug

  8. Donald Organ on December 3rd, 2007 9:08 pm
    Gravatar

    Then why are you compairing PHP to a compiled language, or why do you want it to?

  9. Doug Hill on December 3rd, 2007 9:51 pm
    Gravatar

    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!

  10. Adam on January 9th, 2008 2:05 pm
    Gravatar

    Very nice! Kudos for the post.

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>