Why Coffee Does Non Back Upwards Operator Overloading

Unlike C++, Java doesn't back upwards operator overloading. Java doesn't furnish liberty to programmer, to overload the criterion arithmetics operators e.g. +, -, * too / etc. If y'all own got worked previously inward C++, than y'all know that, Java has left lot of characteristic supported inward C++ e.g.  Java doesn't back upwards multiple inheritance, no pointers inward Java, too no move past times past reference inward Java. Rarely this inquiry asked inward Java interviews, to cheque how programmer thinks well-nigh for sure features, which is non supported inward Java. Another similar questions is regarding Java beingness move past times past reference, which is to a greater extent than oft than non look as, whether Java is move past times past value or reference. Though I don't know the existent argue behind it, I recall next observation brand feel on, why Operator overloading is non supported inward Java.


1) Simplicity too Cleanliness
 to overload the criterion arithmetics operators e Why Java does non back upwards Operator overloadingobject oriented language. Adding Operator overloading would own got definitely made pattern to a greater extent than complex than without it, too it mightiness own got Pb to to a greater extent than complex compiler or slows the JVM ,because it needs to practice extra move to pose the actual important of operators, too cut the chance to optimize the linguistic communication past times guarantee demeanour of operators inward Java.

2) Avoid Programming Errors
Java doesn't allow user defined operator overloading, because if y'all allow programmer to practice operator overloading, they volition come upwards up amongst multiple meanings for same operator, which volition brand the learning bend of whatever developer hard too things to a greater extent than confusing too messy. Its been observed that, in that place is increase inward programming errors, when linguistic communication supports operator overloading, which inward plow increase e evolution too delivery time. Since Java too JVM has taken most of developers responsibility,  inward retention management past times providing garbage collector, it doesn't actually brand feel to left this characteristic to pollute the code, too equally a loop hole for programming errors.


3) JVM Complexity
From JVM perspective, supporting operator overloading is to a greater extent than difficult, too if the same matter tin move achieved, past times using method overloading inward to a greater extent than intuitive too build clean way, it does brand feel to non back upwards operator overloading inward Java. Influenza A virus subtype H5N1 complex JVM, may lawsuit inward slower JVM, than a relatively simpler JVM ,and cut the chance of optimization past times taking out guaranteed demeanour of operators inward Java.

4) Easy Development of Tools
This is an additional practice goodness of non supporting operator overloading inward Java. Omission of operator overloading has kept the linguistic communication easier to handgrip too process, which inward plow makes it easier to prepare the tools, that procedure the linguistic communication e.g. IDE or re-factoring tool. Re-factoring tools inward Java are far improve than C++.

Further Learning
Complete Java Masterclass
method overloading using to a greater extent than intuitive too piece of cake agency too that mightiness move the argue coffee designer idea that supporting operator overloading volition non move a big practice goodness for language, only inward fact entirely Java designer tin response existent motivation of, why Java doesn't back upwards operator overloading, similar another questions equally Why Java doesn't back upwards multiple inheritance or Why String is immutable inward Java.

Sumber https://javarevisited.blogspot.com/

0 Response to "Why Coffee Does Non Back Upwards Operator Overloading"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel