Why do you need to write the underlying culvert _ MySQL

Source: Internet
Author: User
Many people are asking me, since SUN or a third party has provided us with enough APIs, why do we need to write the underlying meanings on our own? In fact, this problem is not understandable to beginners and common programmers, but when you are familiar with a certain program, not only JAVA, you can naturally understand it. you no longer want to use the meanings that others have designed for you, because you believe many people are asking me, since SUN or a third party has provided us with enough APIs, why do we need to write the underlying statements on our own?
In fact, this problem is not understandable to beginners and common programmers, but when you are familiar with a certain program, not only JAVA, you will naturally understand it-you no longer want to use the meanings that others have designed for you, because you believe that the implementation process of your own statements is more strong than that provided by others.
This strong standard should be more efficient and feature better (not more ).

First, we call the APIs provided by SUN and third-party software vendors as standard APIs. our own APIs are quick APIs,
Standard APIs are generic. for this purpose, a certain amount of resources are required. for JAVA itself, JVM and a common BEAN must be implemented first, its business logic may have only one line of code, but to take care of Cainiao-level client programmers, BEAN designers (service programmers) have to spend more time writing BEAN interfaces. it is the so-called specification: 80% of resources are used to complete functions other than the business logic.


For example, in JAVAMAIL, there are about 30 complete MAIL functions in a MAIL system, but JAVAMAIL is based on the message mechanism specification, both efficiency and ease of use have become spam in the mail system. although I have learned many languages, I am enthusiastic about the JAVA language. I think that JAVAMAIL does not affect my passion for JAVA and JAVA technologies.
It can be said that the JAVA development team is no longer the original elites, and their initial ideas have not been carried forward. for JAVAMAIL itself, they have evolved from thought degradation to program level ------ deliberately used for general purposes, and the results are stuck in a difficult trap.

For us, if you are very familiar with the implementation of JAVA technology, it is the most effective way to solve the problem by writing your own statements. for example, we know that the String + operation is the append () operation of StringBuffer at the underlying layer. why not do this directly in the program? If you do this, you will get amazing efficiency:
String s = "";
For (int = 0; I <1024*1024*4; I ++)
S + = 1;
It takes more than 30 minutes to get a 4 m string on P2,
While
StringBuffer sb = new StringBuffer ();
For (int = 0; I <1024*1024*4; I ++)
Sb. append ("1 ");
String s = new String (sb );
In less than one second. why not? Of course, String and StringBuffer are known to common programmers, but how many programmers are clear about the efficiency of more data structures?

I have said many times that, in all languages, even in assembly, all date statements are converted from UNIX timestamps,
Therefore, converting this value is the fastest way in the past. do not look at the DateFormat, Calendar, and other classes provided by SUN, as well as some after () and before () methods, they are also compared and re-converted from UNIX Timestamps. to achieve universality, they also need to consider the format specifications of different countries,
(Local), so it is not as effective as writing by yourself.

On the other hand, you have to believe that not everyone in the standard API developer is smarter than you, and they may achieve worse functions than you, or you can do better than them. of course, the vast majority of functions are well implemented. This is why we are still using the JAVA language rather than rewriting the JAVA language by ourselves, but in practical applications, many times, you should write more efficient and practical Quick APIs by yourself.

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.