2

I often see the terms "early binding" and "static dispatch" used interchangeably, and I also often see the terms "late binding" and "dynamic dispatch" used interchangeably.

Do these terms mean the same thing?

3
  • "early" and "late" are relative qualifiers, whereas "static" and "dynamic" are not.
    – Caleth
    Apr 20 '20 at 16:23
  • 2
    They are the same for all practical purposes, although “binding” is used as a more general term for associating names with values, whereas “dispatch” is more specifically used in the context of method calls in OOP. One might argue that “static dispatch” doesn't actually exist. Reality is often confusing, e.g. a statically dispatched method in C++ may use late binding (at runtime) due to dynamic linking. But Perl might use early binding (at runtime) to resolve subroutines. As Caleth points out, it's good to be careful about relative terms like early/late, though it's usually clear in context.
    – amon
    Apr 20 '20 at 16:25
  • "early" binding usually means an eager approach. However a dynamic language might early bind at runtime. Its just doing so before the running code has requested an invocation which mandates a binding. "late" binding similarly is a lazy approach. However that might mean resolution on load by the platform specific binary loader, which is still technically resolved prior to runtime. But is late, in that the compiler did not do it.
    – Kain0_0
    Apr 21 '20 at 4:57
5

Binding is a more general concept than dispatch.

"Binding" means "resolving an identifier to something", whereas "dispatch" specifically means "resolving an identifier to a subroutine", and is most often used when talking about method dispatch in OO, but also e.g. Haskell type classes or methods of Abstract Data Types.

As was pointed out in the comments, "early" and "late" are relative, however the meaning is usually clear from the context in which the term was used, and almost always means "before runtime" and "at runtime".

0

Sometimes I've heard "static dispatch" and "dynamic dispatch" to refer to exactly how the language locates the method to be called: "static" using a fixed data structure and "dynamic" using a list that has to be run each time.

"Binding" generally refers to bringing separately-compiled subroutines together into an executable. I think of "early binding" as linking against .obj files, and "late binding" to refer to .DLL or .so files.

However – bottom line – the terminology can be ambiguous. You need to be sure what you are actually meaning by the terms you're using, and that you also understand the other party's meaning!

0

It’s not always clear what someone means by these terms, but generally:

With static dispatch you know which code you want to call and the same call will always call the same code. With dynamic dispatch, you don’t know before the call what code will be called. Take C++ virtual functions. The same virtual function call can call different code, depending on the class of an instance.

With early binding, your program knows where each bit of code is when it is loaded into memory. You can have static dispatch and early binding: you don’t know yet which code is called, but you know where each code that could be called is. Late binding happens for example if you load a library only when it’s needed. You might know that you want to call the sqrt function in the math library, but you don’t know where it is until the math library has been loaded into memory, and someone has examined its table of contents to find where the sqrt function is. Usually this is implemented so that the second call knows where the function is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.