-1

So currently reading about binding... Based on the examples I can think of along with examples found on the web, it appears that dynamic binding tends to occur predominantly in interpreted languages as opposed to occurring in compiled languages. Also tends to occur a bit in Java, but java isn't a 'purely' compiled language. I've read - http://en.wikipedia.org/wiki/Dynamic_binding_(computing).

My question is then - for classes, methods and objects, does dynamic binding occur first at the object level and then trace up to methods, classes and such? Also, are there instances in which dynamic binding occurs at the object level in a compiled language?

MinimalMaximizer
  • 392
  • 1
  • 4
  • 18
  • 2
    The whole concept of "interpreted" versus "compiled language" is pretty muddy and nonsensical (languages *are*; their implementations are interpreters or compilers and all languages can be implemented in either way). In my experience, it hurts more than it aids understanding, best stop making that distinction except as a corollary to its history. –  Mar 18 '14 at 21:30
  • You might want to fix the spelling error in the title so it can be found by search – david.pfx Mar 21 '14 at 03:17

3 Answers3

1

No, dynamic binding can occur in compiled languages, like C++:

https://en.wikipedia.org/wiki/Dynamic_binding_%28computing%29

Note that Java is also compiled, into bytecode, which is then interpreted by the JVM. Sometimes the difference between interpreted and compiled languages can get blurry (such as C++ using dynamic dispatch).

antimatter
  • 3,240
  • 2
  • 23
  • 34
  • 1
    I was thinking that about java - but java is more a of a hybrid...its not a pure compiled or interpreted language. Thanks for the response though. – MinimalMaximizer Mar 18 '14 at 01:14
  • @MinimalMaximizer: Java is compiled. It happens that the VM can do things that machine code can't. If you mean 'languages that are compiled to machine code' perhaps you should say so. – david.pfx Mar 21 '14 at 03:17
  • @david.pfx correct me if wrong. I thought that one of the pros of an interpreter was platform indepence which java's bytecode allows you to do. Since this step is interpreted. – MinimalMaximizer Mar 21 '14 at 03:26
  • @MinimalMaximizer: There is a logical fallacy in there somewhere. Java is compiled, not interpreted. It is usually compiled into Java bytecode, but not always. Platform independence is multifactorial. Not all interpreters are platform independent. Where to start? – david.pfx Mar 21 '14 at 07:29
1

Your question has a series of definitional problems. For dynamic binding you could be thinking of:

  • function overloading (C++)
  • vtable dispatch (C++)
  • dynamic name lookup and class dispatch (Smalltalk, ruby, python, etc)
  • dynamic name lookup and object dispatch (Javascript)
  • late binding (VB6 COM)
  • dynamic dispatch (Lisp, Dylan)

For compiled versus interpreted you could be thinking of:

  • compiled to machine code (C/C++)
  • compiled to bytecode, then JIT compiled (C#, Java)
  • compiled to bytecode, with VM (Java, Python)
  • parsed and tokenised (?)

In general, very few languages are compiled to machine code and most of those do not have dynamic name lookup or object inheritance. Many languages are compiled (but not to machine code) and many of them have dynamic name lookup, with either class or object inheritance.

So the answer is, it depends.

david.pfx
  • 10,520
  • 3
  • 30
  • 63
1

Compiled language and interpreted language is a false dichotomy that causes a lot of confusion in the programming language community. Many modern language implementation platforms include both an interpreter and a compiler. Even if the language's original and long standing implementation has been a compiler, that does not mean that someone can't write an interpreter for it later. There's more than one C interpreter out there as well as dozen's of Lisp compilers.

mmachenry
  • 1,773
  • 3
  • 22
  • 38