www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - NuMem - safe(r) nogc memory managment

reply Luna <luna foxgirls.gay> writes:
NuMem 0.5.4 has been released, numem is a new library I am 
developing with contributions from Auburn Sounds/p0nce. It's 
meant to provide safer ways of writing nogc code, which is 
sometimes neccesary when the D garbage collector would be an 
unoptimal choice.

NuMem currently features:

  * C++ style smart pointers (unique_ptr, shared_ptr, weak_ptr)
  * C++ style vector type (with support for moving unique_ptr's 
in!)
  * Alternative for new and destroy; `nogc_new` and `nogc_delete`.
  * A string alternative built on the vector implementation
    * Automatic null-pointer handling, for easy passing of strings 
to C.
  * A `minimal_rt` mode meant for environments where only a tiny 
subset of the D runtime is present, with custom handling of class 
destruction that doesn't use TypeInfo.
    * Eg. the port of D I'm making for the SEGA Dreamcast.

We plan to add more memory management utilities, thereby making 
writing completely GC-less D code a lot more user-friendly.

You can find the package here
https://code.dlang.org/packages/numem

Additionally, the `yxml` package uses numem's smart pointers and 
strings.
https://code.dlang.org/packages/yxml
Dec 30 2023
next sibling parent Guillaume Piolat <first.name gmail.com> writes:
On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:
  * C++ style smart pointers (unique_ptr, shared_ptr, weak_ptr)
  * C++ style vector type (with support for moving unique_ptr's 
 in!)
Indeed with numem you can have a relatively "C++11" experience with scoped ownership, which we intend to make use of because without GC it's easy to be plagued by leaks in user code.
Dec 30 2023
prev sibling next sibling parent ryuukk_ <ryuukk.dev gmail.com> writes:
Nice, thanks for sharing, it'll be very useful for the C++ 
developers who want to give D a try
Dec 30 2023
prev sibling next sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
 We plan to add more memory management utilities, thereby making 
 writing completely GC-less D code a lot more user-friendly.
I'd be happy to help What D really is missing _right now_, and will hopefully get _before_ phobosv3 is a good and minimalistic Allocator API, i modeled mine around zig's, no RAII, just a simple struct with 3 function ptr
Dec 30 2023
next sibling parent Guillaume Piolat <first.name gmail.com> writes:
On Saturday, 30 December 2023 at 16:36:38 UTC, ryuukk_ wrote:
 What D really is missing _right now_, and will hopefully get 
 _before_ phobosv3 is a good and minimalistic Allocator API, i 
 modeled mine around zig's, no RAII, just a simple struct with 3 
 function ptr
FWIW it's possible to do a generic one with one function pointer: https://www.lua.org/manual/5.4/manual.html#lua_Alloc
Dec 30 2023
prev sibling parent IGotD- <nise nise.com> writes:
On Saturday, 30 December 2023 at 16:36:38 UTC, ryuukk_ wrote:
 We plan to add more memory management utilities, thereby 
 making writing completely GC-less D code a lot more 
 user-friendly.
I'd be happy to help What D really is missing _right now_, and will hopefully get _before_ phobosv3 is a good and minimalistic Allocator API, i modeled mine around zig's, no RAII, just a simple struct with 3 function ptr
Yes, but first we can replace all the data structures in druntime to use non GC versions. I don't think there are that many of them. The non GC dynamic array would be a good fit here.
Dec 30 2023
prev sibling parent reply Sergey <kornburn yandex.ru> writes:
On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:
 NuMem 0.5.4 has been released, numem is a new library
Any meaningful comparison with another similar library will be highly appreciated https://code.dlang.org/packages/automem
Jan 02
parent Guillaume Piolat <first.name gmail.com> writes:
On Tuesday, 2 January 2024 at 10:30:52 UTC, Sergey wrote:
 On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:
 NuMem 0.5.4 has been released, numem is a new library
Any meaningful comparison with another similar library will be highly appreciated https://code.dlang.org/packages/automem
I'm not familiar with automem, and I'm not numem primary author. Goals seems very similar and from a cursory reading: - automem is much further along on many points such as: attribute forwarding, nogc, safe, DIP1000, allocator support, ranges, support for GC roots, and exists since 6 years. - numem is designed to allow C++ programmers to feel at ease, with a bit less runtime use maybe. Containers own their elements, like C++ containers (not sure how it is in automem). We plan a std::map-like.
Jan 03