Women in Technology

Hear us Roar



Article:
  Why PHP 5 Rocks!
Subject:   some questions
Date:   2004-07-18 03:19:08
From:   riffraff
I never found this in php5 presentations:
- are classes objects ?
- are classes locked or open (like ruby,smalltalk)?
- can you define your own metaclasses or
- can you control the allocation+initialization of an object (like python,ruby,smalltalk) or just init like java?
- can you do mixin programming in php5 ?


- how good is the performance of runtime class checking of arguments to methods?
- there are nifty tricks to make it faster than an attribute lookup at any call?

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • some questions
    2004-08-16 13:15:05  GassertH [View]

    I'm no expert of Ruby or Smalltalk, but I'll try to answer. I think the PHP5 developers thought much more of Java (Sun is becoming an important PHP player..) than of these other languages. Let's not judge that for the moment ,)
    PHP, and let's state that clearly, is not an object-oriented language _only_. The majority of its user base most probably does not use OOP. The new OO-features are a step forwards, but certainly a pragmatic user-focused one. Do not look for "highbrow" OO-theoretic stuff in PHP. Consequence: I could directly write a big NO as an overall answer here :)

    # - are classes objects ?
    There is no class "class", if you mean that. But with the new Reflection API and by the means of "$o = new $someClassName();" you should be able to do most of the things you could do with the class "class" in Java.
    I think you could say there are no metaclasses.

    # are classes locked or open (like ruby,smalltalk)?
    I guess they're locked, I do no know of a way to alter a loaded class. Not sure if I understand the question, though.

    # can you define your own metaclasses or
    No metaclasses, I still think

    # can you control the allocation+initialization of an object?
    no. no object-oriented/-aware way to deal with things like memory usage and time consumption.

    # can you do mixin programming in php5 ?
    there's only "ordinary" inheritance.

    # how good is the performance of runtime class checking of arguments to methods?
    define "good" while I do a little benchmarking :)

    # there are nifty tricks to make it faster than an attribute lookup at any call?
    I did not understand this question? What do you refer to by "it"?

    • some questions
      2004-08-22 08:24:46  GassertH [View]

      Perhaps http://pecl.php.net/package/classkit should be mentioned here. It's an extension that allows you to add, remove, rename, and redefine class methods at runtime.