Why is D unpopular

Ali Çehreli acehreli at yahoo.com
Mon Jun 13 17:08:55 UTC 2022


On 6/12/22 03:40, Max Samukha wrote:
 > On Sunday, 12 June 2022 at 09:54:42 UTC, Ola Fosheim Grøstad wrote:
 >
 >>
 >> Many OO languages don't provide encapsulation, like Python.
 >
 > Right, but Python programmers are expected to prepend private members
 > with '_'.
 >
 >> I would say encapsulation has more to do with scaling up and evolving,
 >> as well as reliability (e.g. actors).
 >> But I guess you can say that OO features span a space where
 >> encapsulation is one dimension.
 >
 > Then it is natural to expect the feature would apply to the class level
 > (if we are talking about class-based OOP)? Really, I'm yet to meet a D
 > user that wouldn't be surprised 'private' is module-level.

I was surprised too. Then I realized D's view was better that C++'s (my 
frame of reference at the time). Then I realized I've been under the 
influence of C++'s view of OOP. Then I thought more about what 
encapsulation actually means. Then I realized encapsulation has nothing 
to do with access control. I am much happier with this repaired frame of 
reference.

 > And the
 > 'friend' story rarely impresses them. The reply is always: "Ok, 'friend'
 > breaks OOP principles. Is D better because it breaks OOP in its own way?"

Access control is just an aspect of OOP. Neither friend nor module-level 
private breaks OOP. Being a simpleton, I start reading from Wikipedia 
but others can read their trusted OOP gospel to gather the same information:

   https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)

For example:

   "Under the definition that encapsulation "can be used to hide data 
members and member functions", the internal representation of an object 
is generally hidden from view outside of the object's definition."

Note "can be used to hide" and "generally hidden". See, all the other 
languages apply their view of 'private', not OOP's view of 'private'.

I find D's 'private' very useful and I doubt a single project had any 
problem with it.

Ali



More information about the Digitalmars-d mailing list