Re: Object Oriented PHP vs Java

From: Bruno Desthuilliers (bdesth.quelquechose_at_free.quelquepart.fr)
Date: 01/22/04


Date: Thu, 22 Jan 2004 12:45:27 +0100

Agelmar wrote:
> Bruno Desthuilliers wrote:
>
>>Savut wrote:
>>
>>>"Jerry" <weinstei@nova.edu> wrote in message
>>>news:69fca47c.0401211031.539ef63f@posting.google.com...
>>>
>>>
>>>>What are the advantages and disadvantages of using Object Oriented
>>>>PHP vs Java?
>>>
>>> >> PHP is not fully OO, even the PHP5... but Java is OO
>>>
>>As there is *no* commonly accepted definition of OO, I just dont
>>understand how you can claim such a thing.
>>
>>BTW, Smalltalkers could tell you why Java is not OO !-)
>
>
> Actually, there is a commonly accepted definition...
> OO implies:
> polymorphism, encapsulation, and inheritance.

Not so commonly accepted...
inheritence have two meanings :
- type/interface inheritence, which is about subtyping
- implementation inheritence, which is about code reuse

The first one doesn't make sens in a dynamically-typed language nor in
statically-typed-with-type-inference language (like OCaml). So it is
only useful for 'rigidly-typed' languages like Java and C++ - which BTW
are not 'pure' OOPLs (if this has any meaning) since they have
'non-object' types.

The second one is handy for code-reuse but can - and in many cases would
better - be replaced by composition/delegation.

Encapsulation largely predates OO and is of common use in procedural
(never wrote an ADT in C ?) and functional languages (ever heard of
closures ?).

Polymorphism is also independant of OO, and exists in procedural and/or
functional languages too.

So much for your 'commonly accepted definition', which doesnt define
anything IMHO : I just can't see how anyone could connect this with the
concept of objects that did not ever mentionned.

But dont take it wrong, I agree that these 3 concepts are commonly used
in OO and do have a meaning in a somewhat wider perspective.

What strikes me is that you missed the 2 real key points : objects, and
message passing with dynamic dispatch. OO is mostly and primarily about
things that we call 'objects' that have state and send messages to each
others. How some particular object react to a message depends on its
particular behavior and state.

And now this brings back the notions of encapsulation (each object carry
it's own state) and polymorphism (two different object can accept the
same message, each one reacting in it's own way).

The concept of 'type' could then be defined by the LSP : two objects
that accepts the same messages are of the same type. And the notion of
class could be defined in an almost mathematic way : a class is the set
of objects that a/ are of the same type and b/ have the same behavior
(which usually implies having the same internal structure when it comes
to implementation).

Note that inheritance has no particular meaning wrt this definition, and
so is only a code reuse facility in a dynamically typed language and a
'necessary evil' (no flame please) to support dynamic dispatch of
messages (ie polymorphism) in rigidly-typed languages.

<disclaimer>
Please note also that I would never pretend this definition being the
One And Only Revealed Truth(tm) about OO !-)
<disclaimer/>

My 2 cents...
Bruno



Relevant Pages

  • Re: Static vs Dynamic
    ... The type system in SML has the notion of ``parametric polymorphism'' ... functions that operate on lists in general, ... polymorphism, and for ease of type inference. ... Other languages with similar goals include Objective CAML, ...
    (comp.lang.lisp)
  • Re: Unix and OO Avoidance
    ... >> polymorphism except polymorphism based upon ... You are right, RCM has used managing dependencies as his definition of OO, ... << are managed through dynamic polymorphism. ... << that I would not consider OO languages. ...
    (comp.object)
  • Re: Type regimes - terms and themes (Was: Naive, possibly silly question [LONG] )
    ... > Uncle Bob wrote: ... it's possible to achieve polymorphism without inheritance in ... statically-typed languages. ... - Method overloading dispatches statically in mainstream STLs. ...
    (comp.object)
  • Re: parser
    ... be more general than just being 'Common Lisp'... ... lots of brittle glue code and crap to marshall between the respective ... So you have only used languages that require you to write FFI code by ... Market share is a useful measure if you want to make money. ...
    (comp.programming)
  • Re: 98.6% DNA and Evolutionary Logic
    ... Humans are related to *all living things on Earth, ... stretches of DNA, charting a nested hierarchy. ... Some people believe that all languages are related by common ...
    (talk.origins)

Loading