Dynamic Typing And Reuse

The following survey suggests that many programmers believe that static typing decreases reuse.

http://www.eecs.berkeley.edu/~lmeyerov/projects/socioplt/viz/index.html

My personal observation is that this is true because with dynamic typing it's easier to plug modules into a new environment without having to drag in or hook up lots of specialized types/classes or libraries. And if they do have lots of dependencies to libraries or specialized types/classes, it's easier to mock up a replacement or adapter if you don't to bring in the entire module(s) because it doesn't have to be defined in as much detail.

Mocking up drop-in replacements for a library's dependency indicates a problem with your code or that of the library's.

Also, it's easier to transplant routines from one dynamic language to another because there are less typing rules and built-in types to translate from one language to another.

The primary premise behind most static/strong typing techniques is that you define and describe as much as possible to the computer about the intent of the program so that it catches more mistakes for you and/or gives you more info about the mistakes. (Auto-complete assistance may be another claimed benefit.) However, a trade-off of this is that there are more dependencies and more complex dependencies such that if you pull things apart for reuse elsewhere, you have more non-connected wires to reconnect in a new environment.

Dynamic types do make it easier to perform GenericProgramming for data plumbing, dependency injection, etc.. Though you can achieve similar benefits in statically typed languages that have a safe model for casting (Haskell, Java, etc.). Regarding your last point, static types can be used to wire components together - i.e. if I need a FooBar, and there is a FooBar in the generic DependencyInjection context, then I can hook them up based on type. Dynamic types can be used the same way, of course, matching on structure or strings. I think, rather than actual capability, the difference is that static types would require a bit more design up front to support generics - i.e. ad-hoc reuse is harder with static types if you haven't planned for it (a feature most developers don't prioritize).


EditText of this page (last edited August 23, 2013) or FindPage with title or text search