More D & Rust

bearophile bearophileHUGS at lycos.com
Tue Oct 16 13:16:30 PDT 2012


Marco Leise:

> I agree with them, that it would be nice if D classes could
> naturally be placed on the stack.

Allocating D class instances in-place (on the stack or inside 
other structs/class instances) is not hard, but in practice I 
never do it (Like I never use Rebindable or Typedef. I sometimes 
use Nullable or AssumeUnique). But to make it safe enough you 
probably need a smarter type system, that they have mostly 
finished designing in Rust.

Avoiding most heap allocations is positive because it reduces the 
amount of garbage, reduces pressure on the GC, gives good 
performance even if you use a not too much refined GC, avoids GC 
precision troubles, helps use less levels of indirection, and 
generally helps keep the code faster.

Another thing Rust team is doing is (I think) having the 
reference compiler based on LLVM. This means saving time to 
develop only the front-end and designing the language. Scala 
development was quick because the "back-end" and the GC was 
already done (but of course it introduced some limitations. Now 
they are porting Scala to the LLVM, removing most or all of the 
limitations, but they keep all layers of the compiler but the 
last one, so they have to translate stack-based code to the 
infinite-number-of-registers-based IR of LLVM, and I think this 
is sub-optimal, but they will have time to fix this problem later 
removing one more stage in the middle).

Bye,
bearophile


More information about the Digitalmars-d mailing list