Possible Duplicate:
Feature allowing SO to execute code snippets in a sandbox and produce useful results

The code we look at and work with on SO is so "dead". Answerer's can scan it over with their eye's, but it's not natural. Answerer's can copy it into an IDE to bring it to life, but this is not effecient.

OP's should be allowed to updload a method that can be executed within a selectable context (E.G a console app). Give the method a common name so it will hook and execute. Imagine template pattern. If one participates in TopCoder its quite similar. OP's should be allowed to specify their own secure template that can't be seen by answerers. This should be a special case as it requires some knowledge and coding to implement. Second, custom template upload is a special case because people should learn to reduce the problem down to a simple compileable example first. Answerer's should be able to modify the method hook and propose it as a unique solution.

This not only allows answerer's to be more effecient and more natural, but it encourages iterative improvement and works the same way that we normally perform our daily development tasks. A debugger will print error messages.

I'm speaking in terms of .NET, but this could apply to other frameworks/languages.

  • -1's no comment. lol jump on the downvote boat. I have seen no one offer me a reasonable explanation for why this would not improve quality. Commented Dec 31, 2010 at 0:15
  • Duplicate: Feature allowing SO to execute code snippets in a sandbox and produce useful results. I knew I'd seen this before. Commented Dec 31, 2010 at 0:19
  • @P.Brian downvotes have a different meaning on Meta; here, they are simply a sign of disagreement.
    – Pekka
    Commented Dec 31, 2010 at 1:27
  • I think the author means he'd like the equivalent of jsfiddle for other languages as well.
    – wildpeaks
    Commented Dec 31, 2010 at 1:39
  • 1
    @Pekka Don't downvotes mean disagreement on the other SE sites as well ?
    – wildpeaks
    Commented Dec 31, 2010 at 1:39
  • 4
    @user the distinction here is "I disagree with this suggestions" as opposed to "this question is ill-posed or unhelpful". Downvoter's here may think that it is a good topic to discuss and well stated and simply want the suggested change to not happen. Commented Dec 31, 2010 at 3:53

4 Answers 4


99% of the code snippets I see on SO aren't executable, and therefore this wouldn't work in any case. If you need something like this, that's what codepad.org is for.

  • That's a false conclusion based on partial information. The fact that the code is "dead" to start with encourages posting partial and/or syntactically incorrect code. I don't buy that people can't post code that compiles nor that it won't improve quality. Also, it's the answerer's job to fix the code not the poster's so its irrelavent. Commented Dec 30, 2010 at 23:52
  • 5
    That comment is utter nonsense. Breathing life into code is a programmer's first and foremost job. Answerers don't have a job, they have a hobby. You got the job, you are getting paid to do it. Commented Dec 31, 2010 at 0:30
  • I always hate how codepad compiles code by default, since most of my snippets don't compile. (Besides that it's an amazing website) Commented Dec 31, 2010 at 1:00
  • 1
    +1 for codepad. That's awesome!
    – John
    Commented Jan 2, 2011 at 3:39

I don't think this is possible at all. Creating execution environments for dozens of platforms and languages would be a huge technical effort - enough to keep a good team busy for a year. And it would add security issues and complications galore, both on the server and on the client side.

This is a job for individual third party sites that provide "workbenches" for code snippets. JSFiddle already does that job very nicely in the HTML / JS / CSS tags.

  • I realize there will be security concerns, but if we could dismiss improvement on the basis on technical issues we'd all be out of a job. Second, there's already a precedent. TopCoder implements a similar model already. Just off the top of my head I can imagine this being run within the context of a VM. Some colleges let people do whatever they want to a computer, but upon logoff everything is reset back to an image. Commented Dec 30, 2010 at 23:56
  • 1
    @P.Brian Don't get me wrong: This would be a great thing to have, no doubt, and it would be a worthy task for a good team. But I don't think you are fully appreciating the mind-boggling complexity this would entail, and the vast amount of resources it would bind.
    – Pekka
    Commented Dec 30, 2010 at 23:59
  • @P.Brian re your update true, this could surely be done in the context of a VM, but don't forget SO has 4.5 million visitors a month (or something like that). You would have to be able to serve them all, 24 hours a day. The infrastructure necessary for that is going to be expensive. This really is a job for individual services offering the functionality for one specific platform I think
    – Pekka
    Commented Dec 31, 2010 at 0:08
  • @Pekka I do realize this is a big change, but its not impossible. Even with 4.5 million hits/month certainly only a small % are actually posting questions at any given point in time. Sure, there will be more active answerer's as people will find the site more useful. Of course its mind boggling to fully support 100% of languages and platforms at once. We shouldn't negate the possibility of incremental updates. Support C# .NET 3.5, then C++, etc...this is what I had in mind to start with. Commented Dec 31, 2010 at 0:08
  • @P.Brian as said, it would be nice, but I can't see this being implemented by SO. As an idea for a start-up or a Open Source project, it would be lovely though
    – Pekka
    Commented Dec 31, 2010 at 0:14
  • @Pekka ideone.com already does the job, although it might not scale to SO's usage levels.
    – moinudin
    Commented Dec 31, 2010 at 0:42

Although if this was possible it would be handy, but rarely used. The problem with many questions is that when the poster includes code it is either too much, too little, not compilable, or not the actual code they are having the problem with. In the small percentage of the time that code include is good and short, the problem can be identified with just reading it.

Secondly identifying the cause of the problem is really just a preliminary step in the direction of the root question of why does x work this way? or why should I not do x?

  • Have you read the kind of code that gets posted most of the time? Do you really want to see enough more of it to actually get it to do something?

  • Have you taken note of the number of different platforms that are represented? How many do you think can be supported?

  • Do you really want to hand every coder on the internet another way to run code on your box?

and finally

  • Do you really want to make it easier for our average poster to get along without ever learning anything about debugging?

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