17

The vast majority of questions on Stack Overflow come with a specific language tag and no post in the tag will contain any language other than that specified language.

However, for some questions are more about a library or framework which might be used by multiple languages. Ultimately, the question is about the library or framework and is not at all related to the specific language the asker happens to be using at all.

For example, a user might ask a question about some aspect of .NET, and while they'll tag it with because that's what they're writing in, absolutely everything in the question as well as everything in any posted answer could apply exactly equally to . The same thing can be true for many or questions which will just happen to get either the or tag.

And sometimes, these language may appropriately omit the language specific tag even.

But just because the question isn't about a specific language doesn't mean I might not want to include a code snippet in my answer. For example, this answer, this answer, and this question.

Unfortunately, doing this can mean taking up a decent chunk of vertical space.

I would like it if Stack Overflow posts could provide some means of stacking these equivalent snippets in a manner perhaps similar to what Microsoft uses on their Developer Network page or like the NSHipster blog uses:

enter image description here enter image description here

The code snippets across the tabs are equivalent, but they are each written in a different language.

Having this feature for Stack Overflow posts would make posts containing duplicated snippets (for the sake of completeness) more readable.

It may also perhaps encourage users to write more complete answers (or edit answers into more completeness) by using this feature.

11
  • 2
    I bet that feature will be abused for stacking all the files in a project on top of each other really fast. Making it impossible makes the feature much harder and less useful... May 21, 2015 at 22:04
  • 4
    There's already a character limit for posts. This wouldn't change that (and it would likely take away a handful of characters to actually force your code into these tabs).
    – nhgrif
    May 21, 2015 at 22:09
  • Is this only a problem with Objective-C and Swift? if so, will it not become redundant as Objective-C fades away?
    – GPPK
    May 22, 2015 at 8:36
  • 3
    @GPPK it's also often relevant with C# and VB.NET, and it could be useful for showing different dialects of SQL. I've also seen questions where it's the algorithm that's important, so it'd be nice to show it in multiple languages. For example, someone is writing a program that has server and client components, and the operation could be done in either. Or, they're using a managed language with native interop (eg. P/Invoke to call C++ from C# code). Or even showing the difference between doing something in an ASP.NET controller vs. the Razor syntax for doing it in the view. May 22, 2015 at 9:17
  • 2
    It would also be useful for JavaScript questions, where there's a "pure" JS way, and a jQuery/Angular/whatever one. Or for CSS/LESS. Or HTML4 vs HTML5 (although HTML4 will eventually fade away... hopefully).
    – Siguza
    May 22, 2015 at 9:27
  • @GPPK As anaximander points out, it'd also be relevant for C#/VB.NET (as my question already points out). Moreover, C# didn't cause VB.NET to fadeout, and I'm not certain that Swift will necessarily cause Objective-C to fade out. There are probably other examples and there will probably be more examples in the future.
    – nhgrif
    May 22, 2015 at 10:26
  • 1
    That would be an awesome unused feature.
    – user1228
    May 22, 2015 at 16:46
  • 1
    I wish I could upvote this more than once. Also good for MS Office object model questions - tag a question with [powerpoint] only and post snippets in VBA/C#/Python.
    – Zev Spitz
    Aug 13, 2015 at 7:01
  • +1. I absolutely agree. The framework OpenUI5 | SAPUI5 allows developers to write the UI in JS, JSON, HTML, or XML! The event handlers and other logic can be implemented either in JS using framework's own AMD-like syntax or in modern TypeScript. Some people struggle to "translate" the provided solution into their favorite language. Mar 24, 2021 at 13:28
  • Note that there is precedent on the now-extinct Documentation project. I'm not sure how easy it would be to port that code though. Mar 24, 2021 at 19:06
  • 1
    Now we have same problem with java/kotlin, groovy/gradle dsl, and I'm sure there gonna be more examples in future Aug 6, 2021 at 13:46

0

You must log in to answer this question.

Browse other questions tagged .