4 ms·
The debate between static and dynamic typing continues unceasingly. Even when the runtime values are statically typed, it's merely reprised at the type level.
by edflsafoiewq 2y ago
The debate between static and dynamic typing continues unceasingly. Even when the runtime values are statically typed, it's merely reprised at the type level.
- smt88 2y agoThe debate seems to have mostly ended in a victory for static types. The largest languages other than Python have them (if you include the transition from JS to TS). Python is slowly moving toward having them too.
- Turskarama 2y agoI honestly don't see how anyone who has used a language with both unions and interfaces could come up with anything else that makes dynamic types better. Either way you need to fulfill the contract, but I'd much prefer to find out I failed to do that at compile time.
- adgjlsfhk1 2y agothe place where imo static languages come up short is first class functions.
- Gibbon1 2y agoI think C# has first class functions. Any pure function you can pass around. And you can create lambdas. gcc has nested functions that can act like a closure. And Clang has blocks.
- Turskarama 2y agoWhat are you talking about, the majority of functional languages have static types.
- ridiculous_fish 2y agoDon't confuse "presence of dynamic types" with "absence of static types." Think about the web, which is full of dynamicism: install this polyfill if needed, call this function if it exists, all sorts of progressive enhancement. Dynamic types are what make those possible.
- Turskarama 2y agoSure, I'm primarily a C# programmer which does have a dynamic type object, and occasionally use VB which uses late binding and can use dynamic typing as well. You want to know how often I find dynamic typing the correct tool for the job? It's literally never. Dynamic typing does allow you to do things faster as long as you can keep the whole type system in your head, which is why JavaScript was designed the way it was. That doesn't mean it is necessary to do any of those things, or is even the best way to do it.
- edflsafoiewq 2y agoThe whole anytype/trait question is just dynamic typing, but at the type level instead of the value level.
- deleted 2y ago[deleted]
- patrick451 2y agoIf I'm told to still use === in typescript, it's not actually a statically typed language.
- smt88 2y agoIt's not a statically typed language. No one is claiming it is. It's a dynamic language with static types.
- patrick451 2y agoNonsense. If I need to keep using === because the type might actually be something different at runtime, it doesn't have static types.
- smt88 2y agoIt has static types because the compiler won't let you change a variable's type. It's exactly as statically typed as C#. Both allow explicitly-declared dynamic variables, but they're disabled by default. === is incidental syntax required to maintain the goal of being a superset of JS.