Live data from Hacker News

Retiring a favourite C++ joke

ignition-training.com

141–150 of 151 posts

Re: Retiring a favourite C++ joke

#142
post #136
post #135

Earlier quoted context omitted.

Nope, it is called experience with large code and teams.

We are talking about one very specific issue, the point of this thread is a joke about new and delete. And your response after evidence services against your position is, “what about all these other things?” Definition of whataboutism.

Nope, the whole issue is about modern C++ in practice versus slideware at conferences.

Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it.

Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.

Re: Retiring a favourite C++ joke

#143

Earlier quoted context omitted.

Since that counter can only have two values, it's storage is optimized and merged with the underlying raw pointer itself (not unlike Rust's null pointer optimization for enums): non-null value of the underlying pointer also serve to represent the counter's value of 1, and the null value serves to represent the counter's value of 0. The check to not under-decrement, for example, manifests as the null check before call…

Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.

I can’t upvote this comment enough. The amount of pedantic nonsense on HN these days is disappointing. I’m not sure why I even bother to read comments here anymore.

Re: Retiring a favourite C++ joke

#144

Earlier quoted context omitted.

FWIW the behavior of delete on a pointer that isn’t either null or returned from new is undefined. So a conforming C++ compiler doesn’t have to diagnose this mistake, and similarly the compiled program doesn’t have to do anything meaningful either. For example, just ignoring the delete and printing the message is as valid a result as the more useful crash at the site of the bad operation.

That this situation is "working as intended" and there are programmers who do not see a problem with that is... well it makes me despair.

What's your proposed alternative? What does the alternative cost? If non-zero, what mechanism would you use to disable it?

Re: Retiring a favourite C++ joke

#145

Earlier quoted context omitted.

Since that counter can only have two values, it's storage is optimized and merged with the underlying raw pointer itself (not unlike Rust's null pointer optimization for enums): non-null value of the underlying pointer also serve to represent the counter's value of 1, and the null value serves to represent the counter's value of 0. The check to not under-decrement, for example, manifests as the null check before call…

Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.

Nope. Only those with "if (this->inner_resource) { /* delete inner resource */ }" inside the destructor could count, others wouldn't.

Edit: actually, nevermind. You are (almost) right: all objects with automatic storage duration and with non-trivial destructors are, very pedantically speaking, reference counted; but objects with dynamic storage duration are not. So RAII works by leveraging the built-in very primitive and restricted (binary) form of reference counting and builds on top of it to be able to reference-count objects with dynamic storage duration as well.

Re: Retiring a favourite C++ joke

#146

Earlier quoted context omitted.

Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.

Nope. Only those with "if (this->inner_resource) { /* delete inner resource */ }" inside the destructor could count, others wouldn't. Edit: actually, nevermind. You are (almost) right: all objects with automatic storage duration and with non-trivial destructors are , very pedantically speaking, reference counted; but objects with dynamic storage duration are not. So RAII works by leveraging the built-in very primitiv…

This is just petty sophism. I won't participate further. Have a nice day.

Re: Retiring a favourite C++ joke

#147
post #142
post #136

Earlier quoted context omitted.

We are talking about one very specific issue, the point of this thread is a joke about new and delete. And your response after evidence services against your position is, “what about all these other things?” Definition of whataboutism.

Nope, the whole issue is about modern C++ in practice versus slideware at conferences. Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it. Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.

This is just a petty digression. I won't participate further. Have a nice day.

Re: Retiring a favourite C++ joke

#148
post #147
post #142

Earlier quoted context omitted.

Nope, the whole issue is about modern C++ in practice versus slideware at conferences. Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it. Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.

This is just a petty digression. I won't participate further. Have a nice day.

Finally! One "modern C++" advocate less.

Re: Retiring a favourite C++ joke

#149
post #148
post #147

Earlier quoted context omitted.

This is just a petty digression. I won't participate further. Have a nice day.

Finally! One "modern C++" advocate less.

> Dreamer that some day all major systems programming languages will support automatic memory management.

Ironic bio for someone opposed to modern C++ advocates.

Re: Retiring a favourite C++ joke

#150
post #15

Earlier quoted context omitted.

yes, I would have thought the "better" version would be int tobias[24]; delete tobias;

I'll be honest, I didn't get it at first. I thought initially that it was too complex for the teaching example. And then it clicked. You're rather smart aren't you! I guess 24, or 36, or 48 would have worked!

Yeah, I was thinking the number of never-nudes in the world might closer to 2 dozen than 3 or 4 dozen, but I don't really know!
Post reply on HN