Differences between C++ and Java

P

Pep

Roedy said:
I decided to plonk Oliver for a while to give it a rest. It was
getting too frustrating being contradicted over and over by someone so
inexperienced.

Big of you :->
 
O

Oliver Wong

Robert Klemme said:
What exactly do you mean by this?

I'm not a C++ programmer, so I'm not sure about if this is true or not,
but I'm assuming there is no "Foo" such that for all "bar", "bar instanceof
Foo" returns true in C++. While there is such a "Foo" in Java (it's called
"Object").

- Oliver
 
O

Oliver Wong

Roedy Green said:
thanks everyone. You can see the aggregate list at
http://mindprod.com/jgloss/cpp.html

<quote>
Java has a vast standard library set, including AWT and Swing. C++ has a
relativey modest standard set of methods, and relies on platform-specific
GUI libraries.
</quote>

C++ has Qt, GTK and wxWidget which are fairly platform independent.

<quote>
Java requires a JVM to execute. C++ programs are usually freestanding.
</quote>

I'm almost afraid to bring this up (given how poorly my earlier comments on
the JVM were received), but Java doesn't actually require a JVM to execute.
See http://www.excelsior-usa.com/jet.html

- Oliver
 
J

Jeffrey Schwab

Oliver said:
I'm not a C++ programmer, so I'm not sure about if this is true or not,
but I'm assuming there is no "Foo" such that for all "bar", "bar instanceof
Foo" returns true in C++. While there is such a "Foo" in Java (it's called
"Object").

The type is called void. instanceof is spelled dynamic_cast. Pointers
of any type can be assigned to void* without casts.
 
S

SDB

:
: message : >
: > thanks everyone. You can see the aggregate list at
: > http://mindprod.com/jgloss/cpp.html
:
: <quote>
: Java has a vast standard library set, including AWT and Swing. C++ has a
: relativey modest standard set of methods, and relies on platform-specific
: GUI libraries.
: </quote>
:
: C++ has Qt, GTK and wxWidget which are fairly platform independent.
:
: - Oliver

The Java specification includes treats such as GUI, networking and database
connectivity APSs. The C++ specification is quite spartan in this area. It
is very possible to write GUI, networking and database connectivity API's in
C++, they are not part of the specification though.
 
Z

zero

:
: in message : >
: > thanks everyone. You can see the aggregate list at
: > http://mindprod.com/jgloss/cpp.html
:
: <quote>
: Java has a vast standard library set, including AWT and Swing. C++
: has a relativey modest standard set of methods, and relies on
: platform-specific GUI libraries.
: </quote>
:
: C++ has Qt, GTK and wxWidget which are fairly platform independent.
:
: - Oliver

The Java specification includes treats such as GUI, networking and
database connectivity APSs. The C++ specification is quite spartan in
this area. It is very possible to write GUI, networking and database
connectivity API's in C++, they are not part of the specification
though.


To be honest, things like Swing are not part of the Java language either -
they are part of the Java API or Java standard library. I know this is
nitpicking, since the Java API is considered an essential part of Java. It
is true that Swing is a lot more part of Java than Qt is part of C++. The
only library that is "part of" C++ is STL.
 
O

Oliver Wong

SDB said:
:
: <quote>
: Java has a vast standard library set, including AWT and Swing. C++ has a
: relativey modest standard set of methods, and relies on
platform-specific
: GUI libraries.
: </quote>
:
: C++ has Qt, GTK and wxWidget which are fairly platform independent.
:
: - Oliver

The Java specification includes treats such as GUI, networking and
database
connectivity APSs. The C++ specification is quite spartan in this area.
It
is very possible to write GUI, networking and database connectivity API's
in
C++, they are not part of the specification though.

It seems "unfair" to me to compare a { language } to a { language, class
library, platform }. When Roedy wrote "Java has a vast standard library set,
including AWT and Swing", I assumed the "Java" there referred to the Java
Platform, and not just the Java Language.

If we're going to restrict C++ to just the C++ language, then we should
do the same for the Java Language: the Java language itself has no direct
facilities for GUIs, network or database connectivity. You can write APIs
that provide such functionalities (and indeed, Sun has done that for us),
but they are not part of the Java Language Specification, which can read
from:

http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

Note in particular the JLS's section 1.3 "Relationship to Predefined Classes
and Interfaces":
http://java.sun.com/docs/books/jls/third_edition/html/intro.html#1.3

<quote>
As noted above, this specification often refers to classes of the Java and
Java 2 platforms. In particular, some classes have a special relationship
with the Java programming language. Examples include classes such as Object,
Class, ClassLoader, String, Thread, and the classes and interfaces in
package java.lang.reflect, among others. The language definition constrains
the behavior of these classes and interfaces, but this document does not
provide a complete specification for them. The reader is referred to other
parts of the Java platform specification for such detailed API
specifications.
</quote>

- Oliver
 
S

SDB

:

: > The Java specification includes treats such as GUI, networking and
: > database
: > connectivity APSs. The C++ specification is quite spartan in this area.
: > It
: > is very possible to write GUI, networking and database connectivity
API's
: > in
: > C++, they are not part of the specification though.
:
: It seems "unfair" to me to compare a { language } to a { language,
class
: library, platform }. When Roedy wrote "Java has a vast standard library
set,
: including AWT and Swing", I assumed the "Java" there referred to the Java
: Platform, and not just the Java Language.
:
: If we're going to restrict C++ to just the C++ language, then we
should
: do the same for the Java Language: the Java language itself has no direct
: facilities for GUIs, network or database connectivity. You can write APIs
: that provide such functionalities (and indeed, Sun has done that for us),
: but they are not part of the Java Language Specification, which can read
: from:
:

:
: - Oliver

I think ANSI includes some standard libraries their definition of C++.
Simple ones like cout and cin along with some robust libraries like what is
available in the STL. So ANSI defined the standard syntax and a standard
set of libraries. ANSI's definition does not include GUI, database
connectivity nor networking. If ANSI includes some libraries in its
definition of C++, it is fair to compare them to the standard set of
libraries included with java.

But the bottom line is that you don't really care. You'd just rather be a
dick.
 
O

Oliver Wong

SDB said:
:

: > The Java specification includes treats such as GUI, networking and
: > database
: > connectivity APSs. The C++ specification is quite spartan in this
area.
: > It
: > is very possible to write GUI, networking and database connectivity
: > API's in
: > C++, they are not part of the specification though.
:
: It seems "unfair" to me to compare a { language } to a { language,
: class library, platform }. When Roedy wrote "Java has a vast standard
: library set, including AWT and Swing", I assumed the "Java" there
: referred to the Java Platform, and not just the Java Language.
:
: If we're going to restrict C++ to just the C++ language, then we
: should do the same for the Java Language: the Java language itself has
: no direct facilities for GUIs, network or database connectivity. You can
: write APIs that provide such functionalities (and indeed, Sun has done
: that for us), but they are not part of the Java Language Specification

I think ANSI includes some standard libraries their definition of C++.
Simple ones like cout and cin along with some robust libraries like what
is
available in the STL. So ANSI defined the standard syntax and a standard
set of libraries. ANSI's definition does not include GUI, database
connectivity nor networking. If ANSI includes some libraries in its
definition of C++, it is fair to compare them to the standard set of
libraries included with java.

Good point. In light of this new evidence, it is compeling to to think
of Qt, GTK, etc. as the equivalent of Java' SWT: Perhaps of an excellent
quality, but clearly a "Third Party" product.

Still, the issue is not completely clear cut to me. If the intent is to
promote Java, then certain the statement "Sun's class library is much more
comprehensive than ANSI's C++ library" will fufill that role. If the intent
is to promote C++, a better sentence might be "There are so many more
quality libraries that interoperate with C++ than with Java". If, instead,
one wants to make an objective comparison between Java and C++ so that, when
one is in a situation where one needs to choose between the two, perhaps
neither of those sentences are satisfactory.

A statement that I think no reasonable person will dispute is that when
downloading Sun's Java Development Kit, you get an excellent class library
from which to work with; while with C++, you sort of have to find and
download the libraries almost on your own. The closest equivalent I know of
in the C++ world is DJGPP, which does a relatively good job of packaging a
library into their development kit. http://www.delorie.com/djgpp/
But the bottom line is that you don't really care. You'd just rather be a
dick.

I'm surprised at this comment, and given Roedy's frustrations with me
(i.e. you're not the only person I seem to have offended in this thread),
I'm starting to worry that the problem lies with me. Is the tone of my
writing really such that I sound like I'm intentionally being antagonistic?
If I disagree with something you write, how should I have expressed it? I
didn't mean to offend you (which I assume I have, since you have started
"calling me names"). I think I may have Asperger's Syndrome
(http://en.wikipedia.org/wiki/Asperger's_Syndrome), which I usually don't
like to bring up, because I don't want to use it as a crutch (e.g. to get
people to "tolerate" me more readily), but I bring it up now to try to
convince you that I really had no intention of upsetting you.

Anyway, I always thought these disagreements were a Good Thing in the
sense that it allows the people involve to see things from other people's
perspectives and broaden their horizons. Certainly you have educated me with
your pointing out that the ANSI STL is indeed a standard library for C++. I
appreciate that, and I now find myself a little bit more knowledgeable on
the topic matter.

- Oliver
 
M

Monique Y. Mudama

I'm surprised at this comment, and given Roedy's frustrations
with me (i.e. you're not the only person I seem to have offended
in this thread), I'm starting to worry that the problem lies
with me. Is the tone of my writing really such that I sound like
I'm intentionally being antagonistic?

Just for the record, while I don't have a dog in this fight, so to
speak, nothing you wrote seemed antagonistic to me. Nothing I saw
deserved name-calling or killfiling.

Some others on this newsgroup, including me at times, can be pretty
caustic, but I have yet to see that in you. I'm not sure what got
people so huffy.
 
C

Chris Uppal

Oliver said:
I'm starting to worry that the problem lies with me. Is the tone of my
writing really such that I sound like I'm intentionally being
antagonistic?

No.

-- chris
 
L

ldv

Oliver said:
<quote>
Java requires a JVM to execute. C++ programs are usually freestanding.
</quote>

I'm almost afraid to bring this up (given how poorly my earlier comments on
the JVM were received), but Java doesn't actually require a JVM to execute.
See http://www.excelsior-usa.com/jet.html

Excelsior JET is a complete JVM implementation, with support for
reflection, security, dynamic compilation, etc., otherwise it would not
have passed the Java Compatibility Kit test suite. The difference is
that it can interoperate with classes precompiled into native
executables.

Here is an excerpt from the page you pointed the readers to
(http://www.excelsior-usa.com/jet.html):

"Excelsior JET Optimizer converts your application's classes and jars
into highly optimized Intel x86 code and creates a native executable
for Microsoft® Windows® or Linux platform.

Excelsior JET Runtime is a complete Java Virtual Machine that works
with both Java classes and the executables produced by the Optimizer.
It implements the Java SE platform, versions 5.0 and 1.4.2."

LDV
 
J

Jaakko Kangasharju

Jeffrey Schwab said:
The type is called void. instanceof is spelled dynamic_cast. Pointers
of any type can be assigned to void* without casts.

This is orthogonal to Oliver's (correct) understanding (and also
wrong: function pointers are not compatible with void pointers). In
C++ you don't have to use objects through pointers, since references
work just as polymorphically. And there is no generic reference type.
 
P

Pep

Oliver Wong wrote:

A statement that I think no reasonable person will dispute is that
when
downloading Sun's Java Development Kit, you get an excellent class library
from which to work with; while with C++, you sort of have to find and
download the libraries almost on your own. The closest equivalent I know
of in the C++ world is DJGPP, which does a relatively good job of
packaging a library into their development kit.
http://www.delorie.com/djgpp/

Cringe as I do when mentioning Microsoft, the downloading of Suns JDK is
akin to purchasing Microsoft's Visual C development environment where you
get their compiler and a massive class framework in the form of MFC.
I'm surprised at this comment, and given Roedy's frustrations with me
(i.e. you're not the only person I seem to have offended in this thread),
I'm starting to worry that the problem lies with me. Is the tone of my
writing really such that I sound like I'm intentionally being
antagonistic? If I disagree with something you write, how should I have
expressed it? I didn't mean to offend you (which I assume I have, since
you have started "calling me names"). I think I may have Asperger's
Syndrome (http://en.wikipedia.org/wiki/Asperger's_Syndrome), which I
usually don't like to bring up, because I don't want to use it as a crutch
(e.g. to get people to "tolerate" me more readily), but I bring it up now
to try to convince you that I really had no intention of upsetting you.

Oliver you have been eloquently arguing this topic since I inadvertently
spilt this can of beans with my original statement and the bottom line is
that you have been extremely abusive in that you have not bowed down to
their point of view. Shame on you for expressing your own free point of
view :)

It's actually clear when reading Sun's specifications that the java vm is a
separate entity to the java language and that the java language is likewise
separate to the vast accompanying suite of Java libraries. Albeit they are
all massively entwined.
Anyway, I always thought these disagreements were a Good Thing in the
sense that it allows the people involve to see things from other people's
perspectives and broaden their horizons. Certainly you have educated me
with your pointing out that the ANSI STL is indeed a standard library for
C++. I appreciate that, and I now find myself a little bit more
knowledgeable on the topic matter.

- Oliver

And like the Java libraries are written in the Java language (mostly), the
STL is written in C++.

Cheers,
Pep.
 
P

Pep

Roedy said:
Just self preservation. There a guy who has threatened to "take me
down" see http://mindprod.com/feedback/peacedeaththreat.html
I just don't want do be involved in any needless fights.

Having seen some of your arguments to Oliver I believe that you are just
afraid that he might have a valid point that contradicts your own valid
point.

In actual fact I believe that Oliver has put his points across quite well
and though his knowledge of C++ might be lacking, what he does know is
sufficiently voiced to bring about a healthy debate.

In actual fact where he has seen that he might be wrong on a particular
point he has graciously accepted that and moved on. I have not seen him
call you any names yet :->
 
P

Pep

Oliver said:
No, I'm serious. What is the difference, in your opinion, between a
JVM
and an emulator?

- Oliver

Hey Oliver I'll make it easier for him.

vmware is an emulator because it "emulates" a intel based PC whereas a JVM
is not emulating another piece of architecture as it was conceived as a
virtual machine in the first place, except that I suppose you could
possibly say that it is emulating a theoretical physical platform :)
 
R

Roedy Green

Just for the record, while I don't have a dog in this fight, so to
speak, nothing you wrote seemed antagonistic to me. Nothing I saw
deserved name-calling or killfiling.

Have you ever seen the episode of the sitcom "Becker" where the doctor
gets sued for malpractice. His defence lawyer primes him to show how
the opposite side will twist every word the says, by finding some way
to deliberately misinterpret it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top