39

Why do Swift questions get marked as duplicates of Objective-C questions?

Swift is attractive to new developers. A new developer may not be at a level to understand Objective-C syntax and may be asking a valid Swift question. For it to be marked as a duplicate of an Objective-C question is unfair, as that person will then go to the original question and see all the answers in Objective-C.

I have seen this on several occasions, and it is frustrating. Can I ask that Swift questions be seen as separate to Objective-C questions and not just general iOS/OS development questions!

8
  • 2
    See: meta.stackoverflow.com/questions/287600/…
    – helrich
    Commented Apr 2, 2015 at 19:29
  • 7
    Are they questions about the Swift language or are they questions about iOS frameworks? If they're about iOS frameworks, are they about the differences in using them between Swift or Objective-C? Commented Apr 2, 2015 at 19:34
  • 9
    Several examples would probably help here.
    – Servy
    Commented Apr 2, 2015 at 19:37
  • 2
    My issue is with the, how do I do this type of question. Example code is in Swift and it gets marked as a duplicate. You go to the original question and all the answers are in objective-c. Even though the question is tagged swift! Commented Apr 2, 2015 at 19:38
  • 5
    There was some discussion about this over here, as well: meta.stackoverflow.com/questions/285258/…
    – Brad Larson Mod
    Commented Apr 2, 2015 at 19:44
  • As others have noticed, the tagging of Apple-specific technologies is a bit of a mess. Since it is unrealistic to fix it, you might as well use it to your advantage. I have created a small taxonomy for my own use that helps filter out the most clueless questions. You could add the swift tag to the list at the same level as objective-c, to identify a question that confounds the dev framework (Cocoa) with the programming language to control it.
    – Monolo
    Commented Apr 3, 2015 at 9:30
  • This must be a curse to Apple programming experts. Do we have to do this all over again? Re-answering every old question with a different syntax to do the same thing? Awww. Otherwise a mono-culture problem. Commented Apr 3, 2015 at 22:27
  • 3
    @HansPassant you mean like Java 8 and lambdas? Or Python[23]? I can't wait for Perl 6 to some day... well, actually say "yep, its ready".
    – user289086
    Commented Apr 3, 2015 at 23:23

4 Answers 4

32

The answer is because some questions tagged ARE duplicates of some questions tagged .

First of all, let's keep in mind that we probably haven't been using entirely appropriately in the pre-Swift era.

Let's take this question for example:

iOS Development - What does in View vs. View Controller?

It is tagged with , but it has nothing to do with Swift. It is marked as a duplicate of another question. The other question is tagged with , but it has nothing to do with Objective-C.

This isn't a Swift question marked as a duplicate of an Objective-C question. This is a question tagged Swift marked as a duplicate of a question tagged Objective-C, but neither has anything to do with the language the user happens to be writing their code in.

The fact of the matter is, I could write a view controller in Objective-C, subclass it in Swift, and hook some of my outlets or actions up to the parent in Objective-C and some to the child in Swift (not saying this would be good, but could), and run into the same exact issue. Should I open a new question tag it with and and get offended when someone closed it as a duplicate? After all, as far as I know there are no questions where someone has experience this problem when writing in both languages!!

But neither tag is actually appropriate. In the case of the Objective-C question, the problem isn't a result of Objective-C code, and the solution isn't to write or modify any Objective-C code. In the case of the Swift question, the problem isn't a result of Swift code, and the solution isn't to write or modify and Swift code. And if any point in the future there's any other language that you can hook up IBOutlets from your storyboard to your source code, if someone runs into this problem, the problem still won't be because of any code written in any language and the solution still won't be to to write or modify any code in any language.

Most likely, this question's tags should be something like:

And the question it's linked to as a duplicate could/should have the exact same set of tags. So again, in this case, it's not a Swift question marked as a duplicate of an Objective-C question. It's an question incorrectly tagged marked as a duplicate of another question which is incorrectly tagged .

If someone has examples of actual Swift questions (not just questions tagged ) that are closed as duplicates of actual Objective-C questions (not just questions tagged ), I'd love to see these examples.

17
  • My answer here is really sort of just an echo to this related answer.
    – nhgrif
    Commented Apr 2, 2015 at 20:39
  • 10
    Also, more than anything else, people are terrible about incorrectly tagging their question xcode. If Apple comes out with another IDE, and people are now incorrectly tagging that new IDE on questions that have nothing to do with the IDE, are we going to throw a fit when questions tagged (incorrectly) with the new IDE are closed as duplicates of questions tagged (incorrectly) with the old IDE?
    – nhgrif
    Commented Apr 2, 2015 at 20:48
  • So, lets get the mob retagging stuff, right?
    – Braiam
    Commented Apr 3, 2015 at 1:06
  • 3
    Perhaps. We certainly can make an effort to get the tags correct on new questions as they're posted. It's not a day on Stack Overflow if I haven't removed the Xcode tag at least ten times.
    – nhgrif
    Commented Apr 3, 2015 at 1:08
  • Reminds me of android questions with Java answers
    – tgkprog
    Commented Apr 3, 2015 at 21:59
  • Well by that line of argument, basically any question on SO is a duplicate of something that Knuth has covered in his Art of Programming, just expressed in a particular context or programming language...
    – miraculixx
    Commented Apr 5, 2015 at 13:52
  • @miraculixx Well, as a starter, no one is trying to close anything as a duplicate of something not posted to Stack Overflow. No one is saying "This should be closed as a duplicate of the documentation provided here" (linking to some non-Stack Overflow website).
    – nhgrif
    Commented Apr 5, 2015 at 16:55
  • 1
    @nhgrif my point was that it's not a sensible* argument to say "this question is a duplicate because it has been answered for a different programming language". After all, SO encourages to include answers, not links. So a link to a "duplicate" in a different programming language is hardly helping anyone, yet that's all the "closed as duplicate" reason does. *changed from not valid
    – miraculixx
    Commented Apr 5, 2015 at 19:19
  • 1
    @miraculixx That's not what my answer is saying. I'm not saying questions should be closed because it has been answered in another programming language. What I'm saying is that not every question on Stack Overflow is specific to a programming language. The question I linked to in this answer has nothing to do with Swift (despite having some Swift code and originally a Swift tag), and the question it's marked as a duplicate of has nothing to do with Objective-C (despite having some Objective-C code and originally an Objective-C tag).
    – nhgrif
    Commented Apr 5, 2015 at 19:40
  • 1
    @miraculixx It seems by the criteria you're defining that basically nothing on Stack Overflow would actually be a duplicate. Some questions are asked where t he core problem is exactly the same, and the answer to both questions would be identical... but because there's some other completely irrelevant detail that has nothing to do with the actual problem, they're not duplicates? Should we prevent iOS questions as being closed as duplicates of OS X questions even if at the end of the day the question has nothing to do with the OS?
    – nhgrif
    Commented Apr 5, 2015 at 19:42
  • @nhgrif "The answer is because some questions tagged swift ARE duplicates of some questions tagged objective-c."
    – miraculixx
    Commented Apr 5, 2015 at 23:05
  • @nhgrif No, I'm not saying no questions should ever be marked duplicate, at all. If two questions ask the same thing (and there are many), it's good courtesy to close as a duplicate. But if the question is not the same, and the answer is likely not the same either, IMHO it should not be closed on grounds of resemblance on an abstract level, as in this case. Btw, the accepted answer of the duplicate question does not seem to apply - says the OP. Unfortunately, we won't ever know because nobody else can answer...
    – miraculixx
    Commented Apr 5, 2015 at 23:12
  • 1
    Yes, @miraculixx Did you read my answer or just the first line? The whole point my post makes is that just because a question is tagged swift doesn't mean it's actually a Swift question, and just because the question it is marked a duplicate of is tagged Objective-C doesn't mean that question is actually an Objective-C question. The question I offered as an example is a perfect demonstration of this. Both scenarios suffer the same "this class is not key value coding-compliant for the key board", which is an interface builder problem that has nothing to do with the users language.
    – nhgrif
    Commented Apr 5, 2015 at 23:22
  • 1
    @miraculixx Your Stack Overflow profile shows you have basically no activity in Swift, Objective-C, iOS, or Xcode, so I can see how you wouldn't be able to tell that these are duplicates. Meanwhile, if you'll look at my profile, you'll find most all of my activity is in Swift, Objective-C, and iOS. The solution to both problems is the same, it involves fixing how your interface builder file is set up, and there's not a single line of Objective-C OR Swift code in your interface builder.
    – nhgrif
    Commented Apr 5, 2015 at 23:27
  • 1
    Then you have enough experience to recognize that the question I linked to has been appropriate closed as a duplicate. Neither question has anything to do with the programming language at use. The answer at available doesn't make any comment regarding Objective-C. The problem has nothing to do with Objective-C. The solution has nothing to do with Objective-C. In the closed question, the problem has nothing to do with Swift, and if it were left open, any posted answer would likewise have nothing to do with Swift. It's an interface builder question, period. They are duplicates.
    – nhgrif
    Commented Apr 5, 2015 at 23:39
17

This seems to be a case of something I complained about a long time ago: we use tags to indicate the programming language that's being used, and that conflicts with the (potential) use of tags to indicate that the problem has something to do with a particular language.

In this case, it seems that one developer happens to be using and another happens to be using , and they both have the same problem.

In my world, this is similar to one developer writing in and another writing in , and they're both having the same problem.

In both examples, the language being used is interesting, but is not the crux of the problem. The language is orthogonal to the problem.

The counterexample is a question about the syntax of the await keyword in . In that case, the question is about the language.

I really wish we had something like "side tags" in addition to our current tags. These could provide information on the programming language being used, or the IDE being used, in the cases where programming language and IDE are not actually very relevant to the question.

3
  • 1
    Problem area topics vs. user environment tags.
    – user289086
    Commented Apr 2, 2015 at 21:10
  • 7
    That makes sense and is great in theory but if you implement that split fully you depend on askers and reviewers to distinguish confidently, quickly, and accurately which proposed duplicates have sufficient language-neutral answers that are also the best option for the language of the new question. Just seems to me like such an ideal not only requires high proficiency in the nuances, libraries, and implementations of the involved languages but also introduces an endless pit of subjectivity. Right? Commented Apr 2, 2015 at 21:23
  • 1
    @MarkBalhoff I agree. Moreover, askers are inevitably going to not fully understand their actual problem and therefore assign a primary tag for something that should be a "side tag", then get upset when that tag gets moved as a "side tag" and the question gets closed as a duplicate. This exact scenario would still happen with the question I used as an example in my answer probably.
    – nhgrif
    Commented Apr 2, 2015 at 21:24
9

I am neither an Objective-C nor a Swift expert, but as a matter of general site policy, I think that if you are stuck because all available answers to the question you have are in programming languages you don't know or can't use for your project, you ought to be allowed to ask a new question which points at one of those answers and asks for a translation into a language you do know or can use.

In this context, that would go like this: "I am writing an iOS application in Swift. I have problem X, for which [earlier answer] suggests use of this Objective-C fragment: [copy and paste from earlier answer] This seems like it would work, but I don't know what the Swift equivalent of this is, can anyone help me translate it?"

8
  • 4
    There's an existing meta answer by an SO mod which suggests that direct translation questions are actually off-topic. Moreover, unlike VB and C#, Objective-C and Swift can compile into the same binary (just can't be in the same file), so the situation in which you can't use an alternate language is a bit slimmer. But with that said, I also don't think that all Swift questions should be automatically marked as duplicates of an Objective-C question.
    – nhgrif
    Commented Apr 3, 2015 at 22:07
  • 2
    Instead of your suggested question, something more like a plain English description of the problem followed by the attempted Swift code. If you don't have any Swift code to put in your question, then your question isn't really a Swift question, it's a framework question and it can (and should) be marked as a duplicate of any other existing framework question that answers the question. Even if the examples in answers are in Objective-C. If the asker has trouble implementing the same code in Swift, then the question is a Swift syntax question and is ready to be asked.
    – nhgrif
    Commented Apr 3, 2015 at 22:09
  • 1
    Here's the meta answer I referred to in my first comment: meta.stackoverflow.com/a/265834/2792531
    – nhgrif
    Commented Apr 3, 2015 at 22:15
  • 2
    I'm inclined to disagree with that ruling. "Translate [construct] for me" superficially resembles "write my code for me", but it's been my experience that such questions are often quite subtle and excellent teaching moments for future readers: "so a 1:1 translation of your YerbaMate into Emerald would look like this, but that doesn't work because of semantic differences X, Y, Z; you have to write it like this instead. But that's poor style, because in Emerald you have handy features α and β which let you do it more concisely like this."
    – zwol
    Commented Apr 3, 2015 at 22:24
  • 4
    @zwol: Nearly all of those "teaching moments" can be summarized simply thus: Don't try a direct translation, that's simply a bad idea in nearly every case. Extract the algorithm and do a clean re-implementation instead. There might be some questions for SO in extracting the algorithm or in re-implementing (though really try for yourself first), but doing both at once is certainly too broad. Commented Apr 4, 2015 at 13:58
  • 3
    @nhgrif This gets us back to the original problem: For an answer in Objective-C to be of any use to you at all, you have to know Objective-C. Otherwise, the answer is gibberish. This effect gets stronger the bigger the difference between the answer's language and a language that you know. What if somebody asked a very general question and accepted an answer in Brainfuck? Would everybody who asks the same question from then on have their question marked as "duplicate" and be directed to go read the Brainfuck example? Commented Apr 5, 2015 at 14:46
  • @ThrowawayAccount3Million Using the same obscure language as your example, you seem to making a case that says it'd be okay to post a snippet of Brainfuck and say "I need to do this same thing in Swift." I'm not saying that translation requests are off-topic as duplicates. They're off-topic for other reasons. Please read this meta answer: meta.stackoverflow.com/questions/265825/…
    – nhgrif
    Commented Apr 5, 2015 at 14:58
  • @ThrowawayAccount3Million Specifically, a direct translation question is either "Unclear what you're asking" or: Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.
    – nhgrif
    Commented Apr 5, 2015 at 14:59
6

IMO closing these questions is going to hurt the site. For those who disagree, I have a modest proposal: If any English-language question is already answered on Chinese Stack Overflow, the English-language question should be marked as a duplicate and closed. Asking how to translate the Chinese answer into English should be on topic, however.

1
  • 2
    Robert Harvey's answer corroborating this: meta.stackoverflow.com/a/285266 Also see that the OP favored your sarcastic proposal, though probably without making SO a code-translation-service and thus actually making it practical. Commented Apr 4, 2015 at 14:02

You must log in to answer this question.

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