125

This question basically asks for an alternative to concatenating strings directly in a loop. I couldn't find a duplicate quickly, but I'm sure that this is a standard beginner problem having been asked some thousand times maybe.

The title "how to optimize java-performance?" is not helpful for search, and I guess the situation with other equivalent questions is the same. That's why it gets asked again and again.

I refused to answer it, in order not to spam SO with useless repetitive stuff, but there are already 5 answers, not all of them helpful. I'd like to see such questions go away and have a canonical question mentioning string concatenation in the title, but it's not going to happen as beginners have no idea what part of the code is the culprit.

My questions:

  • Should such questions be answered?
  • Can we get a canonical question for this problem? (maybe edit the title?)
16
  • 29
    Consider editing the question into shape to make it a canonical reference.
    – deceze Mod
    Commented Jun 5, 2015 at 12:38
  • 4
    It doesn't ask for an alternative to concatenating strings in a loop, it asks why the provided code is slow. The answer to that question is "because you are concatenating strings in a loop," the answer to the question you have described is "a string builder." Different questions, different answers.
    – Ant P
    Commented Jun 5, 2015 at 18:23
  • 2
    @AntP sure, but searching the web for "java loop string concatenation slow" gives me String concatenation in Java - when to use +, StringBuilder and concat as first result, in turn linking to the more in-depth StringBuilder vs String concatenation in toString() in Java. You really don't want to repeat those answers.
    – CodeCaster
    Commented Jun 5, 2015 at 18:33
  • @AntP It wasn't me who closed the question as a duplicate, as I couldn't find a fitting original. I wanted close it as "too trivial" (however it translates to the available close reasons), but then changed my mind.
    – maaartinus
    Commented Jun 5, 2015 at 18:34
  • 4
    @CodeCaster that still requires you to have identified that string concatenation is the problem. That's trivial to you and me, but not to someone who has to ask the posted question. Whether or not a question whose only context is "this code is slow" is ever going to be useful again is a different matter...
    – Ant P
    Commented Jun 5, 2015 at 18:34
  • "How to optimize java-performance?" is waaay too broad and should be closed. "What's a faster alternative to concatenating strings directly in a loop in Java?" is a perfectly okay question, unless it's a dup in which case you should close it as one. If there is no suitable duplicate but you feel there are a lot of questions like this one, it might be a good idea create a canonical question.
    – Ajedi32
    Commented Jun 5, 2015 at 18:44
  • 3
    In general, it doesn't matter for purposes of closure that the asker didn't know the questions had the same answer, @AntP. Dupe closure still gets them their solution, and produces a better result for everyone who comes after them too.
    – jscs
    Commented Jun 5, 2015 at 19:20
  • related (not a duplicate): Should one advise on off-topic questions? and Stack Overflow technology makes me write bad answers
    – gnat
    Commented Jun 6, 2015 at 6:28
  • Possible duplicate of Are there questions that are too trivial to answer? Commented Sep 1, 2016 at 23:46
  • @ivan_pozdeev It's not my question what is a duplicate. The other one is both newer and less upvoted.
    – maaartinus
    Commented Sep 1, 2016 at 23:54
  • 2
    Ah, got it mixed up, thought it was the other way round. Well, treat it as "related" then and vote to keep open (if you can). Commented Sep 1, 2016 at 23:58
  • @ivan_pozdeev You should be able to withdraw your close vote. This won't remove the duplicate, but it will give one more opportunity for a "Leave Open" vote to offset the "Close" votes for those that haven't read your comment to understand that the other question should be closed as a duplicate. Commented Sep 2, 2016 at 0:25
  • @MichaelGaskill the criterion for review to complete is actually "3 votes to keep open". OTOH, Data.SE suggests that retracting the vote removed it from review queue entirely (I couldn't find its entry). Commented Sep 2, 2016 at 1:44
  • @ivan_pozdeev Just letting you know that you can retract it to keep from counting your vote as a "Close" vote. I read just yesterday that the retracted vote actually does not remove the item from the review queue, it only retracts your vote. If it had been a flag (which it wasn't), retracting it would also keep you from getting a "disputed" or "declined" flag status. I'll see if I can dig up a suitable reference. Commented Sep 2, 2016 at 1:50
  • 1
    @MichaelGaskill well, I actually searched the database and came up empty. Commented Sep 2, 2016 at 2:12

5 Answers 5

264

A question like this would have been closed in a heartbeat in the olden days. But not anymore, it is hard to close it today.

There's history behind this that's relevant. The two site founders, Jeff Atwood and Joel Spolsky, had very different ideas what kind of questions should be on topic for SO. They talked about it at length in their early pod-casts, they never agreed. Jeff Atwood crystallized his opinion in this blog post, core idea was to keep only questions that are high quality, delete the cruft.

Joel Spolsky however believes that any question is on topic, as long as it hasn't been asked before. He crystallized his opinion in the infamous How to move the turtle in Logo question. Actually deleted by Jeff Atwood (he hated it with a passion) but restored by Tim Post.

When Jeff Atwood left the company in early 2012, Joel Spolsky transformed SO to match his vision. Instrumental were the "Summer of Love" campaign he started 6 months later and the removal of reasons from the close dialog a year later that made it easy to remove sand.

This had a very drastic impact on the site; there's a wholeheckofalot of sand around today and very few pearls to find. SO experienced geometric growth in the Atwood years, which ground to a halt in fall of 2013. Many community experts drastically scaled down their contributions or stopped posting completely. Google no longer ranks SO pages like it used to do. Vampire sites that copy SO content often rank closely or higher.

It did empower more SO users to ask questions; it's much easier now that there's no need for showing research or understanding of the problem. These users are also a voting force: any meta proposal that tries to do something about the flagging quality of Q+A is quickly voted into the ground. Users want a forum, not a wiki.

Turns out that Spolsky was right and Atwood was wrong. Sad, isn't it?

23
  • 107
    The two site founders, Jeff Atwood and Joel Spolsky, had very different ideas what kind of questions should be on topic for SO. I half expected you to end this with Atwood creating a Chamber of Secrets.
    – BSMP
    Commented Jun 5, 2015 at 13:53
  • 43
    Man, this would make a book I'd read.
    – Gimby
    Commented Jun 5, 2015 at 15:21
  • 86
    "Turns out that Spolsky was right and Atwood was wrong." If you had said "Turns out that Atwood was right and Spolsky was wrong" I would have glided right over that sentence. But now I wonder in what way specifically was Spolsky right and Atwood wrong? Atwood seems to have been right about pearls and sand. And if growth is the issue (true for many going concerns) then your statement that "SO experienced geometric growth in the Atwood years, it ground to a halt in fall of 2013" seems to contradict your statement about who is right. Thanks for this answer!! Commented Jun 5, 2015 at 17:58
  • 12
    I guess maybe you mean Spolsky was right in determining "what users want". But even that is not crystal clear to me. Commented Jun 5, 2015 at 18:00
  • 54
    "what user want" - they want you to solve their problems for free, isn't it? They don't want to ask a question in terms of SO and follow their rules, they want you to solve their problems immediately, in the sense of help.
    – Roman C
    Commented Jun 5, 2015 at 18:05
  • 9
    @darenshan First, let's do one thing well; the rest of the internet is awash in forums. Second, if we did have a forum, it would degrade the quality of the Q&A side by being a major drain on the attention of mods and staff. Anyone seeking a forum for SO can find one on reddit, I'm sure. (I'm not a redditor.)
    – Frank
    Commented Jun 5, 2015 at 18:42
  • 3
    I will say this: I went to this question Atwood mentioned in his blog post: [skeptics.stackexchange.com/questions/4498/… and unexpectedly learned some amazing things I never knew about successful torture-free interrogation techniques. So the question proved useful to me at least. I can't think of other popular forums where I've seen such thoughtful answers to mundane or overly broad questions.
    – Andy
    Commented Jun 5, 2015 at 18:58
  • 3
    @Frank i agree with you, but apparently there are 2 group of audience, those who are expert , and beginners!, and it is a good solution to move "Good" beginner Q&A to another place instead of deletion.
    – Hadi
    Commented Jun 5, 2015 at 19:19
  • 4
  • 28
    It takes an expert to properly interpret a beginner question. Knowing how to ask the right question isn't that simple, basic stuff like using the proper terminology and posting a good repro snippet are obstacles. You can't click the MOVE button on an expert, they won't come voluntarily. Commented Jun 6, 2015 at 16:38
  • 7
    Why are we talking about moving questions to a beginners' site? Surely they could be flagged as "pearl" or "sand" (default being "sand", and high-rep users can award "pearl" status) and the consumer could decide which they want to see. Commented Jun 8, 2015 at 0:58
  • 6
    I just read this for the first time, and it really explains the struggle to maintain quality, when quantity (of users) is the true goal. This puts a vast amount of meta posts (both questions and answers) into a new light. Thanks for the explanation! Commented Sep 2, 2016 at 0:50
  • 11
    Just stumbled onto this question and answer. It explains a lot, and makes me very, very sad and discouraged. Sigh. My motivation to participate just went down to near zero. I find it curious that the consensus on Meta is the Atwood model, but without the tools to enforce it the onslaught of crap overwhelms efforts to moderate it. Commented Sep 11, 2016 at 5:51
  • 3
    I have to say, it's not so much that Atwood was wrong and Spolsky was right, it's that Spolsky had free reign to run the site how he wanted. Saying Spolsky was right because of how the site has turned out is a classic case of confirmation bias; the site turned out how it did because Spolsky was in charge.
    – TylerH
    Commented Sep 12, 2016 at 4:51
  • 12
    The really sad part is that when people actually do try to vote down poorly worded or badly researched questions, the response tends to be "you people on SO are *&^% snobs" or some such, instead of "What can I do to improve this question?".
    – Claies
    Commented Sep 12, 2016 at 5:29
34

As long as such answers will be upvoted, there will be incentive to write them. People penalized the asker and there is a chance that he will learn something.

But no one penalized answerers. They all get significant amount of upvotes, basically by doing nothing. So what will it teach them (and other people looking at their answer)? It will teach one thing: just wait for a super simple question asked hundreds of time before, quickly post you answer and gain rep.

So returning to your questions:

  • Should such questions be answered? I think that no, the questions and the answers should be penalized. But this is just my opinion.
  • Can we get a canonical question for this problem? (maybe edit the title?) I highly doubt that this will stop questions like this (yes it will decrease the amount, but as long as there is incentive to answer and no incentive to close people will select the former.
12

One tool remains in the off-topic closure toolbox that can address a lot of these issues:

This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting.

I choose to interpret both "can no longer be reproduced" and "simple typographical error" in the broadest possible light, with my eye firmly on the key point:

While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers.

Whether there are actual answers, or just comments that lead the OP in the right direction, there is no use in having the question around. The most common things I see are

  1. Why does my program do this instead of that? Because you made a mistake. It may not actually have been simple, and wasn't actually a typographical error, but it is highly unlikely that anyone else will both make the same mistake and also find your question.

  2. Why does my program get such-and-such a type error? Well, because you made a mistake. There will be thousands of different programs doing thousands different things that will give you the same error; the next person who comes by will never ever be able to find the duplicate question.

Some tiny fraction of "Why isn't my program working how I want?" will be well enough posed, and get good enough answers, that they actually will be useful in the long term. But we need to be very aggressive about getting rid of the rest of them if anyone is to have a hope of finding those pearls.

1
  • 5
    Voting to close for that reason may be satisfying, and I often use it in exactly the way you describe, but the problem is that it rarely gets four other votes, so it amounts to preaching in the desert.
    – user663031
    Commented Jun 19, 2016 at 13:37
6

You can't stop people answering questions with social reasoning - especially when most people won't read it. Attempting the same thing automatically will never be accurate. If you want to stop people answering questions then there needs to be a manual, technical solution, which is closing.

If you've got a gold badge then you can cut off all new answers instantly by closing it as a duplicate. So, if you're constantly seeing the same question pick one as the target (or create your own) and start voting to close.

In the case when multiple incorrect answers are posted in short order downvote all the wrong answers. That's what it's there for and it won't trigger any serial voting scripts as you're voting on each post rather than an individual.

2
  • 2
    I couldn't find the original fast enough, and the answers came very quickly. Everything what I've found was riddled with unrelated stuff and the solution was non exactly obvious. This partly holds for this question as well. ++ The answers are not really wrong, just sometime imprecise or not really helpful.
    – maaartinus
    Commented Jun 5, 2015 at 12:44
  • 1
    I've got a document in an always-open note-taking application (Notational Velocity) with links to the most common duplicates in my favorite language tag, @maaartinus. It takes me less than five seconds to get the right URL in many cases. I highly recommend something similar to you if you're concerned about this problem.
    – jscs
    Commented Jun 5, 2015 at 19:17
-50

Everyone needs help sometimes. As a beginner in a subject it can be difficult to get solid ground.

Facing a wide open question I personally think that it should be answered with a general open answer.

These people are hoping for expertise and experience. Experience may allow for links to things that are not openly searchable, hard to find, or miss titled/posted. Also quick tips to watch out for and general good/bad practice tips.

Where to start links and links to other stacks here, I imagine, is the correct answer to give; not a complete tutorial/class.

Should you? Yes, if you feel like it.

Is it wrong to ask?
My thoughts are "is it wrong to be a lost beginner with no help or to be simply clueless?"

As I am aware, you can report posts and questions. If you feel it is a direct rule infraction and a person isn't serious about getting an answer. Report it.

9
  • 3
    I have no problem with beginners' questions. All I want is to have one good question with some good answers instead of tons of garbage. At the moment of downvoting I thought it must be easy to find, but I was wrong. With an easy to find canonical answer, this one would get closed as a duplicate and the OP would see a link to good answers.
    – maaartinus
    Commented Jun 5, 2015 at 12:53
  • 25
    Yes, it is wrong to ask if you have not done your homework. Doing your homework means searching and thinking and starting over again and again and detaling your search and thoughts. And Stackoverflow is not really a place for beginners who can't be bothered to do the above. The correct course of action is to close as a dupe as soon as possible. Also, Stackoverflow is not about helping people per se. It is about creating a repository of high-quality questions and answers. Having 300+ duplicates of the same question does not help to achieve that goal.
    – dandan78
    Commented Jun 5, 2015 at 13:53
  • 36
    "is it wrong to be a lost beginner with no help or to be simply clueless?" - What does that have to do with anything? When I was a clueless beginner I studied hard and thought long and deep about the questions I asked. That comes with the territory. Being a beginner is not an excuse to not have to make that extra effort.
    – Gimby
    Commented Jun 5, 2015 at 15:34
  • 4
    "Where to start links and links to other stacks here, I imagine, is the correct answer to give; not a complete tutorial/class." No, no, no; a thousand times "no". "is it wrong to be a lost beginner with no help or to be simply clueless?" No, but it also doesn't create an obligation for SO to mentor you.
    – jscs
    Commented Jun 5, 2015 at 19:14
  • I did too and it was all because I had great help I made it this far. Like I said, "If you feel like it". There is no obligation for anyone to do anything nice for someone else.
    – JSG
    Commented Jun 5, 2015 at 23:12
  • 2
    Yes, people need to do thier homework but sometimes things as simple as being a guide can help immensely. I never said walk someone through their projects for them. Yes if they cant hack it then this is not for them but hey. Some people cant read and duplicating rules is a rule infraction here. As I stated, report it. As I am one of a few who remembers being at the bottom and still appriciate all the help I got.
    – JSG
    Commented Jun 5, 2015 at 23:22
  • 9
    Stack Overflow is not a place for guidance. It's for Questions and Answers. Only. This format does not work for guidance. Commented Jun 6, 2015 at 17:42
  • 4
    I'm just going to leave this here... codereview.stackexchange.com. OK, maybe that's not "guidance" per se, and I'll admit that I have not used that particular site. My point is that SE already tries to shoehorn the Q&A format into things other than "questions" and "answers." No, Stack Overflow is not such a place.
    – Andrew
    Commented Jun 8, 2015 at 1:17
  • 5
    is it wrong to be a lost beginner with no help or to be simply clueless? No. But it's not Stack Overflow's job to serve them - as it is not a University's job to serve someone with middle school knowledge.
    – Pekka
    Commented Nov 20, 2015 at 9:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .