0

Services like TIO allow you to create runnable examples in a wide variety of languages. In this answer of mine, I used TIO to give a working example of what OP wanted, instead of just providing code for them to copy/paste it.

Should such behaviour be encouraged? Or is it considered just a fancy toy with limited practical use?

7
  • 2
    Encouraged? Not necessarily. That many times is very good thing? Indeed.
    – yivi
    Jan 7, 2018 at 14:25
  • 1
    I'd say: yes for questions (because it saves time for the people trying to run and debug it), not really for answers (because the answerer should have verified the code works as intended, and there's not much to see).
    – Erik A
    Jan 7, 2018 at 14:32
  • 1
    @ErikvonAsmuth I'd say it depends on the question. If the question is formed like "How can I...?", then a runnable example might illustrate a point. If the question is formed like "Why is this not acting like expected?", then a runnable example is not really necessary
    – MechMK1
    Jan 7, 2018 at 14:33
  • @ErikvonAsmuth for questions, it's important to be able to stay without the link, see Should a question that is meaningless without viewing an external link be closed?
    – gnat
    Jan 7, 2018 at 15:12
  • 2
    @gnat I imagined this was obvious (since it's even enforced for jsfiddle and such), but if you use TIO, always provide the full code in the question/answer text as well!
    – Erik A
    Jan 7, 2018 at 15:15
  • @gnat If you look at my linked example, you will see that I indeed provide the full sourcecode for the answer itself. The difference is that I also provide a TIO link, which allows the user (and others) to see the example in action
    – MechMK1
    Jan 7, 2018 at 15:20
  • 2
    But your question is: should including such links be encouraged? I do not think so. Answers should be self-contained. Supporting links are great, but they should be there only to support the answer. No more, no less.
    – yivi
    Jan 7, 2018 at 15:31

1 Answer 1

1

It depends. As long as you post your code on the site as well because sites like the one you listed generally set an expiry date (like a year or so), after that they delete the code and you can't use it. Stack Overflow keeps all the "good" answers for not only the asker but also future visitors. These visitors may still be looking at that answer years later and if the TIO has expired (or closed/moved) the link you gave will no longer be valid and you will be decreasing the quality of your answer.

Second also remember that links aren't always convenient. It can be frustrating clicking links and a programmer will probably also be able to "see" what will happen without running it.

Is it recommendable? I would say no at this point but you can always allow other to do this and see without "recommending" if the trend catches on. In the future however I do hope something like this is introduced into the site as this would indeed be a useful feature.

You must log in to answer this question.

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