News for hackers. Stuff that matters.
Re:Lies we tell ourselves to keep using Golang by pif on Tuesday November 26, 2024 @03:43AM (#42243714)
> I’ve previously spoken about my loathing of exception handling because it adds a “magic” layer to things which is way too easy to mess up.

I kind of see your point. In this very moment, it doesn't matter whether I agree. What I don't understand, though, is why (typically) people who abhor exceptions are among the fiercest defenders of garbage collection, which does add a “magic” and uncontrollable layer to object destruction.

Personally, having learned to love RAII with C++, I was shocked to discover that other languages discarded it initially and had to add it in later when they realized that their target developers are not as dummy as those choosing Golang.

Re:Lies we tell ourselves to keep using Golang by bsaul on Tuesday November 26, 2024 @04:04AM (#42243840)
How does RAII works in concurrent systems ? It seems to me you need to add compile-time object lifetime evaluation (as in rust) which so far incurs a high toll on language complexity.
Re:Lies we tell ourselves to keep using Golang by maleldil on Tuesday November 26, 2024 @05:00AM (#42244203)
The exact same way it works in Rust. C++'s RAII works the same as Rust's Drop trait. The object is released when it goes out of scope, and if it's shared (e.g. Arc), it's released when the last reference to it drops.
Re:Lies we tell ourselves to keep using Golang by Mawr on Tuesday November 26, 2024 @06:06AM (#42244632)
Different kind of magic. Needing to account for every single line of code being able to throw an exception is very mentally taxing, whereas the existence of a GC removes mental load of needing to account for every single allocation.