answersLogoWhite

0


Best Answer

You're comparing apples and Oranges. C is a procedural language. You can, using structures and functions to access those structures do everything you can in Java. In fact, if you look into GObject, the object oriented method of programming in GTK (the Linux toolkit) people do this all the time. In fact they have pretty much implemented C++ manually using a programming style and macros.

C++ and Java have a great deal more in common. From a language perspective, they are nearly identical. Java is arguably cleaner as it doesn't depend on forward declaration and therefore all functions are coded directly within the class definitions themselves. C++ is arguably more powerful as you have direct access to the hardware of the system and it's also possible to write code in such a way that it is guaranteed to be compiled an optimized in a specific manor.

For application development, Java is often faster (performance and in the time it takes to get the job done). For system level development, C++ is almost always a clear winner. I won't detail it as it's far beyond the scope of the question.

There are two key differences between Java and C++ to a programmer.

1) Java is a garbage collected language

This means you can allocate memory and just forget about it when you're done. Some people say this leads to ugly code and quite frankly, I agree. Bad programmers can be REALLY bad programmers in Java and get away with it. C++ a C++ program will tend to crash your machine if you write it badly. The selling point of garbage collection is performance. It allows the runtime system of the language to clean up when there's time to do it instead of having to clean up during time critical moments. In C++ this type of behavior has to be coded manually and requires a great deal of strategic planning to accomplish.

2) Java has a "good" defined set of standard class libraries.

C++ has libraries also, but only a small percentage of programmers use them because many of us (me included) consider them to be a plague on the language. They're VERY over-engineered and can be very hard to debug. Java's libraries are a lot cleaner even if they have serious inconsistencies (this may spur a political debate, but I offer my opinion and the arguments I've heard from others).

Neither language is particularly good. Neither runtime is particularly modern. There are newer technologies such as C#/.NET and others which have arguably learn from C++ and Java and built upon what was learned.

If you're learning to program, I recommend using C++ with Qt (from Nokia) as it gives you almost the best of both worlds. If you're using one and looking to switch to the other. It should be a smooth transition, the languages are basically the same.

If you're asking about internal data structure. The two languages aren't comparable as Java doesn't have a strict internal structure definition and therefore can't be compared.

P.S. - For a bonus, Java's best feature is relocatable memory. Because it forces you to never use memory locations directly (pointers), so the java virtual machine can relocate your memory in order to make room for larger allocations that otherwise wouldn't fit without paging or asking the OS for more RAM. This can make your applications more efficient as virtual memory paging is far more expensive than simply defragging the memory occasionally.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

No. Java source code and C source code may look similar (since Java is based on C++, which is based on C), but the languages themselves are very different.

Yeah both are totally different language based on different paradigm JAVA is Object-Oriented while C is procedural.C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.C is a low-level language while JAVA is a high-level language.Java is an Interpreted language while C is a compiled language.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Java compiles to byte code suitable for the Java Virtual Machine (JVM). While this means Java programs are highly portable. that is, code is compiled just once and can be run on any platform supporting the JVM without modification. However, it also means there is a high degree of abstraction between the code you write and the hardware that utilises it. That is, low-level architecture features are not directly accessible. Therefore Java program performance is many times worse than that of native machine code programs, particularly those with low-level access to the architecture. Java is also completely object-oriented, has a simpler object model, does not use memory pointers but employs pass by reference by default. And although it has a fairly similar syntax to that of C++, they are not related in any way, shape or form.

C++ compiles to native machine code. This makes it less portable as programs must be compiled separately for each supported platform (using preprocessor directives to filter the required code for each platform). However, the level of abstraction is almost non-existent, with many low-level features, including memory pointers and direct access to specific architecture features. Although C++ is intended for object-oriented programming, it exists purely as a programming aid -- you can choose to write your code in C++ or C, or both, and you can also incorporate your own low-level Assembly Language routines. The object model is complex, parameters are passed by value by default and, although the learning curve is steep and development times extended, the performance gains more than compensate for the extra work.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Java is pure object oriented language, and C++ is not, because you can access the private member of classes in c++ by using the friend function. There is no such function within java.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between C and java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Major difference between c and java?

Java is object oriented, C is not...


What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.


Difference between java and C plus plus?

java is an advanced object oriented programming language than c++


What is difference between exception handling in C and Java?

Easy: there is no exception-handling in C.


Difference between procedure and function in C or C plus plus or Java language?

In C there are functions only, In Java methodsonly (static methods as well), in C++ both.


What is the difference between java compiler and C compiler?

Greetings Technologist. The Java compiler compiles Java code, whereas the C compiler compiles C Code HTH Richard Wolf Software Architect


What are the main differences between Java and C plus plus?

the difference is that c plus is better because you get big grades


What is the difference between javascript and java programming langugage?

JavaScript and java are 2 completely different things. JavaScript is in web pages to make it more interesting and java is a complex computing language devised from c + c++.


What is the difference between java and c sharp?

You can check out the wikipedia link provided in the related links for this question


Major difference between java and cpp?

CPP typically stands for the C PreProcessor, which does macro expansion on C source code. What I suspect you want to know are the differences between C++ and Java. See the links below for more information on that topic.


What is the difference between cc plus plus and java?

C is a procedure oriented language ,Where C++ & java are object oriented language.But java is platform independent.So generally C is called POP.C++ is called OOP.But java is OOP , which is platform independent.If java does not support primitive data type then it is called as pure object oriented language.


What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.