Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

smalltalk - Early binding vs. late binding: what are the comparative benefits and disadvantages?

When discussing the evolution of computer languages, Alan Kay says that the single most important attribute of his Smalltalk is late binding; it gives the language its malleability and extensibility, and allows inappropriate coupling to be refactored out over time. Do you agree? Are there compensating advantages for early binding that explain why it seems to be the dominant of the two paradigms for domains where either could be used?

My personal experience (which is not broad or deep enough to be authoritative), based on implement web applications with javascript, jQuery, jsext, actionscript, php, java, RoR and asp.net seems to suggest a positive correlation between late binding and bloat reduction. Early binding I'm sure helps detect and prevent some typesafety errors, but so do autocompletion and a good IDE, and good programming practices in general. So I tend to catch myself rooting for the late binding side, before my risk-avoidance side restores my rational perspective.

But I really don't have a good sense for how to balance the tradeoffs.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In my experience of both high-performance software (e.g. games, number-crunching) and performance-neutral software (websites, most everything else), there's been one huge advantage of late binding: the malleability/maintainability/extensibility you've mentioned.

There've been two main benefits of early binding. The first:

  • Runtime performance

is commonly accepted, but generally irrelevant because in most cases it's feasible to throw hardware at the problem, which is cheaper. There are, of course, exceptions (e.g. if you don't own the hardware you're running on).

The second benefit of early binding:

  • Ease of development

seems to be underrated. In large projects where developers are working with other people's components, IDEs can read the early bindings and use them to inform the developer (with autocompletion, docs, etc). This is less practical with late-binding because the bindings are created at runtime. It is still possible with late-binding languages if the IDE can infer structure definitions from the code, but since the structure can always be changed at runtime, it's not so reliable.

Ease of development is a big deal. It minimizes expensive programmer time -- and the larger your development team, the more significant it becomes. You'd need to balance that against the flexibility you get with late-binding languages.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...