January 12, 2024

On Thursday, 11 January 2024 at 23:41:56 UTC, deadalnix wrote:

>

On Thursday, 11 January 2024 at 18:38:37 UTC, max haughton wrote:

>

On Thursday, 11 January 2024 at 18:23:00 UTC, deadalnix wrote:

>

Yes. Who maintain these for each editor? Nobody because cost

>

benefits. And for as long as this is the case, the
ecosystem will shrink.

Its a protocol. You only need one; there is one https://github.com/Pure-D/serve-d

https://xkcd.com/927/

Which floating point standard does your computer use?

LSP is extremely widely implemented and supported by almost everything under the sun https://microsoft.github.io/language-server-protocol/implementors/servers/ - other than nano and notepad every text editor in use by more than 2 people that I can think of has it (which includes sublime)

January 12, 2024
On Thursday, 11 January 2024 at 23:44:02 UTC, deadalnix wrote:
> On Thursday, 11 January 2024 at 19:33:48 UTC, Walter Bright wrote:
>> On 1/11/2024 5:07 AM, deadalnix wrote:
>> > such as @nogc, has been a productivity disaster
>>
>> I don't really understand this. Just don't use @nogc?
>
> And don't use any library. Got it.

The thing with @nogc and ESPECIALLY betterC in a library context is that it adds more and more decisions everywhere - O(2^N)? And that's before all the attribute spam.
January 12, 2024

On Thursday, 11 January 2024 at 19:53:10 UTC, Walter Bright wrote:

>

In order to assign tasks, one needs to actually employ people, as I cannot assign anything to volunteers.

You don't need to hire anyone, you just need to carefully explain the structure of the 'dmd' code, and then list countless tasks. Similarly, break down the big tasks into small ones. Create a list that every user can see, and then create an incentive mechanism!

Break down big tasks into small ones, and then let users solve them one by one. The difficulties are handed over to management, and the details are handed over to ordinary users.

Encourage users to solve practical problems related to themselves and tell them where to solve them. Users are like writing plugins.

What the user needs is, where can I solve my small problem? If possible, the user can solve it themselves! It is very important for users to understand the compiler!

January 12, 2024

On Thursday, 11 January 2024 at 19:53:10 UTC, Walter Bright wrote:

>

(Some of our volunteers do do things that aren't much fun, but need to be worked on. Those are our most valued contributors.)

Now there is a discussion group on GitHub, which can be turned into a task list. Each discussion is a task.

What users need is a 'Q', so you can encourage them to establish a 'Q' discussion, and then interested users can organize their own discussions!

And, we should encourage discussion and merge features!

A very simple example is a user, like me, who really wants a C++ class level private. This' private 'can be achieved by adding a keyword, you only need to add one keyword, and then implement the corresponding function. Then, you get a bunch of potential C++ users. But D team refuse this pr , the user leaves. Originally, it could bring a bunch of its friends to enter D. In the end, D loses all and has nothing. There is no function, There are no D users.

January 12, 2024

On Friday, 12 January 2024 at 01:11:44 UTC, zjh wrote:

>

A very simple example is a user, like me, who really wants a C++ class level private.

Don't nitpick about user needs anymore, users are the most important part of the D ecosystem. Without users, D is useless.

January 11, 2024
On Fri, Jan 12, 2024 at 12:42:44AM +0000, max haughton via Digitalmars-d wrote:
> On Thursday, 11 January 2024 at 23:44:02 UTC, deadalnix wrote:
> > On Thursday, 11 January 2024 at 19:33:48 UTC, Walter Bright wrote:
> > > On 1/11/2024 5:07 AM, deadalnix wrote:
> > > > such as @nogc, has been a productivity disaster
> > > 
> > > I don't really understand this. Just don't use @nogc?
> > 
> > And don't use any library. Got it.
> 
> The thing with @nogc and ESPECIALLY betterC in a library context is that it adds more and more decisions everywhere - O(2^N)? And that's before all the attribute spam.

Exactly, it's causing D's already-small ecosystem to be fragmented even more.

Now instead of one library that works for all D code, you have libraries that use the GC so they're incompatible with betterC and @nogc projects, libraries that don't use GC but still use some D feature not in betterC, so the betterC people are left out, then you have @nogc libraries that the GC crowd wouldn't use because it requires you to pass allocators and all the rest of the spam associated with manual memory management.

The only way a library author can deal with this mess is (1) write in the most restricted language subset, i.e., betterC + @nogc, so that it's usable by everybody. But the GC crowd will be unlikely to use it, because it will lack the conveniences they're accustomed to, the API will have manual memory management paraphrenalia that doesn't fit well with the rest of user code. Plus this is also a much higher bar for the library author, so you're further limiting the already small number of people who are writing D libraries.  Or (2) be opinionated and write a GC-using library, in which case the betterC / @nogc people won't use it. Either alternative leads to ecosystem fragmentation. Or write a @nogc library but the betterC people won't use it.  Etc..

//

Now, this is only at the library level.  When you come down to the function level it gets worse. Take for example a library that has a function to register a callback to be triggered when some event occurs:

	void registerCallback(void delegate() cb);

Problem: @safe code can't call this. @nogc code can't call this. BetterC code can't call it either. What to do? Add the most restrictive attributes so that everyone can call it:

	extern(C) void registerCallback(void delegate() cb) @safe @nogc;

Oops, BetterC does not support delegates. Guess we have to lose that subset of D users:

	void registerCallback(void delegate() cb) @safe @nogc;

Still no good. The function will happily take a delegate in the `cb` parameter, but it can't do anything with it, it cannot be called from anywhere, the delegate is @system and may allocate.  Next stab:

	void registerCallback(void delegate() @safe @nogc cb) @safe @nogc;

OK, now the function body can actually call `cb`. But wait, now the function is no longer usable with @system callbacks. Nor with allocating callbacks.  Solution?  Templatize it and let the compiler figure out the attribute soup:

	void registerCallback()(void delegate() cb);

Finally, a solution?  Nope, there can only be one instantiation of this template, and the inferred attributes will be the most restrictive that still allows the function body to compile.  No matter what attributes the compiler infers for it, it will exclude *some* use cases. For example if @safe was inferred, it makes the function unusable with @system callbacks.  If @nogc was inferred, it cannot be used with allocating callbacks.  If it was inferred pure, it cannot be used with an impure callback.  So the only code that can actually call this function is pure @safe @nogc nothrow.  Meaning that it's useless for any code that's impure, @system, allocating, or uses Exceptions.

The only way around this is to create 2^N versions of this function, one with each combination of attributes, so that it's fully generic for all of its intended audience.

	void registerCallbackSystem(void delegate() @system cb) @system;
	void registerCallbackSafe(void delegate() @safe cb) @safe;
	void registerCallbackNoGc(void delegate() @nogc cb) nogc;
	void registerCallbackSafeNoGc(void delegate() @safe @nogc cb) @safe@ nogc;

Most library authors aren't going to bother doing this; they will just pick whatever attribute set suits them, and not bother about the rest. Net result: ecosystem fragmentation.


T

-- 
In theory, there is no difference between theory and practice.
January 12, 2024
On 12/01/2024 2:21 PM, H. S. Teoh wrote:
> Oops, BetterC does not support delegates. Guess we have to lose that subset of D users:
> 
> 
> |void registerCallback(void delegate() cb) @safe @nogc;|

What? -betterC supports delegates.

It does not support closure creation with GC however.

But you can create a delegate yourself just fine.

In fact if you make that scope, it'll create the closure just fine with -betterC.
January 12, 2024

On Thursday, 11 January 2024 at 23:09:46 UTC, Jonathan M Davis wrote:

>

@nogc doesn't even prevent collections running while a function is called. It just prevents that specific function from triggering the collection (thanks to no allocations triggering it). Another thread could trigger a collection while that function is running. So, yes, in a single-threaded program, it's equivalent to calling GC.disable, but in the general case, it isn't.

Or another thread could just call GC.enable/GC.collect and we are in a trouble either way, no matter what we do. Wouldn't it make sense to implement this other thread in a way that it properly cooperates with the main thread?

>

So, anyone actually relying on @nogc preventing collections is arguably asking for trouble even with the current GC - though it seems like the kind of folks who like to use @nogc are often the kind of folks who are likely to avoid the GC entirely, so if @nogc is used everywhere in their code, then they won't end up with either GC allocations or collections.

You are probably talking about the OS kernel developers. Something like PowerNex, d-virtio and maybe a few other seemingly inactive/dead D projects.

But a common scenario for games is to load resources taking advantage of the GC. And then try to avoid GC allocations in the main loop for performance reasons. Do D language maintainers refuse to acknowledge the existence of game developers? I think that there are a few of them in this forum.

>

However, anyone using it selectively really can't rely on it to avoid collections unless their program is single-threaded and will always remain so.

What if the other threads are also @nogc?

January 12, 2024

On Thursday, 11 January 2024 at 23:12:36 UTC, Timon Gehr wrote:

>

alias nice=pure @nogc @safe nothrow;

void foo()@nice{}

Then, you need generic parameters, I'll indicate them with []:

void opApply[functionAttribute a](scope int delegate()a dg)a{
    ....
}

The attribute should be a set(making it easier to determine if it exists), and every common building block (function, enumeration, variable,etc.) can have one, and even all building blocks can have the same set name!

This way, all desired constructs can be extracted at compile time!

January 12, 2024

On Friday, 12 January 2024 at 01:42:42 UTC, zjh wrote:

void opApply[functionAttribute a](scope int delegate()a dg)a{
    ....
}
//=>
void opApply[aset b](scope int delegate()a dg)a{
    ....
}

Here, 'b' represents the set of attributes, and compare with the set of a's attributes to indicate whether or a meet b.