Comparing Rust and D As Better C

Dibyendu Majumdar mobile at majumdar.org.uk
Thu Dec 24 00:41:35 UTC 2020


On Wednesday, 16 December 2020 at 00:36:03 UTC, Dennis wrote:
> On Tuesday, 15 December 2020 at 23:25:02 UTC, Dibyendu Majumdar 
> wrote:
>> I am working on porting a C project to Rust and Better C in 
>> order to get a real world idea of what the differences are.
>
> Is it a public C project?

Yes.

>
>> First impressions of Rust vs D As Better C:
>>
>> Rust has traits - nothing equivalent in the D As Better C 
>> subset.
>> Another difference is Rust has enumerated types - with D a 
>> library solution is possible.
>> Rust appears to have a good tooling in VS Code with pretty 
>> good IDE that gives you hints, flags errors as you type code, 
>> and allows you to lookup docs.
>
> Fair points, but I don't see the link to porting C code. C has 
> no traits, C has no enumerated types, and IDE features are not 
> needed when doing a simple translation. At least my C to D 
> translation work has been very straightforward so far, maybe 
> Rust requires more refactoring so then it's handy.
>

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.


> I have no experience with writing Rust. I do know there is a 
> migration tool for it though:
> https://github.com/immunant/c2rust

It is kind of useless for my purposes.



More information about the Digitalmars-d mailing list