问题
From wikipedia:
Dynamic loading is a mechanism by which a computer program can, at run time, load a library (or other binary) into memory, retrieve the addresses of functions and variables contained in the library, execute those functions or access those variables, and unload the library from memory.
Late binding is a computer programming mechanism in which the method being called upon an object is looked up by name at run-time.
In my opinion,
A similarity is they are both mechanisms in which methods are looked up at run-time.
A difference is dynamic loading does not need to use a linker after loading the library at run-time but late binding always need a linker.
I'm not sure if I am correct, especially the difference part. I would like to learn more from your analysis.
回答1:
Late binding, much like overcommit, is a hack to squeeze out some extra benefit (performance / memory allowance) at the expense of correctness and possible late catastrophic failure.
Without late binding, dynamic loading of modules will succeed only if all symbols needed for relocation can be resolved at load time, and you get a meaningful error from which you can recover if they can't be resolved. With late binding, dynamic loading virtually always "succeeds", then can crash your program later when the dynamic loaded module tries to reference a symbol that can't be resolved.
回答2:
As I understand it, dynamic loading is a lower level than late binding. So a late bound function call looks and feels just like an ordinary function call, except that if the library is missing then the application will terminate when the call is attempted instead of when the application launches, while for dynamic loading you have to write more code but you get to do error handling, such as calling a fallback method.
来源:https://stackoverflow.com/questions/6866432/what-are-similarities-and-differences-between-dynamic-loading-and-late-binding