Re: [PHP] Are PHP5 features worth it?



On Tue, 2006-12-19 at 19:05 +0100, Niels wrote:
Hi list,

I'm writing a PHP program and I've got a number of concerns. The program is
about 20 KLOC at the moment, but will probably grow quite a lot.

I'm using OOP throughout, and I don't really have a lot of problems with
what PHP4 can do with OOP. PHP5 does have a nice feature or two, eventhough
none seems essential to my particular style of programming. I don't mind
using what PHP5 offers where it makes sense, but where's that? Exceptions
and new OOP features?

Exceptions: I just don't see the big advantage. I've got errors and messages
bubbling up through object layers as it is, and exchanging that with a
wholly new structure seems more trouble that it's worth. I've read several
books on how cool PHP5 is, but the arguments for using exceptions seem to
boil down to "Java has them". Nowhere have I seen good examples that really
show how well exceptions solve real problems, all examples seem to show are
that 5 lines of try/catch are somehow sexier than 5 lines of if/else. What
about performance?

New OOP features: I can go through my code and mark all my methods as public
or private or whatever. No problem. But why would I? It will make classes
easier to understand when I look at them, but that's just convenience. What
are the performance benefits? I've not found a single mention of that
anywhere. What do abstractions and interfaces actually do, aside from
structuring my code better?

What major compelling reasons do I have to start using exceptions and OOP-5?

There's only one compelling reason IMHO... objects are assigned to
variables by reference instead of by copy. Other than that, as you have
noted, pretty much everything else is bells and whistles of limited use
to a savvy programmer who doesn't give a rat's ass about java style OOP.
IMHO, stick with PHP4 style coding and adjust the things that are
incompatible with PHP5. Then you're code can work in either. PHP5 uptake
has not been particularly breathtaking and the majority of PHP
developers are still using PHP4 because it works well enough without the
headaches. PHP6 on the other hand, will probably be well worth the
switch.

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
.



Relevant Pages

  • Re: [PHP] Are PHP5 features worth it?
    ... I specifically upgraded my server to PHP 5 to make use of SimpleXML. ... Forget about OOP and exceptions. ... Are PHP5 features worth it? ...
    (php.general)
  • Re: [PHP] PHP4 vs PHP5 Performance?
    ... in PHP4 that was then duplicated b internal code in PHP5. ... PHP4 AND PHP5 developers don't even use OOP. ... What does PHP 5 offer? ... No you don't have to use them, but they are a useful tool. ...
    (php.general)
  • Re: [PHP] PHP4 vs PHP5 Performance?
    ... in PHP4 that was then duplicated b internal code in PHP5. ... PHP4 AND PHP5 developers don't even use OOP. ... in a pre-existing PHP encoded database abstraction layer. ...
    (php.general)
  • Re: [PHP] PHP4 vs PHP5 Performance?
    ... Ooooooooooooooh, the magical "Real OOP". ... PHP4 is as real OOP as any other OOP. ... There's only a narrow sliver of use cases where I'd say PHP 4's primitive SAX ... Otherwise default to PHP5 C implementations. ...
    (php.general)
  • Re: [PHP] Are PHP5 features worth it?
    ... what PHP4 can do with OOP. ... Exceptions: I just don't see the big advantage. ... easier to understand when I look at them, but that's just convenience. ... Someone else mentioned that PHP 5 is much less inclined to copy objects. ...
    (php.general)