February 06, 2023
On Monday, 6 February 2023 at 08:26:45 UTC, Ali Çehreli wrote:
>
> ....
> In contrast, D delivers some features in an unprincipled way and the programmers use combinations of those features the way the see fit.

I agree, that D is unprincipled in many ways, and this is perhaps the biggest surprise for new comers from other 'principled' programming languages.

But is that a design goal for D?

> I really don't care if D had 'static class' to be used only as a namespace but I don't see how this issue is terrible....

If you've ever programmed in C#, you've use static classes, and you've used them many times, and you'll continue to use them.

If D implemented the same abstraction as easily as C#, then C# programmers would find it easier to migrate code to D, perhaps. That's not a request, just an observation. And no, I'm not going to 'go write a DIP'.

Of course, if I was talking about migrating C code, you'd all be stumbling over yourselves to make that happen - .. build it, and they still won't come ;-)

February 07, 2023
On 07/02/2023 9:56 AM, ProtectAndHide wrote:
> On Monday, 6 February 2023 at 08:26:45 UTC, Ali Çehreli wrote:
>>
>> ....
>> In contrast, D delivers some features in an unprincipled way and the programmers use combinations of those features the way the see fit.
> 
> I agree, that D is unprincipled in many ways, and this is perhaps the biggest surprise for new comers from other 'principled' programming languages.
> 
> But is that a design goal for D?

Yes. Not all problems are best solved the same way as another.

Use what is best for you & your problem domain, not what somebody is selling as the next big thing.
February 06, 2023
On 2/6/23 12:56, ProtectAndHide wrote:

> I'm not going to 'go write a
> DIP'.

Nobody will write a DIP about it because very few people ever mentioned this issue over the years.

And as 'static class' and 'static struct' are already usable in D, a newcomer would definitely be confused with your "terrible" conclusion.

Ali

February 07, 2023
On Monday, 6 February 2023 at 21:46:29 UTC, Ali Çehreli wrote:
> On 2/6/23 12:56, ProtectAndHide wrote:
>
> > I'm not going to 'go write a
> > DIP'.
>
> Nobody will write a DIP about it because very few people ever mentioned this issue over the years.
>
> And as 'static class' and 'static struct' are already usable in D, a newcomer would definitely be confused with your "terrible" conclusion.
>
> Ali

You being a little agressive don't you think?

My observation is very reasonable, and correct, and a new comer to D would do well to know that:

The compiler will allow you to do all these things, even if you've @disable'd' the constructor, and have only static members:

- the compiler will allow you to declare a variable of that type
- the compiler will allow you to declare an array with elements of that type
- the compiler will allow you to use that type as a type argument
- the compiler will allow you to use that type as a parameter
- the compiler will allow you to use that type as a return type

I can see no reason why anyone would want to do these things, in this context.

Nor can I see any reason, whatsoever, why the compiler would allow you to do these things, in this context.

It's not about me trying to remove power from the programmer. That's a nonsense argument, without any basis, whatsoever. It's just a (correct) observation.

Further comments that try to derail this will be ignored.
February 07, 2023
On Monday, 6 February 2023 at 21:02:13 UTC, Richard (Rikki) Andrew Cattermole wrote:
> On 07/02/2023 9:56 AM, ProtectAndHide wrote:
>> On Monday, 6 February 2023 at 08:26:45 UTC, Ali Çehreli wrote:
>>>
>>> ....
>>> In contrast, D delivers some features in an unprincipled way and the programmers use combinations of those features the way the see fit.
>> 
>> I agree, that D is unprincipled in many ways, and this is perhaps the biggest surprise for new comers from other 'principled' programming languages.
>> 
>> But is that a design goal for D?
>
> Yes. Not all problems are best solved the same way as another.
>
> Use what is best for you & your problem domain, not what somebody is selling as the next big thing.

Well I don't agree that D should boast about things that's its implemented in an unprincipled way. I find that a strange form of marketing in todays world.

To the extent those unprincipled implementations allow you to do things that you do actually want to do, then fine.. maybe. But an unprincipled implementation of something that just allows you do make mistakes, then it should be looked at further, so see if it can be improved.

February 07, 2023
On 2/6/23 23:45, ProtectAndHide wrote:

> Well I don't agree that D should boast about things that's its
> implemented in an unprincipled way.

Here, "unprincipled"[1] is just a descriptive word meaning that D does not insist on certain software engineering methodologies e.g. unlike Java where "everything is a class" or unlike some functional programming languages where "everything must be immutable".[2]

> an unprincipled
> implementation of something that just allows you do make mistakes, then
> it should be looked at further, so see if it can be improved.

Agreed. But the lack of 'static class' in D or its approximations are not in that category. I can imagine someone coming up ingeniously with a harmful way of using 'static class' but unless that is a real problem that affects D users then there is no issue.

Ali

[1] I remember reading or hearing "unprincipled" from Andrei Alexandrescu long time ago.

[2] Actually, const and immutable being transitive can be seen as counter examples of D having a strong point on something. I think this "turtles all the way down" is not agreed by many users.

February 07, 2023
On 2/6/23 23:33, ProtectAndHide wrote:
> On Monday, 6 February 2023 at 21:46:29 UTC, Ali Çehreli wrote:

>> And as 'static class' and 'static struct' are already usable in D, a
>> newcomer would definitely be confused with your "terrible" conclusion.

> You being a little agressive don't you think?

I see how wrong that came out. Apologies! What I meant was "your conclusion [about something here being] terrible".

> My observation is very reasonable, and correct,

Agreed.

> The compiler will allow you to do all these things

Agreed.

> I can see no reason why anyone would want to do these things, in this
> context.

Agreed.

> Nor can I see any reason, whatsoever, why the compiler would allow you
> to do these things, in this context.

My understanding is that these are side-effects of trying to have orthogonal features. Some combinations don't make sense.

Having said that, since D does not use 'static class' for namespacing, should it go out of its way to implement logic to ban that combination at module scope? Perhaps. People have been discovering meaningless combinations of attributes in D all the time. (I forgot why that is so.)

If D disallowed 'static' at module scope, we wouldn't be having this discussion anyway. If that happened, then 'class' would be accepted for being used for creating objects.

Ali

February 07, 2023
On Tuesday, 7 February 2023 at 16:16:48 UTC, Ali Çehreli wrote:
> On 2/6/23 23:33, ProtectAndHide wrote:
> > On Monday, 6 February 2023 at 21:46:29 UTC, Ali Çehreli wrote:
>
> >> And as 'static class' and 'static struct' are already usable
> in D, a
> >> newcomer would definitely be confused with your "terrible"
> conclusion.
>
> > You being a little agressive don't you think?
>
> I see how wrong that came out. Apologies! What I meant was "your conclusion [about something here being] terrible".
>
> > My observation is very reasonable, and correct,
>
> Agreed.
>
> > The compiler will allow you to do all these things
>
> Agreed.
>
> > I can see no reason why anyone would want to do these things,
> in this
> > context.
>
> Agreed.
>
> > Nor can I see any reason, whatsoever, why the compiler would
> allow you
> > to do these things, in this context.
>
> My understanding is that these are side-effects of trying to have orthogonal features. Some combinations don't make sense.
>
> Having said that, since D does not use 'static class' for namespacing, should it go out of its way to implement logic to ban that combination at module scope? Perhaps. People have been discovering meaningless combinations of attributes in D all the time. (I forgot why that is so.)
>
> If D disallowed 'static' at module scope, we wouldn't be having this discussion anyway. If that happened, then 'class' would be accepted for being used for creating objects.
>
> Ali

Well, in C++ I can just mark the destructor as = delete;

The compiler now won't let me do those things that D would allow.

D could do something similar I guess, with: @disable ~this();

In fact, a static class is a very useful abstraction.

C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-)

When a compiler allows nonsense code, my confidence in it begins to wane...


February 08, 2023
> C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-)

Java as well.

February 08, 2023
On Wednesday, 8 February 2023 at 09:00:40 UTC, thebluepandabear wrote:
>> C# just makes it 'easy' for the programmer to define it as such, without all the nonsense other languages require. In addition, the C# compiler WILL prevent nonsense code, which is exactly what I want from a compiler ;-)
>
> Java as well.

Wait nvm