# Do we want Stack Snippets?

A new feature called Stack Snippets was introduced that allows users to embed runnable code snippets in their posts. According to the blog post:

If you feel that a particular site should have Stack Snippets, post a feature-request on that site’s meta – if there’s support from the community there, we’ll enable them.

Well, I think Stack Snippets would be pretty great here, for several reasons:

• Other users can run and test submissions directly from their browser, without even having to click another link
• Test cases can be embedded naturally into posts, to verify that the code works properly
• We could hide very long ungolfed commentated snippets within collapsed Stack Snippet blocks, so that people who want to see how everything works could, while the answer wouldn't get too long

Finally, here's an example of Stack Snippets in action. (Note that you can make them non-collapsed by default, so you can still see the code.) Try it out here!

And when expanded:

• I like it, but it'd be even better if it supported GolfScript! ;-) – Chris Jester-Young Sep 16 '14 at 21:23
• @ChrisJester-Young Technically, that could be possible if Ruby was supported, and "[w]e don’t have any specific plans at this time to implement other languages, but it’s something we might consider in the future." So that's not too inconceivable of an idea! :) – Doorknob Sep 16 '14 at 21:25
• I actually want to port the GS interpreter to JS. Then Ruby isn't necessary. (Double-quoted strings will eval JS expressions rather than Ruby ones, however.) – Chris Jester-Young Sep 16 '14 at 21:27
• As long as they don't implement more languages, this is going to encourage JS-only challenges, but generally I think it would be very useful here. – Martin Ender Sep 17 '14 at 7:28
• I am in full favor of this. It would have helped a lot in this question. – Calvin's Hobbies Sep 17 '14 at 22:48
• Now related: codegolf.stackexchange.com/questions/40073/… – Calvin's Hobbies Oct 21 '14 at 2:49

For a site that doesn't tend to go in much for language-specific puzzles, JavaScript is doing pretty well here. In light of that, I see no reason to not enable this - enjoy!

hello world!

### Yes

I see a couple potential issues, but nothing that's a deal breaker.

Crazy-inefficient code

Some snippets posted here (especially for golf) have insane runtimes, memory needs, etc. At the least, we should encourage users to mention this if what they're posting will use an inordinant amount of time/resources. (they should probably do this anyway, but I see it as more important if running it is a single click away).

The same could be said about anything potentially malicious, although I see a lot less of that in general.

Voting for pretty/easy

Pretty pictures get you votes, I think we can all agree on that. One-click runnable code would probably also get you votes, if only because people can immediately see output and verify it's correct. That's not really a problem, except that it's limited by language. Should JS answers have an advantage because the output is so accessible? Is that advantage large enough to worry about? I don't know yet, but it's a possibility.

So like I said, nothing that I consider a deal breaker right now, just things to ponder. On the whole, I think it would be a good addition. Even more so if there were more languages available (but I'm not holding my breath for that).

• Inefficiency can be solved by implementing a timeout, but that would depend on the answerer being bothered, I guess. – Sp3000 Oct 24 '14 at 12:40