File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes diff in c++ and java for ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "diff in c++ and java for ..." Watch "diff in c++ and java for ..." New topic
Author

diff in c++ and java for ...

Sukhadev Patil
Greenhorn

Joined: Apr 12, 2006
Posts: 12
Difference between c++ and java for client-server program?
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
One can do pointer arithmetic. Seriously, that question is a little vague. What is it specifically you are trying to evaluate?


ph34r my 133t j4v4 h4><0r1ng sk177z
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
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


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
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.


java j2ee job interview questions with answers | Learn the core concepts and the key areas
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
C++ inherits preprocessor directives from C:

#define QUESTION "vague"

Yet another kind of inheritance
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
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.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10908
    
  12

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
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

Joined: Oct 02, 2003
Posts: 10908
    
  12

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

Joined: Oct 25, 2000
Posts: 7292

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 ]

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: diff in c++ and java for ...
 
Similar Threads
CSharp and Java
final & private together
whts the out put
why is 'unsigned' not supported in java
Apply your Lateral Thinking