4 ms·
This is why I think gradual typing with structural types is the Right Way, and will be what all modern programming languages move towards (like how we don't hav
by OmarIsmail 11y ago
This is why I think gradual typing with structural types is the Right Way, and will be what all modern programming languages move towards (like how we don't have to worry about manual memory management anymore).
Javascript with Flow, or TypeScript is a great example of this. Perl6 is using gradual typing.
The key thing is that there are times where you want the inflexibility of static typing, and there are times where you want the benefits of dynamic typing. Structural types also remove dependencies because the function defines the structure of the type it expects, and not a specific reference.
Also, I think github repos (and the person's tests) are heavily heavily bias towards individual projects. There's a massive difference between something only one person works on, and something that an entire team is developing over the course of years (as team members come and go).
- 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?