Differences between C++ and Java

P

Pep

Roedy said:
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.

Paranoia
 
R

Roedy Green

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.

I think both you are not as interested in learning, as you are in
playing a game of one upmanship. I don't want to play.

What is doubly infuriating is that Oliver is very intelligent but also
inexperienced and he likes to mercilessly beat dead horses and dead
fleas. I just can't be bothered with him any more. I don't have enough
energy. To me he is like a rambunctious intelligent two year old, and
I am a very old grandfather. It is not that he is particularly wicked,
it is just I don't have the energy to deal with him.
 
P

Pep

Roedy said:
I think both you are not as interested in learning, as you are in
playing a game of one upmanship. I don't want to play.

What is doubly infuriating is that Oliver is very intelligent but also
inexperienced and he likes to mercilessly beat dead horses and dead
fleas. I just can't be bothered with him any more. I don't have enough
energy. To me he is like a rambunctious intelligent two year old, and
I am a very old grandfather. It is not that he is particularly wicked,
it is just I don't have the energy to deal with him.

Wow, you are so self conceited it's unreal and yet you claim to be
intelligent.

All I have seen is someone that is not prepared to listen to someone else's
point of view if it is different to there own.
 
B

Bjorn Abelli

I think both you are not as interested in learning, as you are in
playing a game of one upmanship. I don't want to play.

What is doubly infuriating is that Oliver is very intelligent but also
inexperienced and he likes to mercilessly beat dead horses and dead
fleas. I just can't be bothered with him any more. I don't have enough
energy. To me he is like a rambunctious intelligent two year old, and
I am a very old grandfather. It is not that he is particularly wicked,
it is just I don't have the energy to deal with him.

I have constrained myself not to engage in this debate,
but I don't think I can hold myself anymore, as I believe
you're both right...

....and wrong...

I have the greatest respect for Roedy, as I have read several of his essays,
and I agree on his political views on those matters I've read. Keep it up!

I have also made use of his pages on Java in several occasions in this
newsgroup, as it's an invaluable resource to the Java community.

Though some of the comments Oliver made stems from some misconceptions, I
think the debate as such doesn't need to be brought to this low level.

There are some things that *can* be compared between C++ and Java, there are
some things that *can't* be compared between C++ and Java.

One of the problems is that there *do* exist a "standard" on C++ as defined
by ANSI.

Sun withdrew their application for making Java standardized, and kept Java
as a proprietary of Sun.

As such, they unfortunately can't be compared on the exact same grounds.

There will always be differences in whether you talk about them as "just"
languages or as "bigger concepts", and especially in the latter case.

I believe those have been mixed up in this debate, and I'm of the opinion
that you *can't* compare ANSI-C++ (which includes the STL) on the one hand,
and the complete Java platform as defined by Sun on the other. As such they
are two different animals...

The comparison would have been a lot different if Java had been compared to
e.g. Microsoft's or Borland's distributions of C++.

When you do compare C++ with Java, it's better to spell out where the C++
standard doesn't have corresponding parts in the comparison, and to differ
the comparison of the languages from the comparisons of C++ with Java as
"bigger concepts".

// Bjorn A
 
J

Jeffrey Schwab

Jaakko said:
This is orthogonal to Oliver's (correct) understanding (and also
wrong: function pointers are not compatible with void pointers).

Good point, that certainly is an exception to what I said. :)

I don't think it happens to matter in this case, though. It fits the
parallel with Java, since there are no Java references to methods. (If
we're going to count proxy objects like java.lang.reflect.Method, we
should also count C++ functors, whose addresses can be assigned to void*.)
In
C++ you don't have to use objects through pointers, since references
work just as polymorphically.

Right, but I think C++ pointers are the correct analog for Java
references in all but syntax.
And there is no generic reference type.

I'm not really saying void* counts as a "generic" reference type,
especially since "generic" has special meanings in both languages.
Oliver's metric was:

no "Foo" such that for all "bar",
"bar instanceof Foo" returns true

I think the C++ for this is roughly:

no "Foo" such that for "p",
"dynamic_cast<Foo*>(p)" evaluates true
for any pointer "p"

Unless p is a pointer to function, the "Foo" does exist, and it's called
void. Java doesn't have references to functions, so I think this caveat
is OK.
 
J

Jeffrey Schwab

Jeffrey said:
no "Foo" such that for all "bar",
"bar instanceof Foo" returns true

I think the C++ for this is roughly:

no "Foo" such that for "p",
"dynamic_cast<Foo*>(p)" evaluates true
for any pointer "p"

Unless p is a pointer to function,

Or null, of course!
 
R

Roedy Green

Though some of the comments Oliver made stems from some misconceptions, I
think the debate as such doesn't need to be brought to this low level.

I quietly plonked Oliver somewhat before the C++ debate started. I
want to reiterate, I did this to conserve energy. I don't have the
energy to deal with Oliver. Because of health problems, I can rarely
stay awake for more than a few hours at a time. It is extremely
exhausting debating with him. I have so many things I want to
accomplish before I die, and he keeps "trapping" me into wasting my
time by posting false statements that I feel compelled to correct. I
am not recommending others follow suit.

I don't know what he said in that C++ debate. I studiously avoided
even reading his words that others quoted.

The debates where my patience wore thin were the ones about the
meaning of multiplatform, techniques of supporting JVMs, native
methods and pure Java.

It is also a bit of grandmothers sucking eggs. I find it galling
being lectured by a whipper snapper who has never written an
interpreter or a line of assembler.
 
A

Andrew Thompson

Roedy said:
..I studiously avoided
even reading his words that others quoted.

<bemused>
Which is something that is a lot easier to do
when attribution lines are more specific than.
"'X' wrote, quoted or indirectly quoted someone who said :"
</bemused>
 
O

Oliver Wong

Pep said:
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 :)

Yes, that's the position I'm taking: That the JVM is emulating a
"theoretical platform" [1]. I don't know what definitions Roedy is using,
but for me, if you have to data that semantically represents instructions
for a computer of some sort, and you have to apply transformations to that
data before actually sending it to the host computer, then emulation is
occuring.

So when you're executing an EXE file on the Windows architecture, the
machine code is just being sent directly to the CPU, with no transformation;
hence, no emulation. If you want to "run" your favorite SNES game, and you
use a process, such as ZSnes, to translate the op codes for the SNES ROM
into instructions which your Intel x86 processor can understand, then there
is emulation going on.

The Bytecode needs to be transformed before it can run, so I claim that
emulation is occuring when you run a Java program using a JVM.

As for the argument of "it's not an emulator if the thing it 'emulate'
doesn't exist yet", first of all see [1], and second, consider this:
Researchers are exploring the power of quantum computers. For example, we're
relatively confident that they are not more powerful than Turing Machines,
but there are still some open questions. Of course, we don't actually HAVE
quantum computers yet, but we can emulate their behaviour for small
programs. I think most people will still call this "emulation", even though
the platform being emulated doesn't exist (yet).

- Oliver

[1] Note that supposedly there do exist actual physical chips that can run
bytecode directly. I had a discussion about this recently somewhere on
usenet, but I can't remember where. So this platform might not be as
"theoretical" as some people claim. Upon request, I suppose I could do a
google search to find the thread, though interested people could do the
same.
 
O

Oliver Wong

Pep said:
Roedy Green wrote:

Wow, you are so self conceited it's unreal and yet you claim to be
intelligent.

All I have seen is someone that is not prepared to listen to someone
else's
point of view if it is different to there own.

Let's just drop it, Pep. I'm interested in discussing the topic further
(that is, the topic of JVMs, etc.; not of whether one person is right or
wrong), but if Roedy isn't, there's no point in forcing him to.

- Oliver
 
O

Oliver Wong

Pep said:
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.

Sorry, I was considering only kits which you could get "for free" (as in
beer, not as in freedom). It's true that when you're willing to open up your
wallet, you can get a lot more.

- Oliver
 
O

Oliver Wong

Oliver said:
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."

I've never used the JET products, but from my understanding of the
excerpt you gave, there are two products here: One is called "Excelsior JET
Optimizer" and the other is "Excelsior JET Runtime". While "Runtime" is
indeed a JVM, the excerpt makes it sounds like "Optimizer" is a compiler
which can produce native Intel x86 executables which can run without a JVM.

- Oliver
 
C

Chris Uppal

Oliver said:
So when you're executing an EXE file on the Windows architecture, the
machine code is just being sent directly to the CPU, with no
transformation; hence, no emulation.

FWIW, the i86 instructions and register set don't really correspond to the
chip's architecture -- there's another layer of emulation in there. The IA-32
architecture is just as "virtual" as the JVM (although of a very different
design, and low-level rather than high-level).

Modern software sits on top of an N-level stack of interpretation[*]; there's
not (IMO) much point in talking about whether something is emulated or
virtual -- everything is both ;-)

([*] Taking JITing to be just another interpretation technique for these
purposes.)

-- chris
 
M

Mike

zero said:
It should be said that C++ gurus say "the preprocessor is evil" (with
nuances of course). Very much simplified, the consensus is that the
preprocessor is a remnant from the C days, and should be avoided in C++
(replacing macros for example with inline methods)

The pre-processor *is* evil - but like most things evil, is the only (or at
least the cheapest, by the most applicable measure of expense at the time)
way to get things done in the real world when you really need it.

TYPEDEF is also missing. Generics only help with some uses of typefdef.
Many a time I have rued its absence in Java when I want to change a semantic
class of values (and all the paramters and temps throughout the program that
take this type) from 8 to 16 bits, for example.
The only way to do this now is to make sure one uses very consistent
variable naming, and do human-aided (or very complex regex) pattern
matching.
IFAICT, refactoring tools could do this for you, I assume it's hard in that
the spanning-graph of type propogation could get out-of-control becuase at
some point you don't want that type and you explicitly or implicitly cast it
up/down, and the refactoring code would have no way of knowing where to
stop.

m
 
O

Oliver Wong

Chris Uppal said:
Oliver said:
So when you're executing an EXE file on the Windows architecture, the
machine code is just being sent directly to the CPU, with no
transformation; hence, no emulation.

FWIW, the i86 instructions and register set don't really correspond to the
chip's architecture -- there's another layer of emulation in there. The
IA-32
architecture is just as "virtual" as the JVM (although of a very different
design, and low-level rather than high-level).

Modern software sits on top of an N-level stack of interpretation[*];
there's
not (IMO) much point in talking about whether something is emulated or
virtual -- everything is both ;-)

My head is exploding.

You are of course correct. Within a modern processor, all sorts of
"magic" is happening such as instruction re-ordering, which can be seen as
"instruction transformations" and thus, under my (now useless) definition,
"emulation".

I like your "stack of interpretation" concept, and am exploring it
further [1]. To me, this seems to further weaken the distinction between the
JVM and a traditional emulator.

Since "everything is emulation", I tried to find a more useful
definition for "emulator". Wikipedia gives this one: "A software emulator
allows computer programs to run on a platform other than the one for which
they were originally written." Unfortunately, this doesn't seem to help move
the debate in one direction or the other: Java programs are obviously
written for the Java Platform.

But when you're running a Java program on your computer, is it then
running on the Java Platform (i.e. no emulation)? Or is it running on (for
example) the Windows XP platform (i.e. yes emulation)? Given the stack-like
nature of interpretation, both statements are true at the same time!

- Oliver

[1] In the way that the TCP or OSI network stack provides to the layer above
it services to facilitate communication, it seems that this stack provides
to the layer above it services to facilitate computation. What is at the
top? It seems it is the human mind, which is using the computer's services
to aid it. What is at the bottom? CPUs relying on transistors? Transistors
relying on the (semi-)conductivity of silicon? At the very lowest levels, it
seems difficult to distinguish when we are looking at the interface of the
services and when we are looking at the implementation of those services.
 
M

Monique Y. Mudama

I quietly plonked Oliver somewhat before the C++ debate started. I
want to reiterate, I did this to conserve energy. I don't have the
energy to deal with Oliver.

This seems oddly inconsistent with your claim that we should follow
only the words in the discussion while disregarding the author.

I am honestly baffled at some of your recent posts. You have sometimes
taken what seem to be logically inconsistent stances, and you have taken
offense where I believe none was intended. The result is that I have
to read all of your posts with a grain of salt, even though I know
that you have much to contribute to the discussion.
 
L

Luc The Perverse

Monique Y. Mudama said:
This seems oddly inconsistent with your claim that we should follow
only the words in the discussion while disregarding the author.

I am honestly baffled at some of your recent posts. You have sometimes
taken what seem to be logically inconsistent stances, and you have taken
offense where I believe none was intended. The result is that I have
to read all of your posts with a grain of salt, even though I know
that you have much to contribute to the discussion.


Probably (and understandably) Tom St Denis syndrome. When you do nothing
but try to help and teach people, and receive nothing in return but
criticism, flames and angry people. It gets old!
 

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,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top