[HN Gopher] Scope-based resource management for the Linux kernel
       ___________________________________________________________________
        
       Scope-based resource management for the Linux kernel
        
       Author : sohkamyung
       Score  : 29 points
       Date   : 2023-07-02 12:26 UTC (10 hours ago)
        
 (HTM) web link (lwn.net)
 (TXT) w3m dump (lwn.net)
        
       | AshamedCaptain wrote:
       | For all Linus' hate of C++, it just keeps creeping into the
       | kernel.
        
         | jacoblambda wrote:
         | While C++ is basically the origin of RAII, I think a lot of
         | this is a response to the Rust for Linux project picking up
         | steam. Rust showed that these things were not only possible but
         | viable without unnecessary overhead so the C side has to pick
         | up these niceties.
        
           | pipo234 wrote:
           | > Rust showed that these things were not only possible but
           | viable without unnecessary overhead [..]
           | 
           | Ehrm. You seem to imply that Rust has somehow solved the
           | overhead that C++ introduced. I'm aware that comparing Rust
           | versus C++ is a sensitive subject, but I'm curious if you
           | could elaborate on that?
        
       | debatem1 wrote:
       | Looks like a mutant defer, and I guess that's good? At least,
       | there are plenty of good things about it in golang. But I have to
       | admit I'm not looking forward to debugging the inevitable
       | function-with-mixed-defer/goto-resource-handling.
        
         | raggi wrote:
         | Defer has to be added manually and maintained correctly, and
         | often has double call challenges and so on. Automatic behavior
         | on scope exit is less fallible (including e.g. it can't just be
         | broken by the machine in a pathological patch application), and
         | has fewer logical pathologies such as double execution cases.
         | Defer was re-popularized by go, but I think rooted in a knee
         | jerk from bad c++. The scope mechanisms are better, as
         | discussed and it'd be great to see them in more places.
        
       ___________________________________________________________________
       (page generated 2023-07-02 23:01 UTC)