Why is D unpopular?

forkit forkit at gmail.com
Sat Jun 11 01:14:16 UTC 2022


On Saturday, 11 June 2022 at 01:00:44 UTC, H. S. Teoh wrote:
>
> ..
> You know how ridiculous that sounds, right? -- when you 
> rephrase that in terms of a different unit of encapsulation.  
> "I want to protect my function's per-object state from mutation 
> by other functions in the class.  My function will decide when 
> to mutate, and when not to mutate. My class should not force 
> mutation on me."  Or, "I want to protect my local variables 
> from mutation by other blocks in the function. My block will 
> decide when to mutate, and when not to mutate.  My function 
> body shold not force mutation on me."
>
> One can argue that functions in a class ought to work together 
> on that class's data; one could argue the same for functions 
> (and other code) in a module. Or blocks in a function.  It's 
> essentially the same argument at the core; the only difference 
> is the unit of encapsulation.

Any argument taken to the extreme, will certainly sound 
ridiculour - as you've demonstrated.


>
> As I said, opinions differ on this.  You say the class ought to 
> be unit of encapsulation, Walter says it should be the module. 
> Maybe next week I should write a DIP arguing for the block to 
> be the unit of encapsulation instead.  Each side of the 
> argument has its merits and demerits; the choice is essentially 
> arbitrary, based on what the language designer deems more 
> important or not, in balancing the tradeoffs in the language.
>
> There are bigger fish to fry in the pond of programming 
> language design.
>
>
> T

In OOP, opinions do not differ on the level of encapsulation. It 
is the class.

I'm happy to be corrected here, if I'm wrong.

It's why it's called OOP, not MOP.

My only disagreement is where a language offering OOP, goes and 
puts this principle aside.

It's not a disagreement in the module being an abstraction that 
provides a barrier around it. It's that the module swallows up 
the barrier of the class.

Therefore, is you use classes in D, the very principle of OOP has 
been 'mutated'.

In my case, I'm protecting this principle, it's private, and I 
mean really private, and the outside world is not going to mutate 
it   .. I even have barriers in memory to prevent that from 
happening. So no amount of hacking will circumvent that barrier 
;-)   .. but I'm sure many will keep trying.



More information about the Digitalmars-d mailing list