Java Forum / General / December 2005
Differences between C++ and Java
Roedy Green - 16 Nov 2005 13:22 GMT A link to an essay on the differences between C++ and Java in the Java glossary has died, so I concocted this little essay to replace it at http://mindprod.com/jgloss/cpp.html
In Java, the sizes of int, long etc. are rigidly defined in terms of bits. In C++ they are platform-dependent.
In Java, the JVM behaves at if it were big endian, even if internally it is actually little-endian. In C++, the endianness is platform dependent. In Java, garbage collection of unreferenced objects is automatic. In C++, you manually manage memory.
In Java, references are constrained to point only to the beginnings of objects. In C++, you can do arithmetic on pointers and make pointers point anywhere in the address space.
In Java you cannot overload operators. In C++, you can.
In Java, by default methods are virtual (overrideable). In C++, by default, methods are non-virtual.
Java object code (class files containing JVM byte codes) will run unmodified on any platform. C++ object code must be first linked to produce an executable containing platform-specific machine instructions. It will run only on one platform.
Java checks all subscripts that they are in bounds and all casts for validity. C++ does not.
Java requires a JVM to execute. C++ programs are usually freestanding. Java does not use a preprocessor. C++ makes extensive use of a macro preprocessor.
Anything else important to say?
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Pep - 16 Nov 2005 13:30 GMT > A link to an essay on the differences between C++ and Java in the Java > glossary has died, so I concocted this little essay to replace it at > http://mindprod.com/jgloss/cpp.html > > In Java, the sizes of int, long etc. are rigidly defined in terms of > bits. In C++ they are platform-dependent. You could argue that in Java they are still platform dependent, in that they are set as per the Java VM (virtual machine) which is always the same regardless of the physical machine that it is running on.
> In Java, the JVM behaves at if it were big endian, even if internally > it is actually little-endian. In C++, the endianness is platform > dependent. Again you could argue that in Java the endianess is platform dependent, i.e.e as per the Java VM (virtual machine).
> > In Java, garbage collection of unreferenced objects is automatic. In > C++, you manually manage memory. But this does not guarantee when the garbage collection will be performed in Java, whereas in C++ you can determine when it will happen.
> In Java, references are constrained to point only to the beginnings of > objects. In C++, you can do arithmetic on pointers and make pointers [quoted text clipped - 9 lines] > produce an executable containing platform-specific machine > instructions. It will run only on one platform. Again, arguably Java byte code will only run on one platform, i.e the Java VM (virtual machine).
> Java checks all subscripts that they are in bounds and all casts for > validity. C++ does not. [quoted text clipped - 4 lines] > > Anything else important to say? Not looking to cause an argument, just playing with words :)
Roedy Green - 16 Nov 2005 15:37 GMT >You could argue that in Java they are still platform dependent, in that they >are set as per the Java VM (virtual machine) which is always the same >regardless of the physical machine that it is running on. Dependent implies change with the thing depended on changes. The sizes are invariant in Java. They are part of the language spec. They apply even when there is no JVM, e.g. Jet.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 16 Nov 2005 15:39 GMT >Again you could argue that in Java the endianess is platform dependent, >i.e.e as per the Java VM (virtual machine). Unless there is something new in nio, I don't think you can get a program to produce different endianness files or socket streams on different machines with the same code. In other words, it does not depend on the platform. That even applies to 64 bit jvms.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Thomas Hawtin - 16 Nov 2005 18:23 GMT > Unless there is something new in nio, I don't think you can get a > program to produce different endianness files or socket streams on > different machines with the same code. In other words, it does not > depend on the platform. That even applies to 64 bit jvms. The only thing I can think of involves multi-threaded access to non-atomic longs (or doubles) on 32-bit platforms. I think the half written writes will give the exact opposite of the half read reads.
java.nio.ByteOrder.nativeOrder() gives the byte order of the underlying hardware. But you wouldn't be able to tell if it was lying. And it doesn't support PDP-endian.
Tom Hawtin
 Signature Unemployed English Java programmer http://jroller.com/page/tackline/
Roedy Green - 16 Nov 2005 15:40 GMT >But this does not guarantee when the garbage collection will be performed in >Java, whereas in C++ you can determine when it will happen. There is no official GC in C++ is there? It is always an add on. In Java you can suggest when a good time to run might be, but you cannot force it.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Benji - 16 Nov 2005 19:04 GMT >>But this does not guarantee when the garbage collection will be performed in >>Java, whereas in C++ you can determine when it will happen.
> There is no official GC in C++ is there? It is always an add on. In > Java you can suggest when a good time to run might be, but you cannot > force it. I think he's referring to delete and free. it's technically "garbage collection" - just not automatic garbage collection. =P
 Signature Of making better designs there is no end, and much refactoring wearies the body.
Roedy Green - 16 Nov 2005 15:41 GMT >Again, arguably Java byte code will only run on one platform, i.e the Java >VM (virtual machine). You are in the wrong major. Take up corporate law.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 16 Nov 2005 15:50 GMT On Wed, 16 Nov 2005 15:41:14 GMT, Roedy Green <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or indirectly quoted someone who said :
>>Again, arguably Java byte code will only run on one platform, i.e the Java >>VM (virtual machine). > You are in the wrong major. Take up corporate law. In java terminology Platform-independent refers to the ability to run Java byte code on many different platforms if they have a JVM implementation.
Platform refers then not to the JVM but to the OS and hardware that host it.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Pep - 16 Nov 2005 15:59 GMT > On Wed, 16 Nov 2005 15:41:14 GMT, Roedy Green > <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or [quoted text clipped - 10 lines] > Platform refers then not to the JVM but to the OS and hardware that > host it. Like I said, I'm only playing on words.
Please don't get me wrong, I find Java to be a really useful language and certainly prefer the extensibility and ease of use of the language compared to that of C++.
Pep.
Oliver Wong - 16 Nov 2005 20:04 GMT >> On Wed, 16 Nov 2005 15:41:14 GMT, Roedy Green >> <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or [quoted text clipped - 17 lines] > compared > to that of C++. I'm in agreement with Pep here. What we essentially have here is a programming language (Java) for which compilers output a something (bytecode), and for which we have emulators (JVMs) for running on all the platforms which cannot "natively" run that output, whatever that may mean.
However, this does not directly address the issue of whether java is "Platform Independent" or not. The resolution to that issue depends on the definition used for "Platform Independent".
I don't think that it is "useful" to say that a language is platform independent. I use "useful" here to mean that if the label "platform independent" is useful, then there should exist some things which are platform independent, and some things which are not.
In theory, for any (language, platform) pair, a compiler could exists which compiles programs written in that language and produces native code for that platform. For example, you could have a compile which takes Intel x86 assembly with SS3 extensions and produces a native RISC excutable binary. Does that mean that "Intel x86 assembly with SS3 extensions" is platform independent? Probably not. With this interpretation, ALL languages are platform independent, so it is not a "useful" definition.
Can we say that a particular sequence of bits is platform dependent? If we have a .EXE intended to "run" on a Win32 platform, we might try to "run" it on a MacOSX, or Linux platform and notice that it fails to give the desired behaviour. Does this mean that this sequence of bit is platform dependent? Maybe. But what if, by some amazing coincidence, the same sequence of bit could be interpreted as a valid executable file on two different platforms, but the behaviour would vary wildly? E.g. we have two different processors with different instruction sets, and the instruction represented by the word "0x00000001" on processor A means "add as an integer the value in register 1 to the value in register 2 and store it in register 0" while that same word "0x00000001" means "pop 2 values off the stack and multiply them together, and push the result back onto the stack" for processor B.
In the above scenario, the bitstream is a valid program on both platforms, and yet yields completely different results. It seems then that we should not say that a particular sequence of bits is platform dependent, but rather a (sequence of bit, intended behaviour) pair is platform dependent. Of course, as soon as we let "intended behaviour" slip into our definition, we're REALLY entering murky waters.
We can take a much more pragmatic (though perhaps just as equally "murky") approach to defining it by asking this: "Does the user have to worry about what platform they're running on to use our program?" This definition might seem overly Java-centric though, in the sense that it was specifically crafted so that the answer would be "No" for Java and "Yes" for C++.
My conclusion is that if you're target audience is "end-users", use the pragmatic definition listed above. It probably conveys the intended meaning using terms that are at least passingly familiar with the audience.
If the target audience are compiler-writers, system engineers, or other people who are interested in technical details, just avoid the term "platform independent" altogether and say what you really mean.
- Oliver
Roedy Green - 16 Nov 2005 20:38 GMT > I don't think that it is "useful" to say that a language is platform >independent. Then you misunderstand something fundamental about Java, which we have gone over before, (trying to get you to understand the difference between native and byte code methods).
Java goes to great lengths to be platform independent. If you write a program in 100% pure java (none of your own platform dependent native methods) then your code should work on ANY platform that supports the JVM without any modifications or tweaking. This is VERY unlike C/C++.
Java does not LET you write code that depends on the platform. You CAN'T write a program in 100% pure java to tweak the windows registry, or get the Unix task number. That is deliberate. It is not being mean; it is to ensure your code will run everywhere.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 16 Nov 2005 21:07 GMT >> I don't think that it is "useful" to say that a language is platform >>independent. > > Then you misunderstand something fundamental about Java, which we have > gone over before, (trying to get you to understand the difference > between native and byte code methods). Of course, from my perspective, it is you who is misunderstanding. ;)
For the discussion on native vs byte code methods, indeed, I was in error in that I had forgotten of the existence of the "native" keyword in Java. I think your mistake, though, is in confusing the concept of Java, the programming language, with Java, the platform. It's a common confusion, as both concepts have the same name (i.e. "Java"), but they are two distinct concepts. Sun officially acknolwedges this dinction, and you will frequenty see in their documentation reference to "the Java language" and "the Java platform" as two distinct concepts, for example.
> Java goes to great lengths to be platform independent. If you write a > program in 100% pure java (none of your own platform dependent native > methods) then your code should work on ANY platform that supports the > JVM without any modifications or tweaking. This is VERY unlike C/C++. The counter argument to this is that the JVM is not qualitatively different from a traditional emulator. You could write an emulator such that C++ programs written for Unix run on Windows (see Cygwin) and vice versa (see Wine). Does this mean that C++ is also platform independent? Like I said in my previous post, I don't think it's useful to say a *LANGUAGE* is platform independent, because emulators, compilers or virtual machines could be constructed for any language/platform pair.
> Java does not LET you write code that depends on the platform. You > CAN'T write a program in 100% pure java to tweak the windows registry, > or get the Unix task number. That is deliberate. It is not being > mean; it is to ensure your code will run everywhere. I'm not sure about the truth-value of your assertion here, as it depends on how you define a lot of things. Would you consider a Java program in which the keyword "native" never appears to be a 100% pure Java program? If so, I'm relatively confident I could write a Java program without ever using the "native" keyword which does one thing on Windows, and does something different on Unix.
Anyway, I don't see how that truth-value has any effect on the original claim of "I don't think that it is 'useful' to say that a language is platform independent". Are you saying that there DOES exist an unambiguous definition for "platform independent" which can be applied to solely programming languages (and not to the various compilers, interpreters, virtual machines, and other tools that work with the language) which everyone should adopt? If so, what is that definition?
If the definition says anything about what platforms programs written in the given language "runs" on, then I argue that this definition does involve the compilers, interpreters and virtual machines, and not just the programming language.
This is why I believe that a programming language in isolation should not be said to be "platform independent" or not. Maybe I'm wrong, but I can't think of any reasonable definition that doesn't involve the tools mentioned above.
- Oliver
Roedy Green - 16 Nov 2005 21:42 GMT > I'm not sure about the truth-value of your assertion here, as it depends >on how you define a lot of things. Would you consider a Java program in >which the keyword "native" never appears to be a 100% pure Java program? I am getting really impatient with you. Please google "100% pure java" so that you know what the term means first.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 16 Nov 2005 22:19 GMT >> I'm not sure about the truth-value of your assertion here, as it >> depends [quoted text clipped - 3 lines] > I am getting really impatient with you. Please google "100% pure java" > so that you know what the term means first. Okay, I did as you asked, and I was surprised to find out that "100% Pure Java" is actually a standardized term from Sun. If you knew this, Roedy, you could have just said so right away. =P
But it also looks like the term has fell into disuse by Sun. I could not find any reference to it on the main site, though I did find this PDF on Sun's archives entitled "Guidelines for achieving the 100% Pure Java Standard".
http://java.sun.com/products/archive/100percent/4.1.1/100PercentPureJavaCookbook -4_1_1.pdf
The definition of what is and what isn't "100% Pure Java" sure is long! The PDF itself is 61 pages. Here are some choice quotes to illustrate how difficult it is to define this term:
<quote> The purpose of the purity standard is to provide reasonable and economic assurance that the 100% Pure Java program design guidelines have been followed, and that the program will run on any Java Compatible platform. The process is not intended to be immune to subversion, but is intended to be a chance for you to provide evidence of the portability of your product in a uniform and consistent way. </quote>
In other words, there isn't a hard and fast rule as to what is 100% Pure Java and what isn't.
<quote> There is a critical distinction-and connection-between portability and purity. Most people think of a portable program as one that produces the same results on any platform. This is actually a very imprecise definition. </quote>
This quote appears on page 15 of the PDF, and on page 16 they show an example of 2 programs. Both are "portable", but one is "pure" while the other one is not. They don't explain the distinction further (not as far as I can see anyway).
<quote> Variances were previously granted to developers making variance requests to Sun's Variance Council. </quote>
This refers to the fact that Sun used to distribute a tool to check for "100% Pure Java" compliance by analyzing your Java source code. The tool apparently gave some false positives, and rather than "fix" the tool (which may have been on the same order of difficulty as solving the halting problem), you would instead submit an explanation for your "variance" to Sun's Variance Council.
I only skimmed over the PDF, but it seems quite obvious to me that the term "100% Pure Java" is not very well defined at all. Incidentally, the Google search also turned up this site:
http://tolstoy.com/impure.html
which claims to link to an internal Sun document written by the Program Manager in which, basically, Sun admits that the term "100% Pure Java" is a problematic one. Unfortunately, the link seems to be broken and I could not find it via Google cache. If anyone could ressurect that document, I'd be very interested to see it.
- Oliver
Roedy Green - 16 Nov 2005 21:46 GMT >The counter argument to this is that the JVM is not qualitatively >different from a traditional emulator. You could write an emulator such that [quoted text clipped - 3 lines] >platform independent, because emulators, compilers or virtual machines could >be constructed for any language/platform pair. You just jerking my chain.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 17 Nov 2005 17:01 GMT >>The counter argument to this is that the JVM is not qualitatively >>different from a traditional emulator. You could write an emulator such [quoted text clipped - 7 lines] > > You just jerking my chain. No, I'm serious. What is the difference, in your opinion, between a JVM and an emulator?
- Oliver
Pep - 18 Nov 2005 11:48 GMT >>>The counter argument to this is that the JVM is not qualitatively >>>different from a traditional emulator. You could write an emulator such [quoted text clipped - 13 lines] > > - 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 :)
Oliver Wong - 18 Nov 2005 15:37 GMT >> No, I'm serious. What is the difference, in your opinion, between a >> JVM [quoted text clipped - 8 lines] > 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.
Chris Uppal - 18 Nov 2005 16:38 GMT > 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
Oliver Wong - 18 Nov 2005 19:20 GMT >> 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 [quoted text clipped - 10 lines] > 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.
Thomas G. Marshall - 01 Dec 2005 00:13 GMT Chris Uppal said something like:
>> 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 [quoted text clipped - 6 lines] > > Modern software /All/ 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 ;-) Smiley taken, but you're correct, smiley or no.
No matter how simple the cpu, each component of it can be broken down into a number of "things". The list of the modern day hooey that could be these "things" goes far beyond my hardware understanding. In the old days, it might be comprised of microcode, mini-logic arrays, and gates.
What we have here is yet another abstraction ladder. There is no clear distinction as to what is really the cpu instruction:
The CPU add instruction The CPU parts responsible for the add The electron propagation responsible for them parts The quark spin and positioning responsible for the electron propagation (more hooey over my head)
In java's case we just continue the stack skyward
Java add program code responsible for the java add The CPU instructions responsible for that program code The CPU parts responsible for those instructions The electron propagation responsible for them parts The quark spin and positioning responsible for the electron propagation (more hooey over my head)
Wha'ever.
> ([*] Taking JITing to be just another interpretation technique for these > purposes.) > > -- chris
 Signature Forgetthesong,I'dratherhavethefrontallobotomy...
Roedy Green - 16 Nov 2005 21:47 GMT >Would you consider a Java program in >which the keyword "native" never appears to be a 100% pure Java program? There is on such thing as a Java program that uses no native methods. The core methods of Java are necessarily native methods. That is not what 100% pure java means.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Benji - 16 Nov 2005 22:37 GMT >>Would you consider a Java program in >>which the keyword "native" never appears to be a 100% pure Java program? > There is on such thing as a Java program that uses no native methods. > The core methods of Java are necessarily native methods. That is not > what 100% pure java means. OK, now you're just being a jerk. Either stop replying to him, or explain what you mean.
 Signature Of making better designs there is no end, and much refactoring wearies the body.
Roedy Green - 16 Nov 2005 20:40 GMT > I'm in agreement with Pep here. Then you too should drop out of computer science and take up the art of twisting the truth for profit, namely corporate law. Both of you are just playing silly word games.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 16 Nov 2005 21:31 GMT >> I'm in agreement with Pep here. > > Then you too should drop out of computer science and take up the art > of twisting the truth for profit, namely corporate law. Both of you > are just playing silly word games. http://mindprod.com/jgloss/newsgroups.html#GIFTHORSE
My intent was to provide some constructive criticism. I apologize if I was too subtle in my efforts. Here's the sequence of events, and the rational for my actions from my perspective:
You wrote an essay about the difference between C++ and Java. Pep pointed out some problems with the statement "Java is platform independent". You dismissed Pep's point. I agree with the Pep's point, and wanted to indicate that he was not the only person to feel that the statement has some problems, which leads to the possibility that other people may feel the same way too, but chose not to post about it. I (subtly?) ended my post with the advice of "consider your audience". This is difficult in your (Roedy's) case, because the MindProd site is oriented towards people with a technical background in Java, but to the "newbie" segment of that population, so it is somewhat of a grey area whether the essay should strive for technical correctness versus ease of understanding. If I were faced with the same problem, I'd give the "easy to understand" explanation first, with notes that there may be some technical problems with it, and a link (perhaps as a footnote) to the more complex, but technically correct answer.
In the end, it's your site, and your essay, so you can write whatever you want. I had (perhaps incorrectly) assumed you were looking for some feedback.
- Oliver
Pep - 17 Nov 2005 11:22 GMT >>> I'm in agreement with Pep here. >> [quoted text clipped - 32 lines] > > - Oliver Wow, perhaps this is a case of too academic or too java centric?
I think that Roedy should lighten up a bit here. He asked for feedback which I originally gave light heartedly and pointed out that I am not an enemy of the "Java takeover the world" movement :)
I guess I should have read between the lines and seen that what he was actually asking for feedback that agrees entirely with his point of view and perhaps pats him on the back for being a clever little chappy and definitely not anything slightly critical, even in jest.
Roedy Green - 17 Nov 2005 12:26 GMT >I think that Roedy should lighten up a bit here. He asked for feedback >which I originally gave light heartedly and pointed out that I am not an >enemy of the "Java takeover the world" movement :) 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.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Pep - 17 Nov 2005 13:11 GMT >>I think that Roedy should lighten up a bit here. He asked for feedback >>which I originally gave light heartedly and pointed out that I am not an [quoted text clipped - 3 lines] > getting too frustrating being contradicted over and over by someone so > inexperienced. Big of you :->
Roedy Green - 17 Nov 2005 16:11 GMT >> 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 :-> 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.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Pep - 18 Nov 2005 11:45 GMT >>> 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 [quoted text clipped - 5 lines] > 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 :->
Roedy Green - 18 Nov 2005 12:06 GMT >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.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Pep - 18 Nov 2005 12:30 GMT >>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 [quoted text clipped - 9 lines] > 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.
Oliver Wong - 18 Nov 2005 15:42 GMT > 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
Bjorn Abelli - 18 Nov 2005 13:09 GMT "Roedy Green" wrote...
>>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 [quoted text clipped - 9 lines] > 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
Roedy Green - 18 Nov 2005 14:53 GMT On Fri, 18 Nov 2005 14:09:56 +0100, "Bjorn Abelli" <bjorn_abelli@DoNotSpam.hotmail.com> wrote, quoted or indirectly quoted someone who said :
>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.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Andrew Thompson - 18 Nov 2005 15:08 GMT > ..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>
 Signature Andrew Thompson physci, javasaver, 1point1c, lensescapes - athompson.info/andrew Currently accepting short and long term contracts - on Earth.
Monique Y. Mudama - 19 Nov 2005 06:35 GMT > 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.
 Signature monique
Ask smart questions, get good answers: http://www.catb.org/~esr/faqs/smart-questions.html
Luc The Perverse - 19 Nov 2005 07:18 GMT >> 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 [quoted text clipped - 8 lines] > 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!
 Signature LTP
Roedy Green - 19 Nov 2005 15:54 GMT On Fri, 18 Nov 2005 23:35:35 -0700, "Monique Y. Mudama" <spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone who said :
>This seems oddly inconsistent with your claim that we should follow >only the words in the discussion while disregarding the author. I am having trouble with the things Oliver is saying. In my proposed experiment, you would still be able to plonk anonymous voices. The idea was you just you don't prejudge every statement by who said it. You might get away from the ego games of who said X first, who made a mistake, who caught it, whose on my side, who is part of X's posse. The game I would hope would diminish is where A makes a statement. B says "It's wrong". A says that's not what I meant. B says "Yes you did, therefore you are an idiot, POINT!"
I think all newsreaders should have a timeout on a plonk, so that you review the behaviour every once in a while.
Plonking is not like banning someone to outer darkness. Other people can still converse. You can look on it like trimming your set of magazine subscriptions to a reasonable number. You can't read everything, so you might as well be selective.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 19 Nov 2005 16:22 GMT On Fri, 18 Nov 2005 23:35:35 -0700, "Monique Y. Mudama" <spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone who said :
>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. I can't respond to a broad brush charge like that. Please enumerate these stances.
In the debate about ternary for example, I felt you were being unfair by using a straw men argument. I explained the definition of clarity I was using when I claimed it was possible to objectively measure it. You could even do it with a multiple choice test.
Thomas did not originally intended to offend, and his continued use of the insult is definitely intended to offend. It is a f.ck you. I was not asking much, just that he stop comparing all my posts to worthless disgusting slime.
If he did that to random strangers on the street, he would have a nose beaten to a pulp by now.
I am quite ill with HIV. I feel all the time as though I had just completed a marathon, even after a 12 hour sleep. My muscles are like rubber. I am less resistant than usual to the slings of Internet discussion. I have to withdraw from the people that I am getting in fights with. I have very little energy each day and it is maddening when it gets frittered in bickering.
At the same time, I figure I owe people an explanation why am cutting them off.
There seem so be something in the air. Congress and the Senate too are at each other's throats.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Monique Y. Mudama - 19 Nov 2005 18:51 GMT > On Fri, 18 Nov 2005 23:35:35 -0700, "Monique Y. Mudama" ><spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone [quoted text clipped - 6 lines] > I can't respond to a broad brush charge like that. Please enumerate > these stances. I questioned whether to post that even as I did, in part because I don't have the interest in backing it up with specifics, and in part because even if I did, it would simply lead to an argument with no point. It would be he said/she said, literally. It's simply an impression I've gotten. It wasn't so much intended as an attack on you, but it's hard to say something like that without coming across that way. It's more like, hey, Roedy, maybe you could consider going a little easier on people?
[snip]
> Thomas did not originally intended to offend, and his continued use > of the insult is definitely intended to offend. It is a f.ck you. I [quoted text clipped - 3 lines] > If he did that to random strangers on the street, he would have a > nose beaten to a pulp by now. Okay, see, this is where I completely disagree with you. Personally, I find your attribution line, or more accurately, its implied disregard for quoting accurately, to be extremely irritating; whereas Thomas' attribution line slips under my radar and wouldn't even have have been noticed by me if you didn't keep bringing it up. Your dislike for accurately quoting a person is considered a Big Deal in netiquette; people in most newsgroups apologize for misattributions. Whereas silly attribution lines are pretty common, and almost universally ignored. To my mind, *your* attribution is the one that offends and is a "f.ck you," because it says that you have so little respect for us that you don't even care to get our names right. But note that I've never gone on a campaign to get you to change it, although I have commented on it snidely a few times. I never suggested you should have your nose punched in because of it.
We are in usenet, which has different etiquette than the street. He's not really comparing all your posts to worthless slime, as the content of his responses doesn't in any way suggest that he feels your posts are worthless. It's a silly attribution, and it's not harming anyone, and you're freaking out about it, and I find your response, as I said earlier, baffling. I don't know if he's only using that attribution line for you, now, to tweak you, but I'm dead certain it started out as a generic attribution line for anyone.
I can't even think of anything analogous to an attribution line "in real life", so I can't follow that analogy.
> I am quite ill with HIV. I feel all the time as though I had just > completed a marathon, even after a 12 hour sleep. My muscles are [quoted text clipped - 5 lines] > At the same time, I figure I owe people an explanation why am > cutting them off. I guess my feeling is that there's no need to fight; no need at all.
When I get tired of a discussion, I just stop posting, or maybe post to say, "I'm not interested in continuing this discussion, as it's not going anywhere." I don't resort to calling people names (ie whippersnapper; if Oliver is a whippersnapper, I'm not far off, either, having never bothered to write an interpreter, whatever that has to do with anything. And my only exposure to assembler was a truly awful teacher for one class in college). I feel like sometimes you can be quite rude to people, without any justifiable grounds. But frankly, even when rudeness is justified, it's still better to take the high ground. I find that people respect that.
> There seem so be something in the air. Congress and the Senate too > are at each other's throats. Perhaps.
I can understand being ill and having a short temper because of it. I really can, and if I could make you feel better, I would in a heartbeat. Please know that. I admire your desire to make a difference in the world by helping others. And we all sometimes say grumpy things, or things that sound grumpy or uncharitable, in text. It's the nature of the beast. I just firmly believe that "you catch more flies with honey," and I think that when you establish a posting history that is speckled with grumpiness, you're working at cross purposes to your goal. People who would otherwise learn from you will cut you off.
Anyway, I don't want to be hurtful to you, and I don't really think continuing this discussion would be productive. Either you will recognize what you are doing and put effort towards changing it, or you will not recognize it and simply be offended or baffled. And of course there's a chance that I am the only person who sees this trend, that it's all in my imagination, etc. That's possible, too.
I wish you well and I hope that you will feel at least a little bit better in the near future.
 Signature monique
Ask smart questions, get good answers: http://www.catb.org/~esr/faqs/smart-questions.html
Oliver Wong - 21 Nov 2005 16:17 GMT > if Oliver is a whippersnapper, I'm not far off, either, > having never bothered to write an interpreter, whatever that has to do > with anything. And my only exposure to assembler was a truly awful > teacher for one class in college). Just for the record, and for what it's worth, I sort of write interpreters for a living (I write "compiler-like" tools). You'll see me posting on alt.lang.cobol, for example, asking the regulars there questions about the semantics of various keywords, because I'm working on a COBOL interpreter.
As for assembler, like Monique, it was only in an academic setting.
- Oliver
Jeffrey Schwab - 18 Nov 2005 13:53 GMT >>>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 [quoted text clipped - 5 lines] > down" see http://mindprod.com/feedback/peacedeaththreat.html > I just don't want do be involved in any needless fights. Empty page.
<html><body></body></html>
Roedy Green - 18 Nov 2005 15:12 GMT On Fri, 18 Nov 2005 13:53:45 GMT, Jeffrey Schwab <jeff@schwabcenter.com> wrote, quoted or indirectly quoted someone who 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. > >Empty page. Something screwy with it. For me it just kept loading and loading very slowly. It appears to be 0 bytes long and is locked so I can't delete, rename or upload it. I have posted the same document under a new name:
http://mindprod.com/feedback/peacedeaththreat2.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Jeffrey Schwab - 18 Nov 2005 15:29 GMT > On Fri, 18 Nov 2005 13:53:45 GMT, Jeffrey Schwab > <jeff@schwabcenter.com> wrote, quoted or indirectly quoted someone who [quoted text clipped - 11 lines] > > http://mindprod.com/feedback/peacedeaththreat2.html Clearly an emotional topic for a lot of people. Sometimes people don't behave rationally when they are upset.
AndyRB - 16 Nov 2005 17:44 GMT > On Wed, 16 Nov 2005 15:41:14 GMT, Roedy Green > <my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or [quoted text clipped - 7 lines] > Java byte code on many different platforms if they have a JVM > implementation. Which is alot more accurate than you original statement: "Java object code (class files containing JVM byte codes) will run unmodified on any platform"
Lasse Reichstein Nielsen - 16 Nov 2005 22:49 GMT >> In Java, the sizes of int, long etc. are rigidly defined in terms of >> bits. In C++ they are platform-dependent.
> You could argue that in Java they are still platform dependent, in that they > are set as per the Java VM (virtual machine) which is always the same > regardless of the physical machine that it is running on. A more precise characterization of C++ would be that the size of the "int" type is *implementation* dependent. You could easily make two implementations with different size ints on the same platform that are still compliant C++ implementations.
Since the Java Language Specification does not leave room to wiggle, the size of the type "int" is not implementation dependent in Java.
Mentioning the platform is just causing confuzion.
/L
 Signature Lasse Reichstein Nielsen - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'
Robert Klemme - 16 Nov 2005 13:40 GMT > Anything else important to say? Interfaces
Abstract classes are done differently
MI in C++
Generics are different
Java has built in Threading and synchronization mechanisms
If you start talking about standard library functionality then there's a lot more.
robert
Hendrik Maryns - 17 Nov 2005 10:10 GMT Robert Klemme schreef:
>>Anything else important to say? > > Interfaces and multiple inheritance. And in C++ there is no root Object.
> Abstract classes are done differently > > MI in C++ > > Generics are different Friendship does not exist in Java.
> Java has built in Threading and synchronization mechanisms As Oliver Wong pointed out, no expanded variables in Java, no reference semantics either.
Nothing like Javadoc in C++.
H.
 Signature Hendrik Maryns
================== www.lieverleven.be http://aouw.org
Robert Klemme - 17 Nov 2005 11:03 GMT > Robert Klemme schreef: >> [quoted text clipped - 3 lines] > > and multiple inheritance. I mentioned MI.
> And in C++ there is no root Object. What exactly do you mean by this?
>> Abstract classes are done differently >> [quoted text clipped - 3 lines] > > Friendship does not exist in Java. True.
>> Java has built in Threading and synchronization mechanisms > > As Oliver Wong pointed out, no expanded variables in Java, no > reference semantics either. > > Nothing like Javadoc in C++. Well, there's doxygen... Anyway, both are not part of the language IMHO so if pure language capabilities should be compared these don't count.
Kind regards
robert
Hendrik Maryns - 17 Nov 2005 12:18 GMT Robert Klemme schreef:
>>and multiple inheritance. > > I mentioned MI. Ah sorry, didn't recognise the acronym.
>> And in C++ there is no root Object. > > What exactly do you mean by this? What Jaakko Kangasharju said, C++ does not have a rooted hierarchy.
>>Nothing like Javadoc in C++. > > Well, there's doxygen... Anyway, both are not part of the language IMHO > so if pure language capabilities should be compared these don't count. Don't know doxygen. (I'm not a C++ programmer, I only read about it...)
H.
 Signature Hendrik Maryns
================== www.lieverleven.be http://aouw.org
Oliver Wong - 17 Nov 2005 16:12 GMT >> And in C++ there is no root Object. > > 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
Jeffrey Schwab - 17 Nov 2005 17:25 GMT >>> And in C++ there is no root Object. >> [quoted text clipped - 4 lines] > 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.
Jaakko Kangasharju - 18 Nov 2005 07:51 GMT >> 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", [quoted text clipped - 3 lines] > 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.
 Signature Jaakko Kangasharju, Helsinki Institute for Information Technology Olen 37-vuotias aseksuaalinen irlanninsetteriuros
Jeffrey Schwab - 18 Nov 2005 14:22 GMT >>> 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", [quoted text clipped - 6 lines] > 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.
Jeffrey Schwab - 18 Nov 2005 14:33 GMT > no "Foo" such that for all "bar", > "bar instanceof Foo" returns true [quoted text clipped - 6 lines] > > Unless p is a pointer to function, Or null, of course!
> the "Foo" does exist, and it's called > void. Java doesn't have references to functions, so I think this caveat > is OK. Oliver Wong - 16 Nov 2005 19:44 GMT [snip]
> Anything else important to say? I did not know this, but apparently in C++, you can have a variable which is an object (as opposed to a reference to an object). I.e., in C++, you can have:
<C++ Code?> Object* myObject; </C++ Code?>
which is equivalent to
<Java Code> Object myObject; </Java Code>
but you can also have, in C++:
<C++ Code?> Object myObject; </C++ Code>
which has no equivalent in Java. That is to say, in C++, you can have a variable which a pointer to an object, or you can have a variable which is an object itself.
I was quite surprised when I found out about this, and I wonder what the implications of it are when writing C++ code.
See: http://groups.google.com/group/comp.programming/msg/033a72a206f985f9
- Oliver
Roedy Green - 16 Nov 2005 20:16 GMT > I was quite surprised when I found out about this, and I wonder what the >implications of it are when writing C++ code. It drives you nuts. In addition to that there are multiple ways of specifying the same thing.
You need various addressing operators including . -> * [] &
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
zero - 16 Nov 2005 22:05 GMT >> I was quite surprised when I found out about this, and I wonder >> what the [quoted text clipped - 4 lines] > > You need various addressing operators including . -> * [] & On the other hand, it can help make sure you *know* you're handling pointers/references. Many a new Java programmer (including me) has been surprised when trying to create a copy of an object and later changing that copy, only to see unexpected results because they are in fact changing the original - or some member of the original that was a reference to an object.
EdwardH - 16 Nov 2005 19:46 GMT Worms and viruses that use buffer overflows can do it only due to C and C++.
Oliver Wong - 16 Nov 2005 20:09 GMT > Worms and viruses that use buffer overflows can do it only due to C and > C++. That's not nescessarily true. Any time you have a fixed size buffer, you can have a buffer overflow attack. And, AFAIK, every implementation of Java (the platform, not the language) uses fixed size buffers under the hood. In the case of Java, you're essentially trusting that Sun put enough checks to catch any time code tries to write data outside the bounds of the buffer it was assigned to.
I believe when working with low level networking APIs in Java (e.g. the NIO package), you still need to specify a fixed buffer size. If the class library was implemented well, you'd get IndexOutOfBoundsExceptions whenever you tried to write outside of it, but there's always the possibility that there's a bug in the library that might let a buffer overflow attack go through.
- Oliver
zero - 16 Nov 2005 22:08 GMT > Java does not use a preprocessor. C++ makes extensive use of a macro > preprocessor. 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)
Mike - 18 Nov 2005 17:09 GMT >> Java does not use a preprocessor. C++ makes extensive use of a macro >> preprocessor. [quoted text clipped - 3 lines] > 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
Monique Y. Mudama - 16 Nov 2005 23:40 GMT [snip]
> Anything else important to say? It's probably worth mentioning struct and union. A lot of C/C++ people just "assume" you can have a union in Java, and get all blustery when they find out it's not there.
 Signature monique
Ask smart questions, get good answers: http://www.catb.org/~esr/faqs/smart-questions.html
Jaakko Kangasharju - 17 Nov 2005 08:10 GMT > A link to an essay on the differences between C++ and Java in the Java > glossary has died, so I concocted this little essay to replace it at > http://mindprod.com/jgloss/cpp.html > > Anything else important to say? In Java, the class hierarchy has the Object class as its root. C++ does not have a rooted class hierarchy.
In Java, method and field definitions must be inside some class. In C++ you can also define functions and variables independently of classes (and in fact, you don't need to define any classes to write C++ programs).
 Signature Jaakko Kangasharju, Helsinki Institute for Information Technology This space unintentionally left blank
Roedy Green - 17 Nov 2005 10:29 GMT On Thu, 17 Nov 2005 10:10:04 +0200, Jaakko Kangasharju <jkangash@hiit.fi> wrote, quoted or indirectly quoted someone who said
>In Java, the class hierarchy has the Object class as its root. C++ >does not have a rooted class hierarchy. [quoted text clipped - 3 lines] >classes (and in fact, you don't need to define any classes to write >C++ programs). thanks everyone. You can see the aggregate list at http://mindprod.com/jgloss/cpp.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 17 Nov 2005 17:14 GMT > 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
SDB - 17 Nov 2005 20:08 GMT : > thanks everyone. You can see the aggregate list at : > http://mindprod.com/jgloss/cpp.html [quoted text clipped - 8 lines] : : - 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.
zero - 17 Nov 2005 20:27 GMT >: > thanks everyone. You can see the aggregate list at >: > http://mindprod.com/jgloss/cpp.html [quoted text clipped - 14 lines] > 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.
Oliver Wong - 17 Nov 2005 20:29 GMT > : <quote> > : Java has a vast standard library set, including AWT and Swing. C++ has a [quoted text clipped - 14 lines] > 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
SDB - 17 Nov 2005 21:07 GMT : > The Java specification includes treats such as GUI, networking and : > database [quoted text clipped - 15 lines] : 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.
Oliver Wong - 17 Nov 2005 22:00 GMT > : > The Java specification includes treats such as GUI, networking and > : > database [quoted text clipped - 24 lines] > 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.
|
|