HackerTrans
TopNewTrendsCommentsPastAskShowJobs

kbr-

no profile record

comments

kbr-
·l’année dernière·discuss
> Imagine you are sitting in a meeting at work. The discussion is around the plan your team had set in motion last quarter, and the results are being reviewed. Data is being twisted and harassed to confess to whatever version of reality the group wants to see. You are sitting there, and you see through the charade.

> You’re wondering what the point of this is? You did not slog through life, battling inhuman entrance examinations, irrational parental expectations and eight rounds of interviews to get this coveted job, only to do this data jugglery. You’re wondering - why is nobody asking the fundamental, first principles questions? Why are we not questioning our premise? Why are we misinterpreting cause and effect? Why are we chasing these vanity metrics, when the metrics themselves are poor indicators of reality? Why have we accepted as gospel truth some ‘self-evident’ principles?

> The meeting is adjourned, congratulatory messages are passed around, and a vague way forward is discussed. You shake your head, sigh deeply and groan internally, grab coffee and head to the next meeting.

I call people like the author of this post "intellectual superiors". You know, like in the meme with the fedora-wearing man looking out of a window. I was like him when I was in high school. Now trying to keep my ego in check, still struggling sometimes...

But even though the guy is such an intellectually superior person, he didn't manage to come up with the idea that maybe he's there in that meeting to... contribute? You know, you're part of the team, you're in the meeting for a reason, if you disagree with others, it's your responsibility to say it? You may be right that they are misrepresenting the data or arriving at wrong conclusions -- but it doesn't matter, because you chose to instead indulge yourself silently at feeling superior over these sheep.

Philosophers... right?
kbr-
·l’année dernière·discuss
You may also want to pass a resource through something like a channel, promise/future pair or similar. So it's not just down/up the callstack, sometimes it's "sideways". In those cases RAII is a life savior. Otherwise you have to explicitly remember about covering all possibilities: - what if resource never enters the channel - what if it enters the channel but never gets retrieved on the other side - what if the channel gets closed - what if other side tries to retrieve but cancels

Or you leak the resource.
kbr-
·l’année dernière·discuss
It makes things easier. Usually the move constructor (or move assignment operator) will cause the moved-from object to stop being responsible for releasing a resource, moving the responsibility to the moved-to object. Simplest example: move- construct unique-ptr X from unique-ptr Y. When X is destroyed it will free the memory, when Y is destroyed it will do nothing.

So you can allocate resource in one function, then move the object across function boundaries, module boundaries, into another object etc. and in the end the resource will be released exactly once when the final object is destroyed. No need to remember in each of these places along the path to release the resource explicitly if there's an error (through defer or otherwise).
kbr-
·l’année dernière·discuss
The author of the post claims that defer eliminates the need for RAII.

Well, goto also eliminates the "need" but language features are about making life easier, and life is much easier with RAII compared to having only defer.
kbr-
·l’année dernière·discuss
Yeah it's weird but the author of this post claiming that defer can replace RAII kinda suggests that. RAII isn't just about releasing the resource you acquired in the current scope in the same scope. You can pass the resource across multiple boundaries with move semantics and only at the end when it's no longer needed the resources will be released.
kbr-
·l’année dernière·discuss
> It’s a simple keyword, but it singlehandedly eliminates the need for any kind of RAII.

What if you want to put a resource object (which needs a cleanup on destruction) into a vector then give up ownership of the vector to someone?

I write code in go now after moving from C++ and God do I miss destructors. Saying that defer eliminates need for RAII triggers me so much
kbr-
·l’année dernière·discuss
Ahhahah that's beautiful, I'm crying.

Skynet sends Terminator to eradicate humanity, the Terminator uses this as its internal reasoning engine... "instructions unclear, dick caught in ceiling fan"