My most downvoted StackOverflow answer
ohadravid.github.io
ohadravid.github.io
And of course c++ and c aren't the same language.
They answered a programming language question with an answer that only applies to a totally different programming language, and then wrote this whole article complaining about being down voted?
Although, the last image made the click worth it.
An incorrect answer can be useful, because it often illustrates common confusions and naive mistakes that people are prone to making;
If it's corrected with an explanation as to why it doesn't work, a good wrong answer can be more educational than the answer that actually solves the problem.
Possibly more, since the downvoters are probably just triggered.
Like, is there a subreddit dedicated to people drinking their own urine? Was that guy a one-off? I am choosing to remain ignorant, but it is taking some self-control to not dig deeper.
It was bad. Don’t believe the old men that tell you it was gentler and kinder, “back when.” That’s where I cut my troll teeth, and miss it like I miss a boil on my behind.
I thought it went out of fashion in the 90s when they figured out it damages your kidneys, but I may have misremembered that.
> The sizeof way is the right way iff you are dealing with arrays not received as parameters. An array sent as a parameter to a function is treated as a pointer
The conclusion is that it's impossible in that scenario, so you can only manually keep track.
But isn't this what dereferencing is for? What's my fundamental misunderstanding?
In C, there are arrays. If you use the identifier that names the array as a parameter to a function, it gets quietly converted to a pointer to the first item of the array and all array size information is lost.
So you can obtain the array size, but only if you are dealing with the identifier that directly names the array. If you attempt the same technique on a pointer to the array, bad things will happen.
Technically a pointer to the array will work as expected (i.e. void f(int (*x)[5])).
However, if you have a function parameter spelled `T array[N]`, that's really just a `T *array` with a helpful hint that it probably points to the beginning of an array of `N` `T`s. But it might not...
For the case of the function parameter, `sizeof array` is `sizeof(T*)`.
If you make an array 6 long, the compiler knows you did that. However, that information isn’t stored in heap anywhere. If all you have is sizeof(somePtr), there’s nothing for it to look at to retrieve the data.
This question really needs an answer that's carefully written to handle all 6 cases {C, C++ (since this belongs in a header)} x { normal array, VLA, pointer-which-is-an-error }
Over time people realized this is kinda dumb and annoying, so now C++ has std::span, Rust has slices, which are basically structures that store both a pointer and a size, so you can define functions like void do_something(std::span<int> numbers). C will remain forever though so we have to forever deal with the above
Sometimes the sized array form is actually never available, as with dynamically allocated memory. The correct pattern for all those cases is to pass around the size from where it's known, along with the pointer. One can also use a sentinel element to solve some problems without knowing the size explicitly.
Edit: The real point is, what was it about his answer that was hated/downvoted? Surely not the fact the sizeof(a)/sizeof(a[o]) requires a little knowledge and care?
Must be some sort of SO culture we're missing. Because in normal day-to-day conversation between reasonable adults, this would have been an acceptable answer.
https://web.archive.org/web/20231203060623/https://stackover...
Person gave an objectively incorrect answer (im assuming it was objectively incorrect, not really a c/c++ programmer). It was downvoted for being incorrect. That is how things should work
There is no shame in being wrong on the internet on occasion. I know i've said silly things countless times. Making mistakes is part of life. But we don't leave incorrect info out there to mislead others lest correcting it offends the original poster, we downvote/correct it. It is not a personal attack for someone to downvote incorrect/misleading info.
The other point is that there's (usually) no need to choose between good moderation and civility, and at least IMO "blatantly off-topic and should be deleted" really fails at being civil.
How would you express that instead? There was nothing harsh said here. Is it the word "blatantly"?
And why insist on deleting if people found it useful? It’s literally at the bottom of the page, so it’s not a public menace or anything.
1. Regarding the answer being old (This seem a major point from your article)
Answers on SO are intended to be a living organism. It's expected to be maintained very much like code. If you look at answers related to CSS and JS, you'll find many cases of answers[1] originally written in 2008 that are still up-to-date and were updated by various contributors to cover multiple specifications over the years. That's just how it works. Notice how questions are designed to have one accepted answer. So, answers ideally should never fall under "its just something I wrote 10 years ago". It's not a book.
2. Was the answer helpful? or was it noise?
Like you said, the answer was at the bottom of the page, and that's because the majority of people even before the discussion, have found other answers more helpful and voted for them instead over this. What to conclude from this? I believe that was the topic of the meta discussion, and we play by the community rules. Stackoverflow is designed to work similar to Wikipedia. If I was a involved with the discussion, I have no strong feeling about the answer and would probably vote to keep it because it's not harmful per say. But mods and active users are the ones qualified to set the policy that best serve the site/community over time based on their observations.
3. It's nothing personal
The quality of the answer is what matters. The same person can have terrible and great answers. Both the author of the comment and the meta discussion seem to be criticizing the answer and expressing their frustration with it (Rightfully or not). But you went beyond criticizing certain toxic behavior or culture, especially with the parallel you draw at the end to "drives this point home." which seem to be insulting them as a person. There was nothing civil about that IMHO.
[1] How the answer to "How can I horizontally center an element?" evolved over the years: https://stackoverflow.com/posts/114549/revisions
That said, drawing the ire of people on Hacker News is extremely easy, and I do that periodically.
1. come in on Monday and need to solve some stupid problem with a stupid regex
2. Ask a question about negative lookbehind or negative lookahead regex syntax in python and why it doesn't match the text you thought it should, because.... it's Monday.
3. Have people virtually spit-take all over you and heap their scorn for a n-millionth duplicate regex question.
Enjoy!
It’s because that reputation is flat out wrong. If you went onto Stack Overflow and went around insulting people, you’d get downvoted quickly until you didn’t have enough karma to post.
I don't understand. "There's little hope to delete-vote" means it isn't very bad!
> Are C and C++ two completely different languages?
> And, look. I don’t know. Obviously I wasn’t a C or a C++ expert then, am not one now and not even on the path of becoming one.
"Are Java and Javascript different languages? Who knows! But be nice to each other, which in this context means not downvoting answers from people who aren't familiar with the subject matter being discussed, I guess."
> existing working JavaScript code is also TypeScript code
For C++, it's been decades since anything like that was true.
> C++ is, like Typescript to Javascript, almost a superset of C except for a few changes that break things.
"Almost" and "few changes" are doing some heavy lifting here. Advertising and insisting incorrectly that C++ is a superset is only doing harm to both languages and causing confusion like the one in the post. It might have been true some 30+ years ago, but let's stop spreading it (outside of historical context) and misinforming others.
Please see:
- https://en.m.wikipedia.org/wiki/Compatibility_of_C_and_C++
Like how can he both write an answer basically saying: c sucks use c++ instead, and also not know the difference between them.
OTOH, it was useful to me, and useful to many others. I answered it 2 years after the original question, so it's highly unlikely the original questioner was still looking for the answer. OTOH, lots of people would get to it through Google, and their question is unlikely to be exactly the same as the original question.
https://stackoverflow.com/questions/1817792/is-there-a-previ...
This answer is blatantly off-topic and should be deleted
uncivil and offensive, even though he admits it wasn't a good answer, and write this post to preach being civil, only to end it with implying the critic resemble someone drinking their own piss.. WTF!?The irony in this post is through the roof
Happens to most people, me too. Someone posted something you think is wrong and hostility ensues.
Some people try to hide the hostility behind superficially respectful words, but the hostility is there.
¯\_(ツ)_/¯
You could write.
“THIS ONLY WORKS ON X VERSION”
Before giving an answer. And people will downvote saying it doesn’t work on Y version.