A D vs. Rust example

Steven Schveighoffer schveiguy at gmail.com
Sat Oct 22 00:52:43 UTC 2022


On 10/20/22 10:46 PM, Don Allen wrote:

> I've written about 10,000 lines of Rust over several years, revised many 
> times in consultation with a couple of people in the Rust community who 
> were particularly helpful. I've been writing code professionally and 
> otherwise for longer than most of you, since I'm now 80 (first line of 
> code in 1960 -- IBM 1620 assembly language). I understand Rust pretty 
> well at this point, so I don't think the "newcomer" description applies.

OK, apologies.

> The language is more difficult to master than other I've used (a lot). 
> And if you insist on never writing "unsafe", there are things that are 
> simply impossible to do that are routine in more traditional languages.

I agree that if you have to use escapes in your safe code to write 
useful programs, the utility of the memory safety goes way down. This is 
why I'm very keen to see D @safe be much easier to isolate.

> No. Nested functions don't see their enclosing environment in Rust.

Hm... closures in D typically mean an allocation. So maybe my 
terminology is messed up.

>> Many people discount D because their attempts to make it do the things 
>> in the way they are used to result in horrible performance, or weird 
>> problems.
> 
> I did run into that in D, mostly in the area of needing to be aware of 
> preventing the GC from snatching strings I'd passed to C code (sqlite) 
> (you and I shared that adventure last year). This came about in my case 
> because I was porting C code to D, which is mostly very easy, but I 
> missed this gotcha.

Yes, I remember. I'm still not satisfied with the lack of ability to 
ensure something is stored on the stack.

-Steve


More information about the Digitalmars-d mailing list