Re: [dev] Ada not Rust

From: Jeremy <jer_AT_jer.cx>
Date: Tue, 20 Apr 2021 06:45:40 -0700

On 04/20/21 10:56AM, Laslo Hunhold wrote:
> The strong point over Rust is readability, stronger guarantees, built-in
> concurrency and the fact that it's ISO-standardized, among many other
> things. To see how far you can go with Ada (using SPARK, a very close
> subset), read chapter 2.2 in [0]. All the tooling is GPL licensed, but
> they also make money with professional-tier packages.
>

Regarding readability: in terms of the just the standard libraries, I
agree that Rust is more readable than C, especially it comes to iterating
and generics.

The barriers to entry for hacking the compiler, however, increase as
these features are added.

etywyniel has suggested an implementation of generics in C that use M4:
https://github.com/etwyniel/c-generics

For example:
        VEC(int) v;
        v = VEC_NEW(int);

        printf("capacity: %zu\n", v.cap);
        PUSH(v, 55, 95, 88, 1, 2, 3, 4);

        SLICE(int) sl = VEC_SLICE(int, &v, :4);
        printf("Slice length: %zu\n", sl.size);

Note that, M4's utility is not restricted to C preprocessing, it has
applications in many other languages. M4 is a simple syntax and can be
implmented in very few lines of code:

$ git clone https://github.com/eunuchs/heirloom-project
$ wc -l heirloom-project/heirloom/heirloom-devtools/m4/* | grep total
 2578 total

Regarding ISO-standardization: could you explain a bit more about the
value of this?

Regarding built-in concurrency: I would argue that pipe(3) & select(3)
is sufficient for built-in concurrency, though I understand this debate
is on-going.

> Which stronger guarantees am I talking about? You can do contractual
> programming, guarantee there are no runtime-errors statically (!, i.e.
> at compile time), prove statically that there are no data-races (even
> in concurrent programs, how nice is that?) and Ada has had a proper
> memory ownership model since the 80's which Rust is selling us like
> this big new invention. And such guarantees are good to have when you
> write a program responsible for actuating nuclear-reactor-control-rods
> or the avionics of an aeroplane.
>

I agree that Rust is better at marketing memory ownership. I'd argue
that Rust is better at marketing as a whole.

Have a look at the arguments you can pass to "-fsanitize=" in gcc(1).

> > Rationally, there is nothing better than C. I wish all the other
> > things did not exist, so that people would stop piling crap on top of
> > crap. It takes a solid engineering discipline, which is long forgotten.
>
> But is the C-ecosystem really so light? We're using a slew of static
> analyzers, debuggers, etc. to fix our C programs, and even though I've
> been programming in C for a decade and would call myself relatively
> good at it, I still keep on making mistakes.
>

Isn't this the essence of UNIX?

Rust is an incredibly fun language to write in, and I believe that the
enthusiasm for it is unparalleled, however, I'm not certain it's doing
anything better in terms of debugging & static analysis compared to the
C ecosystem.

Jeremy
Received on Tue Apr 20 2021 - 15:45:40 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 20 2021 - 15:48:09 CEST