D - more power than (really) needed !
Don Clugston
dac at nospam.com.au
Fri Mar 10 02:12:58 PST 2006
Hasan Aljudy wrote:
> Walter Bright wrote:
>> "Craig Black" <cblack at ara.com> wrote in message
>> news:dun68p$30kv$1 at digitaldaemon.com...
>>
>>> A lot of the bias towards OOP purism comes from Java vs. C++
>>> comparisons, much more convincing than Anything vs. D. Hopefully the
>>> simplicity and power of D can help to eliminate OOP purism.
>>
>>
>> The trouble with OOP is, well, not everything is an object. For
>> example, take the trig function sin(x). It's not an object. Of course,
>> we could bash it into being an object, but that doesn't accomplish
>> anything but obfuscation.
>
> That's because we've been taught math in a procedural way ;)
Not at all. It's based on functions. Ever heard of functional
programming languages? <g>
> Ideally, x, the angle, would be an object, and sin is a method on that
> object.
???? How about the derivative function? It operates on functions.
Consider something as simple as "+".
real a;
ireal b;
creal c = a + b + a;
Should "+" be a member of a, b, or c?
> Like you said, it'll be a bit confusing if it was an object, but that's
> not because it can't be an object, but mainly because that's not how we
> think about it.
No, it's because the only way that pure OOP can make sense is when
EVERYTHING is an object. In particular, functions must be objects.
(And then 'object' is a poor word to use).
OO has some great ideas. But overuse of OOP is a disaster. It's
unbelievably difficult to write good OO code on a large scale.
More information about the Digitalmars-d
mailing list