Talk:Comparison of Java and C++: Difference between revisions

Content deleted Content added
Eelis.net (talk | contribs)
removed some comments about issues that have long been resolved
Remove merge proposal
 
(209 intermediate revisions by 83 users not shown)
Line 1:
{{Talk header}}
There are some on-line articles comparing Java with C++. Some of them emphasize C++'s advantages, while others highlight Java's. Who's that guy who write "Thinking in Java"? He had a pretty comprehensive one, although it's dated now. [[User:Ed Poor]]
{{Old AfD multi |date=17 December 2021 |result='''keep''' |page=Comparison of Java and C++}}
{{WikiProject banner shell|class=List|1=
{{WikiProject Computing |importance=low}}
{{WikiProject Java |importance=low}}
{{WikiProject C/C++ |importance=low }}
}}
{{User:MiszaBot/config
|archiveheader = {{Talk archive}}
|algo = old(365d)
|maxarchivesize = 100K
|minthreadsleft = 5
|minthreadstoarchive = 1
|counter = 2
|archive = Talk:Comparison of Java and C++/Archive %(counter)d
}}
 
== Maintainingremove abounds NPOVchecking ==
 
It is said that "HotSpot can remove bounds checking". But as far as I understand it's only an optimization technique which sometimes remove bound checking but not suppress it totally. [[User:Xavier Combelle|Xavier Combelle]] ([[User talk:Xavier Combelle|talk]]) 17:33, 22 July 2013 (UTC)
A comparison of Java to C++ should list differences. Calling those differences "advantages" or "disadvantages" of one language or the other is in most cases controversial and shows bias. Additionally, it's often impossible to argue in favor or against a specific language feature without considering the broader perspective and intent of the languages.
 
== Copyrights and patents ==
In the interest of maintaining a NPOV, I have reworded and moved all items from the "advantages"/"disadvantages" lists to the "differences" list. In addition, I've added a paragraph that describes the cause of many differences: differing design aims.
 
If we're going to say that "Various aspects of the language are covered by patents and copyrights held by Oracle.", then we need a cite to back it up. [[Oracle_v._Google]] says the opposite, that provided they avoid copying code, Google can implement Java (and all its APIs) even over Oracle's objections. http://www.javaworld.com/jw-10-1997/jw-10-lawsuit.html says "the complaint charges Microsoft with trademark infringement, false advertising, breach of contract, unfair competition, interference with prospective economic advantage, and inducing breach of contract." That long list does not include copyrights or patents. If we're wildly speculating, http://communities.mentor.com/community/cs/archives/cxx-abi-dev/msg01295.html is a list of possible patents over C++ implementations (not really from a reliable source) and if GCC's C++ implementation violates any of them, so almost certainly does GCC's Java implementation, as they share an ABI... and IBM and Microsoft are the corporate names on those patents, not Oracle.--[[User:Prosfilaes|Prosfilaes]] ([[User talk:Prosfilaes|talk]]) 08:24, 27 October 2013 (UTC)
I urge future editors to not show bias.
:Your last observation is interesting, but irrelevant here. The point is, Oracle may at any time assert it's intellectual rights over various aspects of the Java language. Moreover, the verdict in the Oracle/Google lawsuit does not in any way affect their right to sue even on the very same grounds laid out in that particular lawsuit, and however unlikely, they could still win such a lawsuit. And please note that a large part of that lawsuit was simply an objection to Google duplicating the Java API of all things! Which means, of course, that the types of complaints filed in any future lawsuit are only limited by the creativity of Oracle's legal department. [[User:Sebastiangarth|Sebastian Garth]] ([[User talk:Sebastiangarth|talk]]) 13:45, 27 October 2013 (UTC)
:: The point is, Microsoft may at any time assert its intellectual rights over various aspects of the Java and C++ languages. So might IBM. So might any other huge patent holder. So might any designer of a pre-Java API who wanted to claim that Java's API is a copyright infringement of theirs. Looking at the results of the SCO trial, it's not at all improbable that somewhere BSD-licensed code snuck its way into Oracle's Java implementation sans proper copyright notice. All of this might happen, and all of it is [[WP:CRYSTAL|crystal-balling]].
:: Yes, Oracle could sue on the same grounds. There's very few limitations on what people can sue on. Speculating that they could win such a lawsuit is, again, crystal-balling, and again, Oracle is not unique in having a creative legal department.
:: Going back to the original statement, nobody has ever shown that a language can be covered by copyrights, and [[Oracle v. Google]] said they couldn't, or at least Java wasn't. Neither 6061520 or RE38104, the two patents brought up in the Oracle trial, seem to be about Java as much as ways to implement Java. If we want to make the claim under question, we should speak with specificity and with cites. (And we should avoid saying anything about Oracle's "intellectual rights" over Java. That's not a clear term. We should speak specifically of copyrights, patents or trademarks, each of which has very different extents and limitations.)--[[User:Prosfilaes|Prosfilaes]] ([[User talk:Prosfilaes|talk]]) 17:40, 27 October 2013 (UTC)
:::I do understand your point but I still must disagree here. At any rate, I'm not going to press the issue any further. Perhaps we'll revisit the discussion sometime in the future. For now, at least, we can leave the wording as it is. [[User:Sebastiangarth|Sebastian Garth]] ([[User talk:Sebastiangarth|talk]]) 19:36, 27 October 2013 (UTC)
 
== Multiple Inheritance in Java ==
-- [[User:Eelis.net|Eelis]] 01:53, 2005 May 23 (UTC)
 
Guys/Gals,
 
Java does not support multiple inheritance. <---- note that there's a period at the end of that sentence
----
 
I call your attention to: http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)
I'm going to remove the comment that this article should be merged because I don't agree with the reasons, and the fact that editing has remained active for over 5 months and about 40 edits leads me to believe there are plenty of others to support my position. If this should be merged, I think there are enough people who have worked on this article that there should be some discussion here first. I don't want to see an overzealous and possibly inexperienced editor coming along, see the merge task as a community decision waiting to be implemented, and do the merge without discussion. [[User:CyborgTosser|CyborgTosser]] ([[User_talk:CyborgTosser|Only half the battle]]) 20:22, 25 Feb 2005 (UTC)
 
Specifically, the fact that that article begins by stating that *implementation* is what is being inherited, NOT TO BE CONFUSED with subtyping:
For reference, here is the original merge request as posted by [[User:Netoholic|Netoholic]]:
:''This article or section should be [[Wikipedia:Duplicate articles|merged]] with the [[Java programming language]] & the [[C Plus Plus|C++ programming language]].
 
http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)#Inheritance_vs_subtyping
[[User:CyborgTosser|CyborgTosser]] ([[User_talk:CyborgTosser|Only half the battle]]) 20:27, 25 Feb 2005 (UTC)
 
Anyone who understands multiple inheritance and its problem(s) would know quite well that Java does not support multiple inheritance, and the creators of Java were very vocal and open about their reasons for excluding multiple inheritance from the Java language spec.
: My main point is that there are infinite combinations of comparison articles possible (just the top 10 languages alone would lead to 45 such articles). A much better approach would be to put the "Advantages" and "Disavantage" sections within each language article itself. That way, you can reduce the redundancy where a language has dis/advantages over multiple other ones. -- [[User:Netoholic|Netoholic]] [[User talk:Netoholic|@]] 22:12, 2005 Feb 25 (UTC)
 
[[User:Aquishix|Aquishix]] ([[User talk:Aquishix|talk]]) 12:19, 10 February 2014 (UTC)
::There are many ''possible'' combinations for articles, but probably only about a dozen that would make ''interesting'' articles. In particular, when one language is strongly influenced by another (this article) or if the languages represent a split in design philosophy within a given paradigm (such as OCaml vs. Lisp), there is a possibility for an interesting article. An advantages/disadvantages section in each article would be a good idea, but as long as the number of comparison articles we have doesn't grow without bounds, I don't think there will be a lot of redundancy. Look, for example, at this article and the comparison of Java to C#. What gives Java an advantage/disadvantage compared to C++ is not the same as compared to C#. But I will take a "wait and see" attitude on this. If I am wrong and there is a ton of redundancy as more of these articles pop up, then I'm in support of consolidation. [[User:CyborgTosser|CyborgTosser]] ([[User_talk:CyborgTosser|Only half the battle]]) 23:28, 25 Feb 2005 (UTC)
 
== Java Generics Inaccuracy ==
 
I believe there is an error in the generics vs. templates comparison section.
 
It says (as of 11/18/2015):
{| class="wikitable"
! '''C++ Templates''' !! '''Java Generics'''
|-
| Templates can be [[Template (programming)#Explicit template specialization|specialized]]—a separate implementation could be provided for a particular template parameter.
|| Generics cannot be specialized.
|}
 
The below program shows an example of specializing a generic method for a specific template parameter. The "myCount" method is specialized for subclasses (inclusive) of Character. Is this not "providing a separate implementation for a particular template parameter"? It seems to precisely match the definition of "Explicit template specialization" given here: [[Template (programming)#Explicit template specialization]]
 
<syntaxhighlight lang="java">
import java.util.*;
 
public class Test {
 
static <T> int myCount (Iterator<T> iterator, T val)
{
int ret = 0;
while (iterator.hasNext()) {
T entry = iterator.next();
if (entry.equals(val)) ++ret;
}
return ret;
}
 
static <T extends Character> int myCount (Iterator<T> iterator, T val)
{
System.out.println("weirdcount");
int ret = 0;
while (iterator.hasNext()) {
T entry = iterator.next();
if (entry.equals(val)) ++ret;
}
return ret*3;
}
 
public static void main (String[] args) {
List<Integer> nums = new ArrayList<>(Arrays.asList(1,2,3,3,3,4,5,2,1));
int count = myCount(nums.iterator(), 3);
System.out.println(count);
 
List<Character> characters =
new ArrayList<>(Arrays.asList('a','b','c','d','e','a','b'));
int count2 = myCount(characters.iterator(), 'a');
System.out.println(count2);
}
}
</syntaxhighlight>
Thanks,
[[User:Vancan1ty|Vancan1ty]] ([[User talk:Vancan1ty|talk]]) 04:35, 19 November 2015 (UTC)
 
== nested/inner classes ==
 
I think the article should also state that C++ nested classes differ from Java inner classes.
C++ nested classes are kinda like a static class in Java and can not access fields in the outer class unless they are static (C++11) [[User:Peter.quiring|Peter.quiring]] ([[User talk:Peter.quiring|talk]]) 22:42, 4 April 2016 (UTC)