Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

diff in c++ and java for ...

 
Sukhadev Patil
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between c++ and java for client-server program?
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One can do pointer arithmetic. Seriously, that question is a little vague. What is it specifically you are trying to evaluate?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java doesn't support pointers.

Memory management is automatically done by JVM with the help of Garbage Collector.

Java doesn't support multiple inheritence.

unlike c++, Java is a platform independent language
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does not support multiple-inheritance but Java provides some of the benefits of multiple-inheritance by providing multiple interface inheritance.

Java does not have destructors. The finalize() should be used judiciously and in Java.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C++ inherits preprocessor directives from C:

#define QUESTION "vague"

Yet another kind of inheritance
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C++ is platform independant, if you stick to the standard libraries, which is a minor problem for C++ in this context.

The main difference between Java and C++ in a network based progam is that there is no sockets support in the standard C++ library(or C for that matter). This is a good and a bad thing. Good because you actually have to learn sockets programming, Java abstracts it to the point where it is very easy to use, but you learn little. This implies that it is a bit more work. This also means that since you are directly using OS functions, it is not platform independant.

The main library for *nix OSes is the Berkley Sockets API. The main library in Windows in winsock, which is heavily based on Berkley, with just enough changes to break compatibility.

There are cross platform networking libraries available if platform independance is important to your project, many are free. Wxwidgets contains a networking library.

IO is a bit clunky in C++ compared to Java, but you don't need to get bogged down in pointers.

Both are great for networking, but if you are learning, stick to the langauge that doesn't hide as many details.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rusty, i think you have a different idea of what "platform independant" means than most people.

"Platform independant" as i understand it, means that you compile it once, and that same executable file can be run on any system (that has a JRE).

it does NOT mean that you write the code, and then compile it on 27 different machines to make 27 different binaries that each can only be run on a specific machine, even if they're all built from the same source code file.
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Platform independant means that it will run on any platform that a compiler/interpreter is available for, with little to no code changes. I have had to slightly alter code twice to get a Java program to work correctly on Linux and XP, so by your definition Java is not platform independant.

Java is platform independant by this definition. So is standard C and C++.

Your defintion implies that only interpreted or hybrid(like Java) languages are platform independant. This is wrong, for two reasons. First is that standard C and C++ doesn't really care about the underlying OS, just like java, perl, ect. Second is that intrepreted languages suffer the same limitation as compiled languages, they don't(sometimes can't) have an interpreter for every platform.

Anyway minor point, and off-topic.

I am curious, what is a lowercase dad?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lowercase comes from the fact that i seldom use the shift key when typing. While i was in the process of adopting my daughter, EFH changed my title to "dad to be". once the adoption was complete, he changed it again to "dad".
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term platform-independent isn't all that blurry: we usually mean "hardware and operating system environment."

The subjective part is in calling things platform-independent and asking whether that's helpful or not. The term suggests there's an advantage over other tools or programs that do the same work; it is not a classification that suggests code can be written totally regardless of the hardware/OS.

C/C++ can be written in a platform-independent manner. With all due respect to the sizeof() operator, however, they are not inherently platform-independent. Highly portable, yes.

Some people argue that Java is not 'truly' platform-independent either. As I see it, those arguments are academic. JDK-supplied classes generally don't require recompilation to run. There are exceptions, but to me this just means platform-independence isn't bulletproof.

The practical benefits of avoiding recompilation are substantial. Would you rather download a JAR file and get straight to work, or would you prefer providing a compiler, running make/ANT files, waiting a few minutes, and hoping everything works out?
[ June 02, 2006: Message edited by: Michael Ernest ]
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fred rosenberger:
lowercase comes from the fact that i seldom use the shift key when typing. While i was in the process of adopting my daughter, EFH changed my title to "dad to be". once the adoption was complete, he changed it again to "dad".


I see, that is a nice story. I hope all is going well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic