4
\$\begingroup\$

As far as I can tell, is basically just C++'s version of .

If this is correct and there is no other appropriate use of the tag (the tag says it's not supposed to be used for "template-meta-programming"), then I recommend we synonimize into .

As a note, this tag almost certainly has some improper uses for things like "template-meta-programming" which the wiki cautions against, and probably some other things, so it'd need some clean-up.

\$\endgroup\$
9
  • \$\begingroup\$ I agree, especially since Rust calls them generics but they act more like C++ templates than Java generics. \$\endgroup\$
    – o11c
    Jul 17, 2015 at 1:39
  • \$\begingroup\$ I don't know enough about C++ to know for sure that a C++ template is equivalent enough to a Swift/Java/C# generic. \$\endgroup\$
    – nhgrif
    Jul 17, 2015 at 1:40
  • 2
    \$\begingroup\$ Language-wise, there is a big difference between C++ templates and generics in a language like Java, for instance, however, since both tags seem to represent the same concept, creating the synonym might be adequate. \$\endgroup\$
    – glampert
    Jul 17, 2015 at 1:43
  • \$\begingroup\$ @glampert Would you mind posting, as an answer, an elaboration on the differences between C++ templates and say Java generics? \$\endgroup\$
    – nhgrif
    Jul 17, 2015 at 1:44
  • 2
    \$\begingroup\$ humm, let me think about for a while, I'm not fully decided on either side yet :P \$\endgroup\$
    – glampert
    Jul 17, 2015 at 1:47
  • \$\begingroup\$ IMO if you exclude template-meta-programming (which should not be hyphenated btw) all that's left is implementations differences. I mean, the implementations differences are often significant, but ... \$\endgroup\$
    – o11c
    Jul 17, 2015 at 1:48
  • \$\begingroup\$ @glampert Based on that link, I think synonimization is right. For example, Swift generics don't require you to specify a class or protocol (but you can). \$\endgroup\$
    – nhgrif
    Jul 17, 2015 at 1:54
  • \$\begingroup\$ Yep, like I said, it is the same overall concept, so from that standpoint, they could be merged, however, if you look into the questions tagged with template, the majority seems to be c++, while generics is a mix of mainly Java and C#. Should those be mixed together? I don't know... \$\endgroup\$
    – glampert
    Jul 17, 2015 at 2:03
  • 1
    \$\begingroup\$ As far as I can tell, "generics" is basically just Java's version of C++'s "template". \$\endgroup\$
    – janos
    Jul 18, 2015 at 16:13

2 Answers 2

10
\$\begingroup\$

No.

Templates and Generics, though similar enough in some ways, are different enough in other ways to the point where a person expert in one will have little or no valuable insight on the other. A person who follows will not likely follow (and vice versa). This makes it different from other language-agnostic tags like , etc...

Tags have two purposes - a broad classification of questions, but also as landmarks that users use to find questions to answer. Merging these tags will make life "worse" for people who follow them, not better, and will add little, or no value for people asking questions either.

So, no, do not mix these two.

\$\endgroup\$
4
  • \$\begingroup\$ So which tag should we use for Rust "generics", which act like C++ templates? \$\endgroup\$
    – o11c
    Jul 18, 2015 at 22:39
  • 1
    \$\begingroup\$ @o11c If the documentation calls them generics, use generics. If it calls them templates, use templates. Don't mix them. \$\endgroup\$
    – Mast Mod
    Jul 19, 2015 at 7:33
  • \$\begingroup\$ @Mast Okay, so the tag generics gets used for (quoting) "similar enough in some ways, are different enough in other ways to the point where a person expert in one will have little or no valuable insight on the other". Gotcha. \$\endgroup\$
    – o11c
    Jul 19, 2015 at 20:27
  • \$\begingroup\$ Keep in mind that template should not be used for template-meta-programming, which I think covers all the things that generics can't do. \$\endgroup\$
    – o11c
    Jul 19, 2015 at 20:28
9
\$\begingroup\$

From a technical standpoint, if we look into the way C++ templates are implemented vs how Java generics are implemented, there is a big difference. C# generics are implemented in a way more similar to C++ templates, but there are a few differences as well. Certainly there's more, but these are the languages I know about.

From a semantic standpoint, my understanding is that both templates and generics represent the same concept of type generic programming. From this perspective, then yes, the words are synonyms.

Now from a cultural standpoint, I don't recall ever hearing a C++ programmer use the term generics to talk about templates, so I'm not sure if mixing both terminologies is a good idea due to the historial meaning of the word template in the C++ community.

So in the end, all that beating around the bush is my way of saying that I'm not sure :P. It seems to me that I can go both ways just as well.

\$\endgroup\$
1
  • 5
    \$\begingroup\$ For what it's worth, you'll never hear an iOS developer talking about [hash-maps], but [dictionary] has been made a synonym of [hash-map]. Thanks for your input. \$\endgroup\$
    – nhgrif
    Jul 17, 2015 at 4:02

You must log in to answer this question.

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