Memory safe and coroutines are the focus of D.
IGotD-
nise at nise.com
Sun Oct 16 20:22:47 UTC 2022
On Sunday, 16 October 2022 at 17:59:41 UTC, zoujiaqing wrote:
> Memory safe:
> Now there are two programming languages to solve memory safe.
> One is that rust-language limits memory safe when writing. The
> other is that swift-language uses ARC to manage memory to
> ensure memory safe. I think D should do more like swift.
Not going to happen because Walter do not want to have managed
pointers in the language. So we just have raw pointers in D just
like we have now. How do we add arbitrary managed memory (ARC or
whatever you want) with only raw pointers? I don't know and I
don't say it's impossible but that could be a fun D conference
talk.
As for the Swift comparison, it has value types which are
allocated on the stack and then it has classes which are
allocated on the heap. This in Swift does not exist (you can do
this if you resort to some unsafe types).
```d
int *intPtr = new int;
```
Swift also does allocation on the heap of structs which are value
types under certain conditions so there is more going on under
the hood there. Programmer will never see this unless they debug
the code. This can also make havoc if you start to copy these
heap allocated value types which can cause more heap allocations
without you knowing it.
If D would follow the same separation as Swift, then ARC for only
classes would be possible. Also that would be a reason not to use
D because I like to heap allocate whatever I want.
More information about the Digitalmars-d
mailing list