Comparison between C #, C ++, and Java

Source: Internet
Author: User
1: object-oriented language
Both C # and Java are pure object-oriented languages and C ++ are non-pure object-oriented languages.

2: force type check
Both C # and Java force type checks, while C ++ is loose.

3: Macro
Both C # and Java do not support macros. c ++ supports macros.

4: Template
Neither C # Nor JAVA supports template, and C ++ supports template.

5. Multi-Inheritance
Both C # and Java do not support multi-inheritance, and both support interfaces. c ++ supports multi-inheritance.

6: pointer
Both C # and Java do not support pointers. c ++ supports pointers. (However, C # allows pointers in the Unsafe code)

7: Memory Management
Both C # and Java support garbage collection. C ++ does not support garbage collection.

8: Virtual Machine
Both C # and Java require virtual machines, while C ++ does not. The Java execution file is an intermediate code called bytecode, which is executed through Java Runtime Environment (JRE). The execution file of C # is also an intermediate code called managed code, it is executed through ngws runtime. In addition to Java, you can also use other programming languages (such as Ada and Python) to create bytecode. In addition to C #, you can use other programming languages (such as Visual Basic and C ++) to manage the code.

9: namespace
Both C # and Java support hierarchical namespaces, but C ++ only supports single-layer namespaces. Java namespace is called package, and C # namespace is called namespace. Both Java and C # Use "." As the namespace symbol, while C ++ uses 「::」.

10: platform-independent type
Both C # and Java use platform-independent type. The type of C ++ is affected by the platform.

11: Use wrapper to package basic State
Both C # and Java support packaging basic states into objects. in Java, wrapper is called, and in C #, box is called.

12: Boolean! = Integer
Neither C # Nor Java can use integers as boolean values, while C ++ can.

13: access modifier
Both C # and Java support four levels of access modifier, including public, protected, private, and default/Internal. c ++ only supports public, protected, and private. Java default (not written) refers to opening only for the same package, which is exactly the internal of C.

14. Variable Initialization
Both C # and Java stipulate that uninitialized variables cannot be used. c ++ does not have such restrictions. Both Java and C # compilers actively help uninitialized field/data member to set the initial value. c ++ does not.

15. Transformation
Both C # and Java stipulate that the basic state and reference types cannot be switched.

16: array boundary check
C # and Java both actively perform array boundary check, and C ++ does not.

17: Call native code
Both C # and Java support calling native code. Java uses JNI (Java Native Interface); C # uses pinvoke (platform invocation Service)

18: Metadata
The intermediate codes of C # and Java both contain Class metadata, while C is independent of header file.

19: intermediate code command
The IL intermediate code command of C # is very similar to the bytecode command of Java, and some are even the same.

20: Exception Handling
Both C # and Java support try/catch/Finally, but C ++ only supports try/catch.

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.