Thread overview
What is the current progress on "Safety and Memory Management"?
Jul 15, 2016
maik klein
Jul 16, 2016
The D dude
Jul 16, 2016
maik klein
Jul 16, 2016
Enamex
Jul 17, 2016
qznc
Jul 19, 2016
Karabuta
Jul 19, 2016
maik klein
Jul 20, 2016
tsbockman
Jul 18, 2016
tsbockman
July 15, 2016
https://wiki.dlang.org/Vision/2016H2

Safety and Memory Management

Safety and making the GC optional remain important concerns through the end of this year. We are putting them together because the GC alternatives we endorse must address safety.


Has there been any progress so far? Are there any DIPs to improve no gc code?
July 16, 2016
On Friday, 15 July 2016 at 12:59:39 UTC, maik klein wrote:
> https://wiki.dlang.org/Vision/2016H2
>
> Safety and Memory Management
>
> Safety and making the GC optional remain important concerns through the end of this year. We are putting them together because the GC alternatives we endorse must address safety.
>
>
> Has there been any progress so far? Are there any DIPs to improve no gc code?

I can see these two:

http://wiki.dlang.org/DIP18 (a bit outdated)
http://wiki.dlang.org/DIP68

I can remember that there was talk about making allow to use a custom allocator with `new`, but I haven't seen a proposal yet.

I do encourage you to volunteer, doing the research & submitting your idea(s) for a change ;-)
July 16, 2016
On Saturday, 16 July 2016 at 20:38:05 UTC, The D dude wrote:
> On Friday, 15 July 2016 at 12:59:39 UTC, maik klein wrote:
>> https://wiki.dlang.org/Vision/2016H2
>>
>> Safety and Memory Management
>>
>> Safety and making the GC optional remain important concerns through the end of this year. We are putting them together because the GC alternatives we endorse must address safety.
>>
>>
>> Has there been any progress so far? Are there any DIPs to improve no gc code?
>
> I can see these two:
>
> http://wiki.dlang.org/DIP18 (a bit outdated)
> http://wiki.dlang.org/DIP68
>
> I can remember that there was talk about making allow to use a custom allocator with `new`, but I haven't seen a proposal yet.
>
> I do encourage you to volunteer, doing the research & submitting your idea(s) for a change ;-)

I was actually thinking of contributing something bigger as part of my bachelor thesis. (Not sure if I am allowed to do that)

What I wanted to do is to translate a big part of Rust's std to D. Stuff like Rc, Arc, Box, Optional + all the necessary tools for ownership semantics.

Also implement data structures that work with ownership semantics (Rc, Box, Arc etc)  like Vec, HashMap.

Add ownership semantics to phobos, for example a lot of stuff in phobos can't be used with non copyable types. (A lot of things rely on copying)

I have already implemented a small part of Rusts std but it felt like that I was the only one interested in this. (I am aware of RefCounted, Unique, Nullable etc)

I would definitely put some spare time into researching this a bit more if there is some interest.


July 16, 2016
On Saturday, 16 July 2016 at 21:45:17 UTC, maik klein wrote:
> I was actually thinking of contributing something bigger as part of my bachelor thesis. (Not sure if I am allowed to do that)
>
> What I wanted to do is to translate a big part of Rust's std to D. Stuff like Rc, Arc, Box, Optional + all the necessary tools for ownership semantics.
>
> Also implement data structures that work with ownership semantics (Rc, Box, Arc etc)  like Vec, HashMap.
>
> Add ownership semantics to phobos, for example a lot of stuff in phobos can't be used with non copyable types. (A lot of things rely on copying)
>
> I have already implemented a small part of Rusts std but it felt like that I was the only one interested in this. (I am aware of RefCounted, Unique, Nullable etc)
>
> I would definitely put some spare time into researching this a bit more if there is some interest.

That sounds very interesting. You mean to encode Rust-like ownership semantics at runtime for a complete alternative stdlib in D?
July 17, 2016
On Saturday, 16 July 2016 at 21:45:17 UTC, maik klein wrote:
> I was actually thinking of contributing something bigger as part of my bachelor thesis. (Not sure if I am allowed to do that)
>
> What I wanted to do is to translate a big part of Rust's std to D. Stuff like Rc, Arc, Box, Optional + all the necessary tools for ownership semantics.
>
> Also implement data structures that work with ownership semantics (Rc, Box, Arc etc)  like Vec, HashMap.
>
> Add ownership semantics to phobos, for example a lot of stuff in phobos can't be used with non copyable types. (A lot of things rely on copying)

If I were your advisor, I would suggest not to think about Phobos. Just build your own library and publish via dub. Getting a contribution into Phobos is not a good use of time for a bachelor thesis.

Apart from that: Ownership semantics as a library is a great topic! Go for it.


July 18, 2016
On Saturday, 16 July 2016 at 21:45:17 UTC, maik klein wrote:
> What I wanted to do is to translate a big part of Rust's std to D. Stuff like Rc, Arc, Box, Optional + all the necessary tools for ownership semantics.
>
> Also implement data structures that work with ownership semantics (Rc, Box, Arc etc)  like Vec, HashMap.
>
> Add ownership semantics to phobos, for example a lot of stuff in phobos can't be used with non copyable types. (A lot of things rely on copying)
>
> I have already implemented a small part of Rusts std but it felt like that I was the only one interested in this. (I am aware of RefCounted, Unique, Nullable etc)
>
> I would definitely put some spare time into researching this a bit more if there is some interest.

Walter and Andrei have, in the past, stated many times that they believe Rust's approach to the memory safety problem is too complex and not a good fit for D. They have been exploring alternative solutions for a while now, and will probably announce something eventually.

Nothing significant gets added to the language, runtime, or standard library without their approval - no matter how popular it is with the community.

So, make sure that you get explicit pre-approval from them before you waste your time, unless everything you want to do can be implemented as a normal stand-alone DUB package.
July 19, 2016
On Sunday, 17 July 2016 at 06:05:27 UTC, qznc wrote:
> On Saturday, 16 July 2016 at 21:45:17 UTC, maik klein wrote:
>> I was actually thinking of contributing something bigger as part of my bachelor thesis. (Not sure if I am allowed to do that)
>>
>> What I wanted to do is to translate a big part of Rust's std to D. Stuff like Rc, Arc, Box, Optional + all the necessary tools for ownership semantics.
>>
>> Also implement data structures that work with ownership semantics (Rc, Box, Arc etc)  like Vec, HashMap.
>>
>> Add ownership semantics to phobos, for example a lot of stuff in phobos can't be used with non copyable types. (A lot of things rely on copying)
>
> If I were your advisor, I would suggest not to think about Phobos. Just build your own library and publish via dub. Getting a contribution into Phobos is not a good use of time for a bachelor thesis.
>
> Apart from that: Ownership semantics as a library is a great topic! Go for it.

+1
July 19, 2016
On Sunday, 17 July 2016 at 06:05:27 UTC, qznc wrote:
> If I were your advisor, I would suggest not to think about Phobos. Just build your own library and publish via dub. Getting a contribution into Phobos is not a good use of time for a bachelor thesis.
>
> Apart from that: Ownership semantics as a library is a great topic! Go for it.

That was the initial idea, but its not completely feasible to have it as a standalone library because a few things in phobos just need to be fixed for it to be practical. For example "Tuple", I could and will have a separate Tuple implementation but it would be very nice if I could at one point forward some changes to phobos. Probably in combination with a DIP and why those changes are needed.

Also some safety features of Rust could also be implemented as a library for example Sync and Send. See https://doc.rust-lang.org/nomicon/send-and-sync.html

My major concern is that I am not sure if the D community wants to have similar ownership semantics of C++ / Rust.

> Walter and Andrei have, in the past, stated many times that they believe Rust's approach to the memory safety problem is too complex and not a good fit for D. They have been exploring alternative solutions for a while now, and will probably announce something eventually.
>
> Nothing significant gets added to the language, runtime, or standard library without their approval - no matter how popular it is with the community.
>
> So, make sure that you get explicit pre-approval from them before you waste your time, unless everything you want to do can be implemented as a normal stand-alone DUB package.

I don't want to implement any memory safety at all, I just want to implement a proper library to avoid the GC. I just listed Rust because Rusts's std lib is open source, readable and feature rich. (+ I am already familiar with it)
July 20, 2016
On Tuesday, 19 July 2016 at 13:01:23 UTC, maik klein wrote:
> I don't want to implement any memory safety at all,

If you don't care about memory safety, I expect that your efforts to modify Phobos for that purpose will be unwelcome. The D leadership are actively working on non-GC memory management, but safety is a high priority.

A third-party library for unsafe memory management might see some adoption - but it also risks being made irrelevant when and if the official project for safe memory management finally bears fruit.