Jump to content

Talk:Comparison of Java and C++

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

remove bounds checking

[edit]

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. Xavier Combelle (talk) 17:33, 22 July 2013 (UTC)[reply]

Copyrights and patents

[edit]

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.--Prosfilaes (talk) 08:24, 27 October 2013 (UTC)[reply]

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. Sebastian Garth (talk) 13:45, 27 October 2013 (UTC)[reply]
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 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.)--Prosfilaes (talk) 17:40, 27 October 2013 (UTC)[reply]
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. Sebastian Garth (talk) 19:36, 27 October 2013 (UTC)[reply]

Multiple Inheritance in Java

[edit]

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)

Specifically, the fact that that article begins by stating that *implementation* is what is being inherited, NOT TO BE CONFUSED with subtyping:

http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)#Inheritance_vs_subtyping

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.

Aquishix (talk) 12:19, 10 February 2014 (UTC)[reply]

Java Generics Inaccuracy

[edit]

I believe there is an error in the generics vs. templates comparison section.

It says (as of 11/18/2015):

C++ Templates Java Generics
Templates can be 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

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);
    }
}

Thanks, Vancan1ty (talk) 04:35, 19 November 2015 (UTC)[reply]

nested/inner classes

[edit]

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) Peter.quiring (talk) 22:42, 4 April 2016 (UTC)[reply]