4 ms·
> benefits of dynamic typing What, specifically?
by ionforce 11y ago
> benefits of dynamic typing
What, specifically?
- ufo 11y agoThe biggest one, IMO is that dynamic languages are simpler and more flexible. We can usually describe the semantics of a statically typed language based on a simpler dynamic language together with a type system^1. The purpose of the type system is to ensure that certain undesired behaviors do not occur when we execute the program. For example, adding a number to a string, calling non-existing method in an object, and so on. From this point of view, a type system adds static guarantees to your program (certain classes of bugs never happen, the editor has an easier time doing autocomplete, etc) at the cost of increased complexity and learning curve (you need to learn the type system in addition to the runtime semantics) and decreased flexibility (every type system inevitably disallows some programs that would not have resulted in one of the undesired behaviors had you just had faith and ran everything). I also think it helps to see static typing as a spectrum. For example, most languages only detect division by zero and index-out-of-bounds errors at runtime. Dependently-typed type systems can be used to guarantee that errors like these do not happen at runtime but they are much harder to learn (lots of advanced type theory is involved) and use (you need to do a lot more work to appease the type system) ^1 - A notable exception are language that use type-based name overloading. But if you "desugar" the overloading then the styatic types are usually eraseable at runtime.
- loup-vaillant 11y agoMost probably heterogeneous collections (which are covered by sum types), and polymorphism (which is covered by "virtual" inheritance or closures).
- OmarIsmail 11y agoSpeed, specifically when doing some quick prototyping/exploration.
- ionforce 11y agoWhy is a dynamic language quicker for prototyping and exploration?