Why is there no operator overload in Java?

Source: Internet
Author: User
Recently, he has been reading Herb's book series of predictional C ++. Scott Meyer wrote in his preface that predictional C ++ is a book that often uses "Make me surprise". Indeed, even though I have been using C ++ for many years, reading such a book still makes me feel that my understanding of C ++ is quite simple.

But as some people keep asking this question-"is the complexity of system design that requires so much knowledge, experience and skills, or the complexity of C ++ itself?" (well, my personal understanding is that both of them are ^_^), Bruce wrote in the thinking in Java 4 sequence, as he keeps deepening his understanding of Java, the design goal of the Java language is to make it easier to describe and build complex systems.ProgramDevelopers can also use Java to construct a complex system. Java is an easier way to describe the system language at a higher abstraction level. Maybe it is not so efficient, sometimes it seems not flexible enough, but it won't often make you surprise...

Back to the topic, why is there no operator overloading in Java? C ++ Operator Overloading is an important feature of its strong and flexible language. I have worked with Quatro DSP simulators this year, quatro DSP is a digital image processor used for printers and scanners. The simulator itself is actually a C ++ library, with the support of the database, the compilation language of Quatro DSP can be converted into a valid C ++ function call, so that the integrated development environment (such as Vc) in C ++ can be implemented) simulation of DSP assembly language execution, the main working principle is nothing more than the register is defined as a class type object, so that the Assembly language into a function call using macro replacement and operator overloading.

C ++ not only involves Operator overloading, but also custom type conversion (well, most C ++ books advise you never use the latter without proper reasons ), exceptional C ++ describes exceptional securityCodeIn this section --

"In particle, it helps to develop a habit of eyeing with mild suspicion anything that might turn out to be a function call --- including user-defineed operators, user-defined conversions, and silent temporary objects among the more subtle cluprits-because any function call might throw."

"In fact, it will help you develop this habit and have a skeptical eye on all statements. I guess this may be a function call-including a custom operator and a custom type conversion, and some temporary objects that are generated quietly in an even more unpredictable context-Because function calls may throw an exception. "

The purpose of Herb's writing this section is to explain how to write abnormal security or neutral code in C ++. You must carefully analyze the statements that may throw exceptions, most of the statements in a template code are very likely to be a function call, and function calls may throw an exception, at last, there will be very few statements that will not throw exceptions for your confirmation ...... if you do not make such a mental expectation, and assume that most statements do not throw an exception, the probability of your surprise being very high ......

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.