The Case for Rust (in the base system)

One simple example . In C you can dereference a null pointer & a pointer pointing to the sky. Never possible in F# or ada
Ada its quite easy:

Code:
with Ada.Text_IO;

procedure Erroneous is
   type Int_Ptr is access Integer;
   P : Int_Ptr;  -- uninitialized
begin
   -- ERRONEOUS EXECUTION
   Ada.Text_IO.Put_Line (Integer'Image (P.all));
end Erroneous;

F# is just .NET so the typical bindings marshal errors allow it too.

Code:
open Microsoft.FSharp.NativeInterop

#nowarn "9"   // allow NativePtr usage

let demo () =
    // Allocate stack memory for an int, but DO NOT initialize it
    let p = NativePtr.stackalloc<int> 1

    // ERRONEOUS / UNDEFINED BEHAVIOR
    let x = NativePtr.read p

    printfn "%d" x

demo ()

And since languages other than C or C++ need a *shedload* of bindings, this kind of dangerous stuff is very easy (and necessary) to creep in.
 
Ada its quite easy:

Code:
with Ada.Text_IO;

procedure Erroneous is
   type Int_Ptr is access Integer;
   P : Int_Ptr;  -- uninitialized
begin
   -- ERRONEOUS EXECUTION
   Ada.Text_IO.Put_Line (Integer'Image (P.all));
end Erroneous;

F# is just .NET so the typical bindings marshal errors allow it too.

Code:
open Microsoft.FSharp.NativeInterop

#nowarn "9"   // allow NativePtr usage

let demo () =
    // Allocate stack memory for an int, but DO NOT initialize it
    let p = NativePtr.stackalloc<int> 1

    // ERRONEOUS / UNDEFINED BEHAVIOR
    let x = NativePtr.read p

    printfn "%d" x

demo ()

And since languages other than C or C++ need a *shedload* of bindings, this kind of dangerous stuff is very easy (and necessary) to creep in.

What do you think of my cppfront program , hello.cpp2 ,

Code:
String: type == std::string; 
auto&   Cout =  std::cout;
#define Format  std::format

greet: (name: String) = {
    Cout << Format("Hello, {}\n", name);
}

sum: (a: i32, b: i32) -> i32 = {
    sum := a + b; // Type inference with :=
    return sum;
}

main: () = {
    x: String = "world";
    greet(x);
    s:=sum(10, 20);
    Cout << Format("Sum :  {}\n", s);
}
 
What do you think of my cppfront program , hello.cpp2 ,
I like it to an extent. I do think extensions of C (and C++) do have a lot of merit as a solution for a next gen language.

But my worry is that they focus on the wrong aspects and miss the important things that need to be improved.
 
And you miss to name those things that you regard as important.
Think about all these kids reading here ... do you think that they know?? :-/
The limitations of C++ are well cited in a number of papers. I don't expect every technical conversation needs to be suitable for kids.

Similarly to before, I can only recommend people read around if they are struggling to keep up 🤷‍♂️ .
 
Back
Top