October 15, 2021

On Friday, 15 October 2021 at 15:17:11 UTC, Imperatorn wrote:

>

On Friday, 15 October 2021 at 14:24:16 UTC, SomeGuy wrote:

>

On Friday, 15 October 2021 at 13:45:11 UTC, deadalnix wrote:

>

[...]

This problem could still be solved by making the GC just another allocator (and make it the default global allocator). D's current GC only runs when an allocation is made anyway, so doing this shouldn't break the behavior of existing code (except leaking memory if the constructs that assume GC is used, of course).

Maybe from this point on those constructs can be made to use reference counting instead and make sure they're allocator-independent.

Bring back new and make it configurable 😎

Maybe I can make LWDR do this.

October 15, 2021

On Friday, 15 October 2021 at 15:42:13 UTC, IGotD- wrote:

>

On Friday, 15 October 2021 at 14:24:16 UTC, SomeGuy wrote:

>

[...]

The biggest obstacle is that D has no fat pointers. It has only pointers which is enough when you have tracing GC but not enough if your pointers requires extra metadata.

This is one of the biggest mistakes in D which limits the possibility to change GC type. Other languages like Nim have a reference types which is a fat pointer type. Nim has gone through more GC types in a shorter time than D.

Fat pointers come at a cost though which might be extra dereferences as your data is an inner pointer member. In practice this is already possible in D as a library solution. Problem is that you cannot easily change Druntime/Phobos to also use your custom GC.

Er, that's not how Nim's "fat pointers" work and the term is either misleading or wrong, sizeof(ref) == sizeof(void*) in Nim land.

October 15, 2021

On Friday, 15 October 2021 at 16:05:13 UTC, Araq wrote:

>

Er, that's not how Nim's "fat pointers" work and the term is either misleading or wrong, sizeof(ref) == sizeof(void*) in Nim land.

So how do they work then, when you have set the GC to default ORC?

October 15, 2021

On Friday, 15 October 2021 at 15:42:13 UTC, IGotD- wrote:

>

The biggest obstacle is that D has no fat pointers. It has only pointers which is enough when you have tracing GC but not enough if your pointers requires extra metadata.

This is one of the biggest mistakes in D which limits the possibility to change GC type. Other languages like Nim have a reference types which is a fat pointer type. Nim has gone through more GC types in a shorter time than D.

Fat pointers come at a cost though which might be extra dereferences as your data is an inner pointer member. In practice this is already possible in D as a library solution. Problem is that you cannot easily change Druntime/Phobos to also use your custom GC.

Yeah, what I was proposing is not actually for adding custom GC types, it is for gradually phasing out the GC (for libraries) and maybe replace it with some reference counted type like Rust has.

When people complain about GC in D it's mostly because the library ecosystem is by default @YesGC. TBH I like having a GC and using it when I don't care about memory usage or speed. This mostly when I use D as a Python replacement and it does its job well.

The problem is when I want to use D as a C++ replacement. When I try to do that, I can't D libraries that are not @nogc. I want library developers to design their interfaces after considering allowing the usage of different allocators. Because if that happens then I could pass the GC as the allocator parameter and not care about memory management, or maybe I want to pass my own arena allocator when I'm thinking about cache locality or whatever. Otherwise we're risking two different library ecosystems coexisting (one @nogc and one @yesgc) and that means we'll never have a good library ecosystem.

Just let the application developers pass whatever allocator parameter into the libraries (and actually make the stdlib work this way to set an example).

If the current situation persists, D is just "C" or "Go" with more features and much fewer libraries.

I'm okay with D not having the ecosystem of C (or Rust, or Go) and building everything from ground-up, most people wouldn't be. Don't tell me we have great interop with C and C++, I'm using D because I want to minimize my exposure to C & C++.

I hope the situation changes, because if it doesn't Zig will eat D's lunch even though it is actually a worse language (with probably a better ecosystem). Or maybe Jai will if the situation doesn't change before Jai is released (and everybody knows it won't be released for years, still). That'd be especially saddening since Jai is actually just D with different syntax, no GC and more powerful CTFE. That's literally it.

October 15, 2021

On Friday, 15 October 2021 at 16:21:32 UTC, SomeGuy wrote:

>

When people complain about GC in D it's mostly because the library ecosystem is by default @YesGC. TBH I like having a GC and using it when I don't care about memory usage or speed. This mostly when I use D as a Python replacement and it does its job well.

You kind have to, the alternative being that the library aren't @YesGC as you say, and then whatever reference they manipulate is now invisible to the GC. That may cause library users to see their object being collected when they are still alive and a whole slue of similar problem.

If you want the language to support a GC, you HAVE TO have the library allocate anything using the GC.

From there you have several options:
1/ Not use a GC at all and do manual memory management à la C++.
2/ Use a GC for everything à la Java.
3/ Not use a GC an use an ownership system instead à la Rust.
4/ Allow for manual memory management via GC free, but in which case the compiler can't prove anything, so things like @safe or @nogc cannot work by design.
5/ Use a GC AND an ownership system that allow the compiler to prove invariant about freeing (and even do a lot of it automatically) so things like @safe can work (and @nogc needs to forbid GC leaks rather than GC allocations).

D correspond to none of the above, even though it tries to be kind of 4 kind of 5.

Then end result in practice is that almost everything uses the GC, and that @safe and @nogc are almost useless.

October 15, 2021

On Friday, 15 October 2021 at 10:58:14 UTC, bauss wrote:

>

On Friday, 15 October 2021 at 10:26:51 UTC, Imperatorn wrote:

>

On Friday, 15 October 2021 at 09:47:48 UTC, Antonio wrote:

>

On Monday, 11 October 2021 at 15:59:10 UTC, Atila Neves wrote:

>

[...]

About Wrong D features:

In my opinion, D is afraid of embracing decisions with all it's consequences... it maintains itself in a position where nothing is "the best for niche X"

[...]

I'm not sure what you mean by your gc/nogc comment. Could you clarify? D allows for all approaches afaik

I think that's his problem. D doesn't have a specific philosophy about memory management.

Oh, I see 😎

October 15, 2021
I have one!

noreturn
October 15, 2021

On Friday, 15 October 2021 at 16:10:04 UTC, IGotD- wrote:

>

On Friday, 15 October 2021 at 16:05:13 UTC, Araq wrote:

>

Er, that's not how Nim's "fat pointers" work and the term is either misleading or wrong, sizeof(ref) == sizeof(void*) in Nim land.

So how do they work then, when you have set the GC to default ORC?

The RC and metadata are stored at negative offsets.

October 15, 2021
On Friday, 15 October 2021 at 17:14:10 UTC, Andrei Alexandrescu wrote:
> I have one!
>
> noreturn

Context: Andrei is expressing his frustration with noreturn in discord due to the poor implementation and testing of it.

-Alex
October 15, 2021

On Friday, 15 October 2021 at 13:21:25 UTC, russhy wrote:

>

On Friday, 15 October 2021 at 11:57:28 UTC, deadalnix wrote:

>

On Friday, 15 October 2021 at 10:58:14 UTC, bauss wrote:

>

[...]

This is fine. But here is the deal: that means D cannot have a philosophy on safety. Or have closure allocated on the GC by default. Or a gazilion other things.

It's the same problem, just in another dimension: a decision is made, ut then consequences are not accepted.

using allocators aware APIs solves all of this, look at zig!

it is a problem already solved, use allocators and don't assume one is using GC or other means

--

on the nullable thingy, i agree 100%, we now got 2 way for null

  • null keyword

  • isNull method

nice! in the std! it's standard now!..

Except safety, using Zig is no better than Modula-2, as it doesn't prevent use-after-free bugs.

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19