Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic binding == late binding in Java or not?

In different sources i've read different things on the topic. For example Wikipedia says:

Late binding is often confused with dynamic dispatch, but there are significant differences.

But a couple lines later

it is popular to use the term late binding in Java programming as a synonym for dynamic dispatch. Specifically, this refers to Java's single dispatch mechanism used with virtual methods.

So where's the truth and what are this "significant differences"?

like image 465
4lex1v Avatar asked Feb 27 '12 19:02

4lex1v


1 Answers

Late binding and dynamic single dispatch are, for all intents and purposes, the same. In dynamic single dispatch, the value or identity of a single object determines which code is invoked at runtime, and that's what happens in Java.

The term dynamic dispatch in general is most often used to imply dynamic multiple dispatch, which is where the runtime method is chosen at runtime based on the identities or values of more than one object, which is a language feature in CLOS and Smalltalk, but not in Java or C++.

like image 148
Ernest Friedman-Hill Avatar answered Sep 24 '22 12:09

Ernest Friedman-Hill