Comparing Rust and D As Better C

bpr brogoff at gmail.com
Thu Dec 24 17:31:27 UTC 2020


On Thursday, 24 December 2020 at 00:41:35 UTC, Dibyendu Majumdar 
wrote:
> The enumerated types are important feature for my project which 
> currently uses unions. I may or may not use traits, I do not 
> know yet.
>
> At the moment I am struggling to implement the memory allocator 
> scheme in Rust. I may end up having to forgo this and just use 
> standard Rust facilities for memory management. With D I don't 
> think I will have any issues.

Have you seen this? https://os.phil-opp.com/allocator-designs/

Also https://doc.rust-lang.org/reference/items/unions.html

I didn't find it that difficult to convert C to Rust in the past 
but you may have some special C.

C++ is a different story. For now, Rust lacks const-generics 
(can't parameterize templates with constants) and HKT (higher 
kinded types, expressed in C++ as template template parameters) 
so designs that make use of these won't carry over directly. IIRC 
DasBetterC has all of D's static metaprogramming features. Rust 
has macros, which I've used in the past to work around the lack 
of const-generics.




More information about the Digitalmars-d mailing list