Possibility of replacing C language with Java

Source: Internet
Author: User
Not long ago, csdn published an article titled "C language is dead", which caused some controversy. In fact, the article was reproduced from the blog of Ed Burnette. The original Article titled "Die, C, die !", Let's go to death, C!. It expresses a curse rather than a judgment. The translation "the C language is dead" is obviously a type of lyrical misunderstanding. Csdn netizens have criticized their views, but frankly speaking, since these criticisms are based on a distorted translation text, there is nothing new, and did not grasp the original author's focus.

This is the actual situation. Recently, the technology community outside China has seen a boom. Many people are discussing the possibility that Java will become the most mainstream basic software programming language as a replacement for C language. From the perspective of most people, the trend of replacing C with Java is still supported.

Basic Software refers to such a type of software. Its main task is to give full play to the potential of the computer and provide an efficient and reliable function set for upper-layer application software. These software will be intensively called, and a little lag in performance will be magnified by hundreds of thousands of times in practice. Therefore, for basic software, performance is at least as important as reliability. We often see some ugly designs in the source code of some basic software, and some abnormal hacker skills. In other fields, This is not encouraged, but in basic software, this is reasonable and acceptable.

C language is still strong in some fields, and may always be the king in operating systems, virtual machines, and device driver development. However, in other basic software fields, such as databases, network servers, and image processing, there are only two reasons why C continues to dominate the dominant position. One is fast, second, there are many people who are familiar with it and have rich experience.

However, these two points are now challenged.

First, speed. Java's execution speed reaches the level of jdk1.4, that is, for a general-level developer, the C ++ program he wrote is no longer faster than other Java programs. The subsequent JDK 5.0 and 6.0 further improved the execution performance. The results of multiple evaluations conducted by different organizations indicate that the overall execution efficiency of Java and C is less than doubled, that is, C language, which is well known for its speed and abandoned many things for its speed, is less than twice faster than fully-equipped Java. This is not enough. Considering the new computing environment, the speed advantage of C language may be just an illusion. Because, in the world, only a few people have the ability to write fast and correct big programs on multi-CPU computing platforms in C language. Among these people, only a few people can use the C language to write a large-scale parallel program that can give full play to the computing power of each node in a large, heterogeneous network environment. That is to say, you may be able to double the program efficiency, so as to give full play to the computing potential of a PC worth 6000 RMB, saving customers 1000 yuan. However, in a large heterogeneous network parallel computing environment consisting of 1000 machines, the performance of the C program you write will be far lower than the corresponding Java program, let alone a huge post-maintenance cost, which may cause 10 million or more losses.

Second, experience. Many people claim how their C skills can be achieved, but in fact, even true C masters have to spend considerable time looking for and debugging errors, especially memory errors. Most software written in C has some memory errors and requires a lot of effort and time to stabilize the product. This does not take security defects into account. Currently, most developers have weak knowledge about code security, and security vulnerabilities are quite common in code. In C, this deficiency is especially obvious. The biggest challenge may be concurrency. Concurrency is a very complicated problem that needs to be solved at a very high level of abstraction. The abstract mechanism of C language is too simple, it cannot provide high-level abstraction, so developers can only start from some "concurrency primitives" to construct concurrent programs, which is no different from cutting a tree with a pencil. To put it bluntly, most C programmers do not have the ability to write highly efficient and defect-free concurrent programs.

The cruel fact is that when a person says how well his C language is and how rich his experience is, he is very likely to say that he is using C language to write single-host and single-thread data, there will be no external attacks, there is no pressure on the Time Budget, and users are very experienced in terms of being able to endure a long stable product application. Unfortunately, the market environment and computing environment have completely changed. In the face of a more complex computing environment, using C language to write high-quality large-scale software is a task that can only be completed by a real expert team. If you have been struggling to track and debug a memory leak or thread error for several consecutive days, you will understand that you may not be such an expert.

In contrast, Java compares Abstract Mechanisms, infrastructure, security, and concurrency with the C language, as if it were a machine gun on the bow and arrow. For example, the Java. util. Concurrent package added to Java 5.0 may be the most powerful support library for concurrency problems in mainstream languages. Java's memory management and security mechanisms have also been proven to effectively reduce program defects. This is the intention of the original article that cursed the article.

Therefore, my attitude is clear. I think that replacing Java with C is an idea of progress. However, there are many ideas about progress in the world, but few of them can come true. Can Java effectively replace C language in the basic software field? I don't think it can be done in the short term for the following reasons:

1. human problems. There are not many people who can write excellent basic software in C language. I am afraid there are fewer people who can write excellent basic software in Java. Java has millions of developers, but what are they doing? Most of them are engaged in enterprise-level development and web development. How many people really understand the Java memory model? How many people are familiar with the tools provided in the concurrent package? Many people who have been using Java for many years have not written socket programs, but have no idea about the overhead of Java multithreading and how to diagnose and tune performance, these skills are essential for writing basic software. After learning Java, most Java programmers turn to web development and focus on Mastering one large and complex framework with thick abstraction layer and gorgeous structure, it is not only unclear about the real computer architecture, but also about the computing environment virtualized by Java. Therefore, it is difficult and time-consuming to turn Java Community programming into a vanguard capable of undertaking the next generation of basic software development.

2. Java memory consumption is too large. For system-level programs, the high memory consumption means that the cache hit rate is reduced, the possibility of data exchange with the disk increases, and the impact on performance is serious. Nowadays, many people still think that Java is slow. The main reason is not that Java is slow, but that the overall performance is degraded due to excessive memory consumption. If this problem is not solved, Java can only be used for some basic software at the upper layer. Maybe with the development of computer hardware, this problem will be gradually solved?

3. style issues. I think this problem is the most serious. Basic software development advocates freedom, directness, transparency, simplicity, and efficiency. It must be as sharp as a dagger, as brave as a warrior, and as simple as a farmer, we oppose the layer-by-layer abstraction of stacked houses, and oppose complicated structures and unnecessary flexibility. The design style formed by the Java Community over the years is incompatible with this, or even opposite. Java is oriented to the development of enterprise application software in terms of ideology. Therefore, it emphasizes architecture, design model, standards, regulations, high posture, and court temperament. In C, when you eat, you eat, hold up a bowl to drink, put down the chopsticks and swear by the mother, open your arm to capture meat, and pull up your sleeves to put on the oil. In Java, to do something, you often first create an object and then use this object as the parameter to create another object. In this way, repeat n times, to get the desired object, the last step is to call a method of that object. It is like burning incense and cleansing during meals. In C, the problem should be like a dead man, like a rogue version of Cheng bite gold, take care of you, Qi 21, rushed up is a three-board axe, but also afraid of not killing you. In Java, problems may be like song xianggong, who wants to write a letter on the list, be well-known, be polite, open the shelf, and set up the spectrum. The slogan of Java is that you will be touched by your child first, no matter whether you are killed or not. This tedious set of things is neither necessary nor difficult to get used to for basic software development. It should be noted that this is not a problem with the Java language. In fact, Java itself does not have to be so complicated and so baroque. From the perspective of the language itself, Java can also be brisk and straightforward, but also smooth. Almost no one has used the program like this for more than a decade, so we don't know: if we don't give a step-by-step, how can we use Java to write programs?

It is precisely because of the above reasons (which may not be comprehensive) that, until recently, almost all of the first-class basic software is written in C language, or at least its core is mainly C. In addition, I think this situation will not change much in the short term. Of course, if the Java Community can overcome these problems, give full play to the advantages of Java itself, and develop a large number of first-class supporting software in the basic field, then the situation can be changed, this kind of change is also progress and is welcome.


Related Article

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.