Reply to post: Re: native targets

Microsoft emits last preview of .NET 6 and C# 10, but is C# becoming as complex as C++?

Man inna barrel

Re: native targets

> RAII does not obviate the need to use smart pointers to avoid memory leaks.

I am investigating Rust at present, and that seems to do a fine job with non-GC memory management, based on RAII. I have not needed smart pointers yet. Compile time enforcement of object lifetimes and validating references to shared data can lead to some pretty arcane compile time errors, but every time I get one of those, I find I am trying to do something that would probably be unsafe in C++.

For example, I tried to define a struct containing a reference to an item in a vector. That is definitely unsafe if the vector is mutable, because actual memory locations can vary when the vector is modified, due to re-allocating the underlying data array. I am going to replace the pointer with an index, which is maybe not as neat, but does not suffer from potential memory errors.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon