संकलित भाषाओं में, अंतर स्थिर है।
जावा:
//early binding:
public create_a_foo(*args) {
return new Foo(args)
}
my_foo = create_a_foo();
//late binding:
public create_something(Class klass, *args) {
klass.new_instance(args)
}
my_foo = create_something(Foo);
In the first example, the compiler can do all sorts of neat stuff at compile time. In the second, you just have to hope that whoever uses the method does so responsibly. (Of course, newer JVMs support the Class<? extends Foo> klass
structure, which can greatly reduce this risk.)
एक अन्य लाभ यह है कि आईडीई कक्षा परिभाषा को हॉटलिंक कर सकते हैं, क्योंकि इसे विधि में सही घोषित किया गया है। Create_something (Foo) के लिए कॉल विधि परिभाषा से बहुत दूर बहुत हो सकता है, और यदि आप विधि परिभाषा को देख रहे हैं, तो कार्यान्वयन को देखना अच्छा लगेगा।
देर से बाध्यकारी का मुख्य लाभ यह है कि यह चीजों को नियंत्रण में आसान बनाता है, साथ ही पॉलिमॉर्फिज्म और बतख-टाइपिंग के कुछ अन्य उपयोग (यदि आपकी भाषा ऐसी चीजों का समर्थन करती है) बनाता है।