Java or C + +?

Source: Internet
Author: User

Java is particularly like C + +; It is natural to conclude that C + + seems to be replaced by Java. But I have some doubts about this logic. In any case, C + + still has some features that Java does not have. And despite a lot of assurances that Java will one day meet or exceed the speed of C + +. But this breakthrough has not yet been achieved (although the pace of Java has steadily improved, it has not yet reached the speed of C + +). In addition, there are a large number of C + + enthusiasts in many areas, so I don't think that language will soon be replaced by another language (the power of enthusiasts is negligible.) For example, at a "middle/Advanced Java Workshop" I hosted, Allen Holub claimed that two of the most commonly used languages were REXX and COBOL. I feel that the power of Java is reflected in a slightly different area from C + +. C + + is a language that never tries to pander to a mold. In particular, its form can be varied to solve different types of problems. This is mostly reflected in tools like Microsoft Visual C + + and Borland C + + Builder (which I like the most). They synthesize libraries, component models, and code generation tools to develop a windowing end-user application (for Microsoft Windows operating systems). But on the other hand, what is the most common use of Windows developers? Is Microsoft's Visual Basic (VB). Of course, we don't mention the fact that VB's syntax is easy to confuse-even a few pages long, the resulting code is very difficult to manage. From the point of view of language design, although VB is so successful and popular, but there are still many shortcomings. It's best to have both the power and ease of use of VB while not creating code that is difficult to manage. This is where Java is most attractive: as "the next generation of VB." No matter how you feel after hearing this proposition, think about it anyway: people have done a lot of work on Java to make it easier for programmers to solve application-level problems such as networking and cross-platform UIs, so it essentially allows people to create very large and flexible code principals. At the same time, given that Java also has the most "robust" type checking and error control systems I have not seen in any other language so far, Java does greatly improve our programming efficiency. There is no doubt about this! But for a particular project, can you really switch C + + into Java without any hesitation? In addition to Web applications, there are two more issues to consider. First, if you want to use a large number of existing libraries (which can certainly improve a lot of efficiency), or already have a solid C or C + + code base, then convert to JavAfter a, the reflection will hinder the progress of development, not speed it up. But if you want to build all of your code from scratch, then Java's ease of use can be effective in shortening development time. The biggest problem is speed. In the original Java interpreter, the interpreted Java would be 20 to 50 times times slower than C. Despite a long period of development, this speed has a certain degree of improvement, but compared with C still very disparity. The most important thing about computers is speed; If you can't work clearly and quickly on a single computer, you might as well do it by hand (some people recommend using Java during development to shorten development time.) Then use a tool and support library to translate the code into C + +, which allows for faster execution times. To make Java work for most web development projects, the key is speed improvement. This is the time to use a compiler that people call "just-in-time" (JustIn, or JIT), or even lower-level code compilers (two when writing a book). Of course, a low-level code compiler can make a compiled program impossible to perform across platforms, but it also brings a speed boost. This speed is even closer to C and C + +. and program cross-compiling in Java should be much simpler than C and C + + (in theory, just recompiling, but it's still harder to implement; Other languages have made similar guarantees). In the appendix of this book, we can find a comparison with java/c++. Observations on the status of Java and coding rules.

1  Packagecom.tomtest;2 3 4 classtomtest_43 {5        Public Static voidMain (String args[]) {6 String s1,s2;7s1=NewString ("We Are students");8S2=NewString ("We Are students");9 System.out.println (s1.equals (S2));TenSystem.out.println (s1==S2);  One String s3,s4; AS3= "How is You"; -S4= "How is You"; - System.out.println (S3.equals (S4)); theSystem.out.println (s3==S4); -         } -}

Java or C + +?

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.