19

Most people know and understand that links to screenshots (or pastebins) of code or error messages are unacceptable in both questions and answers. The rationale is easy: one can simply copy and paste that code/error message directly into the question.

However, I have seen and used links to pastebins in comments. So far, I've only seen this practice in questions about assembly because code, error messages, and debugging efforts tend to have long outputs. Is this acceptable to do? I understand that links to content is generally a bad thing, but on the other hand comments just don't support copy and pasting long pieces of code and error messages.

Examples of questions with pastebin links in the comments: MASM32 program to tell if strings are different or the same, NASM and clang/LLVM generating different object files.

10
  • 23
    Links to content aren't unacceptable because you can write it in the question; they're unacceptable because Link Rot is a thing. At least, that's one of the reasons. Another is that all content shouldn't be accessible only after jumping through hoops to get it.
    – Daedalus
    Commented Sep 19, 2022 at 3:33
  • 10
    Comments should be used to help the OP clarify or improve the focus of the question. They should not be used to provide full or partial answers! Comments can also be used to briefly explain how the info in a dupe target applies to the current question.
    – PM 2Ring
    Commented Sep 19, 2022 at 3:51
  • 2
    Some of us also use comments to indicate the location of the error in questions that are destined to be closed as typos, but not everyone in the community approves of that practice.
    – PM 2Ring
    Commented Sep 19, 2022 at 3:55
  • 6
    There is no cookie cutter rule as per usual, it depends on the link and what it is intended for. Comments have a very specific function on the site (to comment on the post), as long as the link supports that function... fine. The first example is an attempt to answer in comments. Not ideal. The second example though. If I see the edit history, information was edited into the question after it was deemed relevant apparently. So I'd say that is an example of where the link worked.
    – Gimby
    Commented Sep 19, 2022 at 9:25
  • 5
    pastebin is blocked by my companies IT policy so any such links are useless for me when on my work PC. Not sure if that is a common corporate policy. Commented Sep 19, 2022 at 18:36
  • Are you asking if posting information critical to a solution or critical to a question is OK to put behind a link in the comments? Or are you asking just in general? The title seems to ask the general question but your body seems focused on the specific criteria I mentioned first.
    – TylerH
    Commented Sep 20, 2022 at 13:26
  • 1
    @MartinSmith It is the same for me; most file and image hosting/sharing sites are blocked categorically... I imagine any robust company of size will have similar firewall policies in place.
    – TylerH
    Commented Sep 20, 2022 at 13:27
  • 2
    @Gimby: Sometimes when we answer in comments, it's because the question seems trivial and not worth writing a full answer to the usual standards, at least that's my thought process. Or like a placeholder while I look for a duplicate, to point the OP and future readers in the right direction. As for working on some code to the point that it's a working version, I wouldn't usually do that unless it's pretty trivial, and then I'd just describe the change instead of linking it on godbolt.org (certainly not pastebin for me.) Commented Sep 20, 2022 at 13:47
  • @PeterCordes The pull to use comments for which they are not intended is indeed very strong and hard to resist.
    – Gimby
    Commented Sep 20, 2022 at 14:04
  • 2
    It honestly completely depends on the question for me. Say the question is clearly a duplicate, but formulated in a such a way that it's highly likely that OP is a beginner and most likely wouldn't understand the answer(s) given in the duplicate question, I'd obviously mark the question as a duplicate, but also pass a fiddle in the comments to teach them how it would work in their specific situation. That way the question is handled properly on SO and OP is helped out with their problem at the same time.
    – icecub
    Commented Sep 21, 2022 at 8:27

2 Answers 2

30

Yes, links to any online compiler, fiddle, documentation or similar content are fine in the comments because there is no requirement for comments to be self-contained (unlike questions and answers).

Ideally comments are about improving and clarifying the question or answer. I.e. it is pretty common to see comment like "here is online compiler for version X of language Y showing your code to work/fail unlike your question/answer says. Please check versions/code" - the expectation that post is updated with requested information and the comment is flagged "No Longer Needed" by whoever updated the post.

The comments you refer in the question look like partial answers - this is not really recommended, but some people do that anyway (Answerers who only use comments). It is perfectly fine to convert such a comment into an answer (Question with no answers, but issue solved in the comments (or extended in chat)) and mark original comment NLN. It is also ok to include the link from the comment as long as all necessary information is in the answer (and visiting the link is optional).

One unfortunate part of providing code in comments via a link to an external site is that the code can't usually be copied to SO by other people due to license. If you are considering to just link a code in the comment then prefer to actually provide answer yourself as you can copy-paste your own code under SO's CC BY-SA license as part of the answer (while others would have to write similar code again).

2
  • Often times, the links to the online fiddle, or compiler are too long for comments. Is there an official approved way to shorten the link for comments?
    – IcyIcicle
    Commented Sep 21, 2022 at 15:10
  • @IcyIcicle I don't believe there is an official way to shorten links and using public link shorteners is actively discouraged. See if sites you are using offer a way to create link that does not include whole code in the link. Commented Sep 21, 2022 at 16:45
7

The problems with links is that they are links, meaning here path to external content. And that external content could vanish, or may be inaccessible to some users (because of corporate firewall policies), the latter being a high chance for sites like pastebin.

Ideally links should only be used to add reference material. For example a comment providing a link to a reference documentation is acceptable:

  • either the question is not trivial and the link can later be used to build a correct answer
  • or the question is trivial and the comment just means RTFM (ideally OP should then delete their question)

Links to code (godbolt.org or consors) should be seen the same:

  • in an exploratory phase they can be an illustration of how things work using a specific computer version - fine in a comment but they are supposed to be followed with an answer of a request to close/delete
  • in a question or an answer requiring a lot of code, or large data, they can be a complement. The post should contain just enough code or data to be intelligible and other users can download the full set if they want to.

Said differently my opinion is that your question cannot be answered out of context. What matters is the goal:

  • if the link to code is intented to demonstrate something in an exploratory phase, all is good: that is what comments are intended for
  • if it is a way to provide an answer circumventing the site policies, then it is not acceptable. The reason is not for containing a link to code but for being an attempt to answer in comment.

You must log in to answer this question.

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