Horizontal Technical Analysis on advantages and disadvantages of C #, C ++, and Java

Source: Internet
Author: User

Since the birth of C #, the debate between C # and Java has come one after another. Objectively speaking, C # and Java are the fruits of traditional Object-Oriented Programming in the componentized software era. Although the two languages have "90% overlapping", the other "10% Contest" is often able to make a balance. In this article, we will share a total of 90%, with 10% differences. We will make a pure technical evaluation on the two languages. The article does not involve companies in two languages, and things behind the market-although this often affects people's choice of programming languages. We are not prepared to figure out who is killer, and the question of who the reader should choose. "Language selection is an art rather than a non-technical issue", the industry has been determined, no need to say more.

Both C # and Java have proposed modern improvements to the complex and obscure syntax and semantics of traditional C ++. In terms of syntax, both of them discard the const modification of functions and their parameters in C ++, macro replacement, global variables and global functions, and many other flashy places. In terms of inheritance, both adopt a single inheritance and multi-interface implementation scheme that is easier to understand and construct. In terms of source code organization, we have put forward a better logical encapsulation of declarations and implementations. In terms of the Type System, both languages have put forward the reflection concept based on the intermediate language il or byte code, this completely revolutionizes the traditional C ++ runtime type identification problem. However, while making drastic changes to C ++, C # seems more conservative and retains many of the good properties of C ++, for example, stack-based lightweight structure types, enumeration types, reference (REF), output (out), array (Params) parameter passing methods, etc, these are all unfortunately lost in Java. The box/Unbox proposed by C # is superior to the Java packaging class in terms of unified types between basic types and single inherited objects, and the efficiency is also better.

C # and Java both propose Managed execution environments for insecure pointers and memory allocation methods in C ++. Efficiency is a problem that has always been criticized for hosting the execution environment. Java Virtual Machine (JVM) Interpretation and execution methods have made many developers "unbearable ". C #'s JIT compilation method won praise for C # on this battlefield. Some C # code hosting is even faster than traditional C ++ code. Although the Java platform implemented by various vendors also adopts the JIT compilation method, however, the comparative advantages of C # in this respect are very obvious-the target compilation language of C #, Il, has placed efficiency in an important position in the initial design, java's bytecode design is reckless. After several years of practice, the Managed execution environment has reached a consensus in the modern software industry, and the sacrifice of efficiency is a highly secure code-of course, the premise is that the sacrifice of efficiency must be small enough, at least tolerable. It is worth noting that here C # is also "Do not forget the older generation of C ++ programmers", C # allows us to perform pointer operations in the unsafe context. Array Index out-of-bounds check, type security has been mentioned quite high in C # and Java. In terms of exception handling, C # is superior to Java in terms of both built-in support and execution efficiency.

"One-time programming, multiple executions" is a persistent demand for programming, especially in the modern Internet era. In terms of cross-platform support and implementation of Java, the speed of JVM is still a headache. C # has fully considered portability in terms of underlying structure, but at least it is not yet mature and tested. C # cross-platform programming seems to be more keen on XML Web Services Interoperability than cross-platform programming. However, C # uses its basic language structure (CLI) to support object-level interoperability among more than 20 mainstream languages, which greatly improves the technical position of C. Low-cost interoperability with COM components also earned a lot of points for C #-maintaining a compatible system is very important to the modern software industry and is also responsible for the majority of developers.

Component-oriented is undoubtedly the mainstream of software development. C # programming for components is even a "infatuated", which is not the same as Java that came out six years ago-of course this is a problem of the times. C # provides first-hand support for component programming through attributes, indexers, delegates, events, Operator overloading, features, and versions. Although these can be indirectly implemented through methods, interfaces, or adapters in Java, however, the history of the software industry tells us that programming efficiency and logical design are both a great challenge-advanced languages are first faced with humans rather than machines. Apart from the component support mechanisms at these language levels ,. the. NET platform also provides a package of solutions for component configuration, operation, and management, while Visual Studio tailored for component development. net is even more exciting, which opens up a broad world for C # component programming. Java's weakness in other technical aspects is negligible, but Java in component programming is rather hard to cure than C. C # has an irresistible charm and temptation in this respect, especially for developers who come from the C ++ and Visual Basic backgrounds.

Given the role of XML Web Services in distributed computing for the next generation of enterprises, it is necessary to provide a simple explanation for the two languages. In terms of XML Web Services operations ,. NET platform directly built-in XML support in the Il intermediate language makes C # the first choice for the next generation of Web Services, which is incomparable to Java that supports Web services through API sets. In C #, the underlying protocols such as XML, SOAP, UDDI, and WSDL are built into developer-oriented components, and these are still Jax (Java xml api) in Java) and other underlying protocol operation functions. Of course, this situation may only be a matter of time. A powerful and efficient Web Services component model is not an insurmountable gap for Java.

In terms of language standardization, Microsoft has also made unprecedented impressive moves. Currently C # And. the net platform infrastructure has been submitted to ECMA of the European Computer Manufacturers Association. After standardization, C # can be developed and supported by any vendor on any platform, this provides a powerful driving force for the development of C. Although Java has the JCP (Java Community process) action in this regard, it can only be quasi-standardized. In the componentized software era, a standardized language like C ++ is very important to the software industry, especially the majority of developers.

Of course, the comprehensive technical evaluation of the two languages is not just a simple list of the above points, its backend platform (C #. net, Java for J2EE), the support of its programming framework, the implementation of tools related to various languages, and the existing system foundation have a considerable impact on the development of programming languages. From a purely technical perspective, C # is undoubtedly more competitive than Java. It doesn't make sense to argue who plagiarize. The development of technology is a process of mutual reference. A pure technical competition cannot determine the outcome of this debate-if it is necessary to fight. The software industry is keen on competition, and technologies honed by the market can better serve us. Let's wait and see!

Source: http://developer.51cto.com/art/200904/119007.htm

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.