3 ms·
As far as I understand dynamically 'typed' languages are actually the way we can get the best of both worlds since dynamically typed languages can be 'upgraded'
by tosh 12y ago
As far as I understand dynamically 'typed' languages are actually the way we can get the best of both worlds since dynamically typed languages can be 'upgraded' to benefit from type annotations (see Dart, Hack/PHP, Python, …) whereas languages with static typing are not easy to 'downgrade' to behave dynamically (?).
The author runs into a few logical fallacies like underestimating how important early agility is for making a product successful (if your product isn't successful there is not much to 'fortify' using static typing) or conflating static/dynamic with strong/weak.
The bottom line imho is that we want languages that are both easily toolable (type systems can help here) as well as allowing us to do fast prototyping. It seems like starting with a dynamic language and to add optional/gradual type annotations is the way to go.
- tosh 12y agoIf you want to get a feeling for what a dynamically typed language + support for type annotations can give you have a look at this: https://dartpad.dartlang.org/ https://dartpad.dartlang.org/ On the top right you can select a Dart code sample. DartPad is similar to jsfiddle but it gives you semantic autocompletion, warnings and auto-correction like IDEs for languages with static typing would do.
- Retra 12y agoIt shouldn't be that hard to add a 'variant' type to a statically typed language. In fact, OO languages usually just use a common superclass for just this purpose.
- dllthomas 12y agoAnd of course Haskell now has Dynamic, it's just not very useful.
- Retra 12y agoIt's probably useful if you wanted to implement a dynamic language using Haskell. :P
- dllthomas 12y agoI'm not sure if this was intended in jest, but it's a bit interesting to treat it seriously so I'm doing so... I think it would not be a very good choice to implement a dynamic language in Haskell, because what it makes flexible is choice of Haskell type, and you likely don't want to tie implemented-language type to Haskell type like that. It would seem more likely to be useful if you wanted to host a dynamic language within Haskell.
- Roboprog 12y agoOr if you are "Go", you just make up an interface with a "quack" method (and maybe "walk", "swim" and "fly", too), without the concrete types ever knowing / caring that there was such an interface, all while still getting the needed type checking on the function/method calls.
- dllthomas 12y agoStatic types help with early agility. I don't have to get everything right at the outset, because I can change my code and know what I broke. That's possible in a code base that can't be statically type checked if you pin things down with sufficient tests... but the tests don't rewrite themselves when I make a change to the code - the types do (at least, when working in a decent language). Note that I'm not at all saying that every statically typed language is superior to every dynamically typed language. Many - particularly older, popular, and oversold statically typed languages - asked for a lot of boiler plate in exchange for not terribly valuable guarantees.
- tosh 12y agoI think we are in agreement but have different things in mind when we use the word agile in this case (which is not surprising). What I meant was the ability to write new code and see if some functionality of the product 'works' before I have to satisfy the type checker. In statically typed languages I have to satisfy the type checker before I can run the code, that is a barrier. Regarding refactoring good tooling supported by type annotations are definitely helpful. I guess what I'm trying to say is that we have languages now that give us the best of both worlds, no more need to pick either extreme of the spectrum or use a dynamically typed language in the beginning and to rewrite everything again in another language later.
- dllthomas 12y agoI appreciate the charity, but I think we do actually have a disagreement. Let's go too far, and define "agility" to be "things that make me faster in the first 5 minutes working on a problem." I am saying that when I am writing Python in that context, Haskell's type system is something I find conspicuously missing.
- chadaustin 12y ago> whereas languages with static typing are not easy to 'downgrade' to behave dynamically (?). That's not true. It's trivial to represent Python's "type system" in Haskell. An incomplete example of what that might look like: data Value = None | String Text | Dict (HashMap Text Value) | List [Value] Also, consider things like the very useful Data.Dynamic: https://hackage.haskell.org/package/base-4.3.1.0/docs/Data-Dynamic.html https://hackage.haskell.org/package/base-4.3.1.0/docs/Data-D... On the importance of early agility: I'm actually 100% in agreement that early agility is critical. In fact, I directly cite Bruce Eckel's arguments to that effect. However, if a business is going to remain agile in the long term, it should probably invest in "correctness tooling" sooner rather than later.
- tosh 12y agoThanks for the elaboration.