News for hackers. Stuff that matters.
Re:Safe C++: Language Extensions for Memory Safety by musicale on Thursday September 12, 2024 @09:20PM (#41527265)
And it only took 40 years (and the development of Java, JavaScript, Go, Rust, even smart pointers in C++ itself, etc.) for C++ implementors to realize it is a good idea!

Perhaps LLVM supporting improved memory safety (e.g. for Swift) is helpful as well.

Re:Safe C++: Language Extensions for Memory Safety by footguhn on Thursday September 12, 2024 @09:22PM (#41527283)
Add rust JIT to C++. No hope to keep up with all that is going to be and has been added to C++ in last decade
Re:Safe C++: Language Extensions for Memory Safety by pornel on Thursday September 12, 2024 @09:51PM (#41527383)
This is based on circle, which looks very Rust-like, and is probably the most sound design of all the contenders for the next C++. It has an actual safe-only mode, with strict aliasing, no uninit memory, and loans tracked via control-flow graph.

Many other "safe" C++ extensions just add basic bounds checking, and end at "we have smart pointers, what else do you want!?!??!?"

Re:Safe C++: Language Extensions for Memory Safety by ladyanita22 on Friday September 13, 2024 @01:50AM (#41528338)
But I understand that if this proposal makes the cut, other compilers would implement it too and make this universal. Seeing this seems to implement all of Rust’s safety features, this would seem like a win here.
Re:Safe C++: Language Extensions for Memory Safety by pornel on Friday September 13, 2024 @08:12AM (#41530440)
It is, although "nobody's going to rewrite millions lines of code" applies to C++ too, not only Rust.

You won't be able to just slap `#pragma safe` on top of every file and have the problem solved. It does require use of different design patterns and structuring data in a way that works with borrowing.

Re:Safe C++: Language Extensions for Memory Safety by lbhdc on Thursday September 12, 2024 @10:00PM (#41527419)
This looks really interesting! It does look very rust like.

    auto get_x/(a, b)(const int^/a x, const int^/b y) -> const int^/a {
      return x;
    }
I like the new `choice` type. It looks like a c++ flavored rust enum.

    template<class T+, class E+>
    choice expected {
      [[safety::unwrap]] ok(T),
      err(E);
    
      T unwrap(self) noexcept safe {
        return match(self) -> T {
          .ok(t)  => rel t;
          .err(e) => panic("{} is err".format(expected~string));
        };
      }
    };
Re:Safe C++: Language Extensions for Memory Safety by ladyanita22 on Friday September 13, 2024 @08:52AM (#41530771)
What are the chances of this proposal making the cut?