A D vs. Rust example
IGotD-
nise at nise.com
Fri Oct 21 14:46:16 UTC 2022
On Friday, 21 October 2022 at 14:04:25 UTC, Don Allen wrote:
>
> But I think there is an opportunity to create a memory-safe
> language with a GC that avoids many of the difficulties of
> Rust. And I think thread-safety should be an option, not a
> requirement, because there are applications that are inherently
> single-threaded. Those applications should not have to adhere
> to the rules that keep multi-threaded applications safe, as is
> the case in Rust, the only alternative being to sprinkle your
> code with "unsafe" blocks, or use thread_local!, which works,
> but makes the code similarly messy.
It already exists and it is called Swift. A few engineers from
the Rust team helped engineer Swift. The syntax similarities
between Swift and Rust are obvious. In Swift they added a lot of
lowering in order to hide the more explicit Rust syntax. If you
see the results after the lowering then the Rust syntax shines
through even more.
Swift added reference counting as GC (much because of
objective-C) and the result is that the language is quite usable,
much more easy to use than Rust. You will not end up with
senseless life time compiler error as in Rust.
Swift isn't safe as "nothing can go wrong" but safe enough for
me. For embedded systems, Swift isn't an ideal candidate as it
relies on its own foundation library, objective-C runtime and C++
standard library. Though there has been people who has
successfully ported Swift to OS-less systems.
More information about the Digitalmars-d
mailing list