News for hackers. Stuff that matters.
Re:Modern C++ Won't Save Us by maccard on Tuesday April 23, 2019 @09:27AM (#19728330)
You can also do it in a one-liner in C++ if you're using shared pointers:

    if(auto obj = my_weak_ptr.lock())
    {
        do_stuff(obj);
    }
> Having to pay for a check is "paying for what you use". If you don't like it then don't make the object nullable in the first place and save yourself the test.

The point is that I can choose _when_ to pay that cost (e.g. I can eat the nullability check at this point, but not at this point, and I can use more sophisticated tooling like a static analyser to reason that the null check is done correctly).

Is it more error prone? yes. Does it allow for things to horribly wrong? yes. Is "rewriting it in rust" a solution? No. If I want to pay the cost of ref-counting, I can use shared/weak ptrs.

Re:Modern C++ Won't Save Us by aliceryhl on Tuesday April 23, 2019 @11:10AM (#19729379)
The rust code in question is not using reference counting.
Re:Modern C++ Won't Save Us by cpeterso on Tuesday April 23, 2019 @06:41PM (#19733715)
Rust's borrow checker is like compile-time reference counting. Same benefit, but no run-time cost.