21

I follow a lot of Javascript questions, and whenever the 'Promise' tag comes up, I'd give it an 80% chance that the OP simply does not understand how promises work.

It's very easy to find examples of this. Common patterns are:

  • Nested new Promise() calls.
  • Nested then() calls where they are unneeded.
  • And the biggest red flag: Not getting that what happens in then() is asynchronous, so writing a function that uses promises means that the result of that function also needs to be a promise.

Luckily, for most of these questions there are people that take the time to help answer with the specific issue.

However, all these really fall into a common category. If a member of my team would have questions like it, I would probably want them to first go out and read up on the subject before continuing. Promises really seem like such a fundamental part of modern Javascript, that (to me) it kinda falls into a category of knowledge that you really should just have before continuing.

Is this the type of thing that would be worth having a canned or community answer for? Questions might all be slightly dissimilar but a sane answer always is 'learn promises, then come back if you're stuck' (but more politely/encouraging).

10
  • 1
    What's the goal? Close them as duplicates of the "learn promises" question? There's already lots of answers about promises with good information on what they are and how they work. If the user doesn't find those helpful how is this one going to help?
    – Clint
    May 31, 2018 at 1:37
  • I honestly don't 100% know. Maybe it's fine to continue to answer the on-eoffs, but I just see so many of them and couldn't help wondering if there's a better way to answer these. Maybe there isn't
    – Evert
    May 31, 2018 at 4:48
  • 11
    This indeed sounds like a situation that requires a canonical to dupe link to, which may need to be created first if the knowledge is currently spread out over several questions and answers. I'm not the biggest fan of canonicals as they're a little too easy to dupe link to, but on the other hand I'm even less of a fan of topics that are a tough nut to crack, like promises, to flood the site with many poorly asked duplicate questions that are hard to close.
    – Gimby
    May 31, 2018 at 8:26
  • 5
    It should be noted that virtually every specialized topic in SO gets a fair number of "they clearly don't get it" questions from inexperienced developers; this is not unique to the topic of promises. Avoiding condescending and dismissive answers is part of keeping [making again?] this site a friendly neighborhood for newcomers. Jun 1, 2018 at 1:43
  • They don't have to know about variable scope, the don't have to know about arrays, they don't have to know objects ... they don't have to know ... well ... anything, not even the name of the language they are using. Why would you expect them to know the concept of promises ..?
    – Teemu
    Jun 1, 2018 at 11:21
  • 2
    time to start aggressively promoting async
    – user5940189
    Jun 1, 2018 at 11:32
  • 6
    I'll come to Async Party as soon as the war against JSON objects is over ...
    – Teemu
    Jun 1, 2018 at 11:34
  • @Orangesandlemons disagree, async is nice and I'm glad it exists but it's a very leaky abstraction. People will still misuse it and come here confused when their code doesn't work. Jun 1, 2018 at 12:01
  • I wish Documentation had worked out... it would have been great as a FAQ for answers just like this instead of duping questions to another question with 50 answers that are all over the place. We can't "be Wikipedia" if we can't get dups under control by having a single source of knowledge on a topic.
    – JeffC
    Jun 2, 2018 at 14:48
  • For promises nested inside new Promise, we have a canonical about the Promise constructor antipattern (and I use canned comments in every second [promise] question)
    – Bergi
    Jun 2, 2018 at 17:52

3 Answers 3

13

TL;DR

I don't think this needs a canonical dupe target, and if it does this one is probably sufficient.

Longer version

Concurrency is hard. Closing questions as dupes of some question that we know answers the question but in no way helps the question writer is aggressive and abrasive. I am the first person to lob a RTFM grenade when it's richly deserved, but this is not that case. Promises are a not beginner-friendly concept woven throughout a language that is, for some reason, frequently marketed to beginners (I suspect that's a carry-over from days when web pages were largely static documents with a hint of JS seasoning).

Bottom line, people are going to flood the site with questions about Promises because the concept is intrinsically hard and that isn't going to change. We can either help those people as we're able, or we can kill it with fire, but I for one am willing to cut some slack to people on this one.

10
  • 5
    Thanks. One of the most infuriating things as a new user to S/O is being shut down and redirected to a "duplicate", but as a beginner in whatever you're looking at, the "duplicate" is probably one you've already studied and couldn't wrap your head around (and then getting a "your account may be closed for asking poor questions" notice if you do it too much! Talk about salt in the wound). S/O is tough like that... I think this goes well in line with the recent "let's be nicer to people" approach as well... fwiw
    – jleach
    Jun 2, 2018 at 15:20
  • 1
    @jleach: You don't get banned for one bad question, so you have the chance to try again, explaining in more detail what you do understand and where you're having trouble making sense of something. This is basically necessary for a "help me understand" question to be good, and not be a duplicate of a canonical. Jun 2, 2018 at 15:48
  • @PeterCordes - correct that you don't get banned for one bad question, but as a new user trying to not put your foot wrong with S/O's very strict requirements, it's pretty easy to get your foot in the mud while you're getting used to how to handle asking at S/O. Prior to hitting a 1k rep mark I probably had four or five notices of that kind, and I'm a 5-year Microsoft MVP that has a lot of prior experience in other venues on how to ask good questions, etc. It's a very difficult site for new users: I have many colleagues that don't bother participating here because of it.
    – jleach
    Jun 2, 2018 at 16:27
  • (I should add that I understand there is a balance to be held: S/O is the greatest QnA site that ever was, which is most likely highly attributed to the fact that they're very strict about this stuff... I don't claim to know where the correct balance is, but nevertheless, as a new initiate, learning how to participate at S/O as harder than some programming languages I've had to learn!)
    – jleach
    Jun 2, 2018 at 16:31
  • JavaScript is marketed to beginners because it is literally the easiest way to get into programming.
    – user4639281
    Jun 2, 2018 at 16:50
  • 1
    @TinyGiant depends on what you mean. If you mean "shortest path to being able to do something that your friends will be impressed by" then quite possibly yes. Needs far less knowledge/tooling than, say, building a smartphone app. But there are two hurdles that you don't run into by starting with e.g. Python: client/server dichotomy and asynchronicity. Those eventually come up in other languages, but it's hard to get anything 'cool' done in JS without understanding them. If we think the flood of Promise questions is bad, just look at the flood of "access PHP/JS variable in the other" questions. Jun 2, 2018 at 18:24
  • 1
    I meant it's the easiest programming language to get started in. You can have a JavaScript program up and running far faster than pretty well anything else. All you need is a browser with a console, which is any modern browser.
    – user4639281
    Jun 2, 2018 at 18:32
  • There's also Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference which I think makes more sense as a dupe to people logging the variable immediate after running an async function and getting undefined. Jun 2, 2018 at 18:53
  • If you try to close all vaguely similar questions as duplicates without adding any info, rather than letting people try and help the individual, wouldn't the questions just change to "why isn't my case working like [link to canonical]?" Given how often I see closing questions as duplicates occur when my experience shows that they really aren't, can I ask: do moderators get points for closing "duplicates", and do people closing as duplicates have to show any technical understanding of the topic, or can any moderator do it?
    – simpleuser
    Jun 28, 2018 at 21:02
  • @simpleuser don't have to be a moderator. If you have sufficient rep (3000? 5000? can't remember) you can vote to close for any reason and 5 such votes will close the question. People with a gold badge in a tag the question is tagged as can insta-close it as a duplicate. As for them not being dupes, the issue isn't that they aren't (they are) the issue is that the OP won't understand the answers to the dupe question. Jun 28, 2018 at 23:49
5

The more questions get asked about a specific topic (currently 7K questions about Javascript and asynchronous), the higher the chances that some are duplicates.

Finding valid duplicate targets is work, answering questions too. A too general, canonical duplicate target might result in people argueing that their specific question isn't a full duplicate (and maybe quite rightly in some cases). On the other hand, it seems like we always have someone willing to answer such repeated questions. This clutters the site.

It's always good to have canonical questions and answers in a topic if only because studying these would be part of a research before the creation of any question. A lack of research might result in downvotes.

All in all, I would prefer if these canonical questions and answers of very high quality existed and askers would at least be referred to them. The duplicate closing should happen as usual.

4

Yes, just write it

Ignore the naysayers and write an awesome Q/A that would help solve the problem you've noticed about JavaScript Promises questions. (I'm ignoring the naysayers because I feel encouraging you to go for it is more important than nick-picking meta concerns.)

If you meet a need, it'll rise in popularity naturally, and you'll help a lot of people. And for that, you need no one's permission. Just write it. I look forward to reading it.

You must log in to answer this question.

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