[Info-vax] Rust as a HS language, was: Re: Quiet?

Dan Cross cross at spitfire.i.gajendra.net
Tue Apr 5 20:41:48 EDT 2022


In article <624cd4e1$0$701$14726298 at news.sunsite.dk>,
Arne Vajhøj  <arne at vajhoej.dk> wrote:
>[snip]
>For low level I can only think of two: Rust and Go. And they seem to
>have found different markets - the OS people like Rust and the
>container people like Go.

Disclaimer: I'm good friends with a number of the Go core team
folks.  Go and Rust are very complementary, with Go being great
for engineering large project with many programmers working in
parallel in a shared code base, and Rust being great for
low-level bit-twiddly kinds of applications.

Go isn't so awesome at the kinds of low-level bare-metal
applications that Rust excels at, however, as it has a very
substantial runtime and expects a lot of OS support (projects
like Tamago and Biscuit/GERT not withstanding).

Getting Rust going on bare metal, in comparison, is almost
trivial: set up a stack and jump to main().

>[snip]
>Rust checks memory access *unless* in an unsafe block (idea borrowed
>from C# language). As a low level language Rust has the need to be able
>to do some flexible memory access - I can not imagine it is
>possible to write a device driver if only able to access memory
>in variables in the program.

It's possible if you are willing to play games with the linker,
and very early bootstrap, but it's sufficiently tedious that it
is just much easier to transmute an integer to a pointer via
unsafe.  Noteably, you really only have to do that once, and you
can largely confine _most_ drivers to mostly safe code.

I don't think that Rust's unsafe was inspired by C#, but I
confess I haven't asked.

>Rust has a unique approach to memory handling based on
>ownership (idea borrowed from modern C++ best practice
>not C++ language) that avoids memory leaks without GC - as
>a low level language that may be used in real time
>context, then the standard solution to avoid memory
>leaks in high level languages GC could be problematic.

Yup.  You get something _very_ close to managed memory without
the overhead of GC.  Note that sometimes GC can be surprisingly
helpful in high-overhead situations (think tight loops where,
thanks to GC, you don't have to check ref counts or pointer
validity...), but generally you get much of that in Rust without
the additional overhead.

	- Dan C.




More information about the Info-vax mailing list