Sealed classes - would you want them in D?
dlang user
dlang.user at gmx.com
Wed May 16 05:36:44 UTC 2018
On 05/15/2018 04:05 PM, Jonathan M Davis wrote:
> On Tuesday, May 15, 2018 12:21:23 Dlang User via Digitalmars-d wrote:
>> On 5/15/2018 10:17 AM, aliak wrote:
>>> On Tuesday, 15 May 2018 at 13:16:55 UTC, 12345swordy wrote:
>>>> The way you use the word "leak" make is sounds that this is
>>>> unintentional, while in reality it is intentional by design. That why
>>>> reading the specification is important!
>>>>
>>>> Alexander
>>>
>>> Ya I guess you be right - but a leak is what it is to people who expect
>>> private to mean private. Which is not a small number of people ;)
>>>
>>> And while I agree reading a spec is important. Language specs are not
>>> known for being trivial to go through and it's not really something you
>>> read but more of something you refer to, and that also probably for more
>>> advanced developers. This is not something you can expect newcomers or
>>> even intermediate level devs to go through. And the less you need to
>>> refer to a spec the better (i.e. more intuitive) a language is.
>>
>> I concur with that. When I first started learning D (coming from a C#
>> background), I figured that I already knew all of the OOP stuff and
>> didn't dig too deeply into it, figuring that it worked pretty close to
>> the same as C#. It did catch me off guard when I first realized how it
>> really worked in D. But the work around (putting it in its own module),
>> seemed pretty trivial and is what I typically do in C# anyways, so it
>> didn't bother me too much.
>
> I think that if there's an actual problem here, it's the fact that how
> private works in D is surprising to folks coming from languages like C++,
> C#, or Java. IMHO, D's approach works extremely well, but if you don't
> understand what it is, you risk problems, just like with any other feature
> that you don't understand properly. And to better deal with that, we
> probably need more in the way of documentation geared towards teaching
> newbies. The "spec" is pretty poor in that it's not precise enough to be a
> spec, meaning that it doesn't really do its job in that respect, but it's
> also not really written with the idea that it's teaching someone, so it
> doesn't do a great job teaching the language either. There's a lot of great
> information there, but it's ultimately not all that accessible for many
> folks.
>
> Though if someone expects to be able to just jump into any language and use
> it without reading up on how it works, they're just shooting themselves in
> the foot. And surprisingly often, that seems to be how many folks operate.
>
> Ultimately, if newcomers don't want to be tripped up on stuff like this,
> their best bet is probably to read books like Andrei's "The D Programming
> Language" and Ali's "Programming in D."
>
> https://wiki.dlang.org/Books
>
> - Jonathan M Davis
>
To clarify myself a little bit, the main points that I was agreeing with
were:
1. I think there are significant number of people coming from other
languages that are going to get tripped up by D's module level
encapsulation, mainly because it happened to me.
2. The spec is hard to use as a training resource, because I tried to
use it and didn't have a good experience with it.
I ended up reading all of the free material that I could find (including
the Programming in D book).
I also wasn't trying say anything about D's encapsulation being right or
wrong, just that it tripped me up initially, and that now that I know
how it works, it isn't a big deal for me.
More information about the Digitalmars-d
mailing list