[development] Time for a new chapter of an endless debate

Larry Garfield larry at garfieldtech.com
Sun Jul 2 18:41:42 UTC 2006


I would have to say -1.

1) Ease of development.  Objects have a shorter syntax than arrays do; half as 
many funky control characters.  (-> vs. [' ']).  That's half as many 
opportunities for typos.  

2) Classes.  Some contrib modules, e.g., Views, do use not only objects but 
classes.  Those cannot be made into arrays with a simple regex.

3) Semantic consistency.  An array is a list, or a multi-dimensional data 
structure.  That's how we use it.  An object is a complex entity "thing".  
That's how we use it.  They are semantically different things, each with 
their own meaning and purpose.

4) Speed.  Under PHP 4, arrays and objects are internally nearly identical and 
I believe there's no appreciable speed difference at all.  Under PHP 5, 
objects have been rewritten and redesigned to be faster.  Thinking for the 
future (and those many people that use PHP 5 already), there is a performance 
question to consider given the different engine.  (I have not benchmarked the 
difference extensively, but it is something that should be considered.)

On Sunday 02 July 2006 10:04, Karoly Negyesi wrote:
> Hi,
>
> Drupal uses objects. Reasons are probably lost by now in the ancient past.
>
> PHP is still not the best. I can write:
>
> somefunction(array('this' => 'that'))
>
> while there is no similar construct for objects.
>
> Also we use arrays for links, menus, links and soon mails.
>
> So, I propose removal of objects on practical grounds: shorter notation
> and a very little memory gain.
>
> If you have an opinion please share but I think we are only furthered by
> _practical_ viewpoints. No theory can make Drupal faster or lower its
> memory usage.
>
> The change looks big but it's not, it's scriptable and I can whip up such
> a script in a very short time.
>
> Regards
>
> NK
>
> Ps. Readability issues? I do not think there is any difference.

-- 
Larry Garfield			AIM: LOLG42
larry at garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson


More information about the development mailing list