8

While reviewing new questions, should we convert code snippets to code blocks for unsupported languages (e.g. python)?

I've seen a number of posts suggesting that snippets shouldn't be used for server-side code, but does its use warrant an edit on its own?

7
  • 8
    What is the value of having a runnable snippet that cannot run? Nothing. Remove them. I also tend to remove JS runnable snippets into non-runnable blocks if all they just throw an error and it's not OP's reported problem (incomplete snippet).
    – VLAZ
    Commented Jun 3, 2020 at 6:34
  • 2
    I've noticed some users actively edit non-runnable code into stack snippets. It would be awesome to have a policy for this.
    – Scratte
    Commented Jun 3, 2020 at 6:46
  • IMO we should push S.O. to support more languages. Either on their own or by partnering with some service that already does this. Example
    – user128511
    Commented Jun 3, 2020 at 7:15
  • @Scratte We do. There is a long-standing policy to reject harmful or superfluous edits.
    – Cody Gray Mod
    Commented Jun 3, 2020 at 9:43
  • @CodyGray The ones I have noticed come from a high-reputation user.
    – Scratte
    Commented Jun 3, 2020 at 9:44
  • 1
    There is a use for having non-JS/HTML/CSS in a snippet. Snippets allow you to have the code in the snippet shown hidden by default. The OP may have wanted to use the capability to have large blocks of code as click-to-view in order to make the post flow a bit easier, but give readers the opportunity to see more extensive examples, if the reader chooses. Other than that potential use, I agree that it doesn't make much sense to have non-JS/HTML/CSS languages in a snippet. I'd note that it's much more likely the OP using a snippet is a mistake/misunderstanding, rather than intentional.
    – Makyen Mod
    Commented Jun 3, 2020 at 10:39
  • 1
    High-reputation users aren't immune from making mistakes, @Scratte, and certainly not from misunderstanding how the site's features work. If you see a pattern of someone with full edit privileges making harmful or superfluous edits, collect a list and raise a moderator flag. There is absolutely no reason to create a Stack Snippet for a code sample in a language not supported by Stack Snippets. They're only for HTML/CSS/JS.
    – Cody Gray Mod
    Commented Jun 4, 2020 at 0:56

1 Answer 1

8

I think that a post using a Stack Snippet for something other than HTML/CSS/JavaScript very likely has other problems if it hasn't had any edits made to it yet. So if you're looking to fix that problem, see if there's anything else you can improve: grammar, other formatting issues, improving the title or tags, etc.

If there's genuinely nothing else (or very little) that can be improved then an edit suggesting this should be approved. It's not as big of a problem as code not being formatted at all, but it is wrong to have non-runnable code in a runnable snippet.

However, if there's a lot or something major still wrong with a post and that's the only thing you fix then you risk a reviewer using "Reject and Edit" instead of "Improve Edit" in order to bring your attention to something you should have fixed.

You must log in to answer this question.

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