72 comments

[ 3.2 ms ] story [ 135 ms ] thread
Ah good old toxic site: StackOverflow.

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.

And then you get a notification that XXX has rewritten your answer for reason YYY.
I've got one of those too! It doesn't answer the question to the extent that it's fair to call it wrong, it's trivial, requires Javascript for a CSS question, and probably other complaints. It's too bad it doesn't show number of upvotes and downvotes because that "+80" is hiding a lot of downvotes!

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...

That last image is really something. I will remember it.
Yup. It is worthy of a meme, all by itself.
Is there a name for this feeling of wanting to know more, even knowing that you will be horrified regardless of the answer? Morbid curiosity seems insufficient.

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.

There were worse, in the days of UseNet.

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.

You know there's a reddit dedicated to your last sentences last clause, with movies, right? As in, people probably monetise this with patreon.
there probably is such a subreddit (likely a fetish), but just like a lot of viral posts, there's no proof that the thing actually happened, but there is a market for making viral posts. It makes people feel popular, and high-karma accounts can be sold to advertisers and political groups who manipulate social media.
Yeah I think it's a copypasta. I've seen it elsewhere with the details slightly different.
There is at least one MMA fighter who practices that therapy: https://www.mixedmartialarts.com/ufc/machida-explains-the-be...
Wow those interview responses are just… utterly inane. “I drink it because i drink it, it’s good for you because it’s healthy, i started drinking it because my dad said it was good for me, it helps me by being healthy and by being good for me” - like it’s all a completely pointless circular recitation of beliefs, no reasoning at all.
They didn't link to the actual meta thread, but I don't see any anger in the stackoverflow comments. If the answer is just objectively bad (for example, it answers a question that wasn't asked), it ought to be deleted, that's just basic moderation.

And of course c++ and c aren't the same language.

I don't understand. In the Meta the answer is used as an example of something that never gets deleted by the system. I don't see any anger about it -- just a discussion of a defect in the Stack Overflow system where unhelpful answers never get pruned.
And I’m curious how else SO should handle poor answers like that. Are they just supposed to leave bad answers like that up? Especially when OP admits they don’t actually understand the topic well and isn’t interested in fixing it?
In this case it seems to help about 50% of the people that see it?

Possibly more, since the downvoters are probably just triggered.

Meanwhile on some other programming forum, you ask a question about C, you only get answers about C++. SO is right to put minimal effort into preventing that happening. But they put maximal effort into it instead.
Correct them?

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.

There are tons of answers on that question already. Correcting it would just be duplicating one of the others…
I think what people are getting bent out of shape about is the answer isn’t incorrect, but it defies their sense of order because it’s a cpp answer without a cpp tag.
He basically answered that the correct way to find the length of an array in c is to use c++ not c. I don't think there is any way to correct that answer, and responding to a question of how do i do X in C with "use C++ instead", is kind of obnoxious.
Tangential, this note from the other answers confuses me as somebody who has no real C experience:

> 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?

You're being confused by one of the parts of C that is difficult for beginners to wrap their heads around, and is a trap from the unwary.

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.

> 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])).

Dereferencing just gets whatever the value is of that data type that is at the memory location in the pointer. That memory location is all the data that is in that pointer, all other data on how to use it is in the compiled-in type. the length isn't stored unless you manually store it.
sizeof() is evaluated at compile time: https://stackoverflow.com/questions/671790/how-does-sizeof-d...

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.

Yeah, it's a pointer which may happen to be a pointer to the start of an array ... or some other element of the array, or a different variable of the same type (the type of the element), or a variable of a different type coerced into being passed as the right type. The compiler doesn't know or care! Do what you like! Hence it can't tell you the size of the thing because the thing could be anything and could have come from anywhere.
Wow, that's new to me! Like a macro in languages I'm used to, but smarter. This is key in contextualizing the "it's a pointer" part of the explanation. It sounds like the size of an array is never intrinsic to it, as a data type, regardless of whether what we've got is a pointer. What's important is that sizeof is compile-time, so it can only know the array size in contexts where it can be determined at compile time.
Yep, that’s correct. The entire data structure of a C array, as available to the running code, is a pointer to the first element. The compiler has that information during compilation but it doesn’t make it trough to the resulting executable.
Except, not always. For VLAs runtime is involved.

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 }

If array is an array of `N` `T`s (`T array[N]`), then `sizeof array` is `N * sizeof(T)`.

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*)`.

Pointers just point to an address in memory. It could point to a single structure or variable, but it also became a standard in C to use pointers to point to the start of an array. When used like this, you have to either agree what the end of an array looks like (e.g. '\00' for end of char array aka string), or manually forward the size of the array to a function, e.g. void do_something(int *numbers, size_t number_count). Accessing elements of the array like numbers[5] is effectively just a nice shorthand for dereferencing (numbers + 5 * sizeof(int)), there is no bounds checking and you can access bad memory with a bad index.

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

It was known that this was dumb and annoying around the time C was designed. Ada had the equivalent of std::span as the default for passing arrays in 1982 and I'm sure earlier languages had it before C was even conceived.
Surprisingly, I don't think I've ever drawn the ire of Stack Overflow, despite its reputation. I don't know my most downvoted answer, but the lowest score I have on an answer is -1, and it's just because the answer was bad.

That said, drawing the ire of people on Hacker News is extremely easy, and I do that periodically.

tempted to down vote, just because you dared us to.
Welcome to Karma Club. The first rule of Karma Club is: you do not talk about Karma Club. [With apologies to Chuck Palahniuk]
Here's the recipe.

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 OK, they give you this number called "karma" which is like credit that you can spend on annoying people.
> Surprisingly, I don't think I've ever drawn the ire of Stack Overflow, despite its reputation.

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 think most of my answers have been left alone, but I've had a few valid questions that have been dumped on because... I don't know? I guess people skimmed my question and assumed it was something was easy to search, therefore I'm a moron.
(comment deleted)
> Apparently, I stepped (through time and space) right into one of the most fiery subjects on SO (a site not known for calm and respectable discourse at the best of times):

> 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."

Really, to be fair in this case it's more like "are Javascript and Typescript different languages though" seeing as C++ is, like Typescript to Javascript, almost a superset of C except for a few changes that break things.
In case of TS vs JS it's well advertised that:

> 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++

- https://www.stroustrup.com/bs_faq.html#C-is-subset

It also doesn't make sense because his answer basically told people to stop using c and use c++ instead.

Like how can he both write an answer basically saying: c sucks use c++ instead, and also not know the difference between them.

This is excellent marketing material for LLMs!
I think this might be satire but can’t quite tell…

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.

I think "totally different" is not an entirely fair characterization of a commonly used superset.
As a daily user and occasional language-lawyer of many C++ features: your perfectly reasonable understanding of the practical relationship between the two ("C++ is a superset of C") deeply irritates a certain type of highly pedantic language nerd, who feels compelled to point out that C is not in fact a subset of C++ and that your opinion is therefore invalid.
Which is hilarious because I've interacted with people working in some extremely deep in-the-weeds C++ code describe their company's coding standard as "oh its just C with classes" heheh.
Try initializing a sparse const array (in .rodata) in C++. It's easy-peasy with C's designated array initializers. With C++, the best you can do is a monstrosity with a constexpr lambda filling out a std::array.
I dont really think it matters if its totally different or sort of different. Their answer either works or it doesn't in the programming language being asked about.
Can't help but feel there is a lot of ego in this post.

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.

(author here): on the contrary, my point is that I was wrong(ish), and I often think about that before I get angry at other people on the internet.

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.

> "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"?

well yes! also calling an answer which mentions c++ as well “off-topic”, it’s not like I wrote a haiku about marmalade.

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.

I'm not involved in this in any way, so I can't definitely say why. But maybe I can share some points:

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

I found this blog post a bit confusing. The classic pattern sizeof(a)/sizeof(a[0]) works perfectly in C and C++. Did he claim this wasn't the case? Or maybe he tagged it as C or C++ but not both? (A much more minor sin). Or maybe something else? I found it impossible to parse.
Arrays in C are often passed around as pointers to the first element, in which case you can no longer get a correct answer with this pattern. This is the most common scenario where it stops to apply.

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.

Yes I know. I've been coding in C for 40 years and C++ for 30 years. It's a simple technique that applies in particular, rather simple, situations with both languages.

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?

I don't get it either. From sibling comments here I think that it's the fact the bulk of his answer was about C++ while the question was about C. But he noted that in his answer and separated the cases, so I don't see what was all the fuss about. It's certainly not a really bad answer, like that Lundin guy says in the comments.

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.

> But I was just starting out, and if someone wrote that my answer was so bad that “there’s little hope to delete-vote it”, I would probably be super sad.

I don't understand. "There's little hope to delete-vote" means it isn't very bad!

So the author finds objective comments like:

  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

Personally, I find the word "blatantly" very rude and uncivil as well. It might be a language/culture thing though, since you obviously don't.
"Someone is wrong on the internet".

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.

¯\_(ツ)_/¯