Differences between C ++ and JAVA

Source: Internet
Author: User

Generally, we talk about JAVA, which first affects "Object-Oriented", "no pointer, high writing efficiency, and low execution efficiency ". More deeply and professionally, I will talk about "JAVA memory Automatic Recovery and multi-thread programming ".

I will search for and summarize the differences as follows: (Please add)

JAVA applications are at the high-level level, and C ++ is at the middleware and underlying level.

JAVA is inseparable from the business logic, while C ++ can leave the business to serve JAVA

The java language provides developers with more concise syntaxes; Removes pointers to bring higher code quality; Fully object-oriented, and its unique operating mechanism is its natural portability.

Java runs on the jvm and is highly portable because the jvm can be installed on any system.

C ++ does not run on other systems. Instead, c ++ runs on different systems and requires different codes. (This is not as good as java. It only writes code once and runs everywhere)
Java has unparalleled advantages in web Applications
Java is not as practical as c ++ in a desktop program. c ++ can be directly compiled into an exe file.
Pointers are the advantages of c ++. They can operate on memory directly, but they are risky at the same time,
Garbage collection, c ++ garbage collection using destructor, java automatic garbage collection
The wide variety of java Plug-ins are the reason why java has developed so rapidly.
Java follows some practical structures of c ++.
C ++ is flexible in programming and control of underlying programs because of the existence of handles.


Java is not just a variant of the C ++ language. They have fundamental differences in some essential issues:

(1) Java is more reliable than C ++. It was estimated that at least one BUG exists in every 50 lines of C ++ programs. Let's not discuss whether this number is exaggerated, but any C ++ programmer has to admit that the C ++ language provides powerful functions while also increasing the possibility of program bugs. Java greatly improves program reliability by changing the language features.

(2) the Java language does not require programs to allocate and recycle memory. Java discards the rarely used, incomprehensible, and confusing features in C ++, such as operator overloading, multi-inheritance, and automatic forced type conversion. In particular, Java does not use pointers and provides automatic waste collection. in Java, memory allocation and collection are automatically performed, so programmers do not need to consider the issue of memory fragmentation.

(3) There is no pointer in the Java language and a real array is introduced. Unlike the "pseudo array" implemented by using pointers in C ++, Java introduces real arrays and removes troublesome pointers from the language, this will prevent the system data from being read or written illegally due to pointer operations such as array operations that are common in c ++ programs.

(4) Java uses Interface technology to replace multiple inheritance in C ++ programs. Interfaces have the same functions as multi-inheritance, but saves the complexity of Multi-inheritance in implementation and maintenance.

Java and C ++ have their own advantages. There is no need to argue that the language is good or that it is not good. If it can exist, it will certainly have its advantages. As long as you decide to learn programming, you will learn it well, programming languages are the same. It is easy to learn other languages.

(The most official information is of course Wikipedia http://zh.wikipedia.org/wiki/Java%E5%92%8CC%2B%2B%E7%9A%84%E5%B0%8D%E7%85%A7)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.