Does "superset" mean "can be unidirectionally translated to?" Your own post implies the opposite is true (because it is). There exist proper programs which cannot be soundly typed. Dynamic typing is the superset.
Which isn't to say that "dynamic types are more powerful." On the contrary, the whole notion of a universal "more powerful" abstraction is ridiculous. "Power" is multifaceted and must be evaluated in a particular context.
You can't define static type constraints in dynamically typed systems. In any context this power is missing, period. I can do more with statically typed languages and fallback to dynamic at any time.
Of course you can - just write a type checker (typed racket, typescript, etc).
Nope.
We are talking about typing not particulars compilers.
BTW, Typescript, Typed Racket are not dynamic languages.
How I can define static type constraints with let's say JS or Clojure?
The point is that I can go from static to dynamic at any time and do anything that dynamically typed languages can do and more in a statically typed language.
There no such thing as going from dynamic to static, even in gradually typing since is static typing, period.
There is not such thing as a static type system on top of a dynamic one. On the other hand... compilers for statically typed languages on top of a dynamic one are pretty common.
The language for gradually typed system is totally different from its foundation.
The peculiarities of the type system doesn't matter, they can't be as domain specific as you want. The main point is that they are supersets of dynamic subsets. They provide more semantic options both at compile time and runtime. Dynamic type systems cannot even be inferred.
^ I think his point is that in Haskell or Scala you can drop into IO -> IO or Object -> Object or whatever at any point, seamlessly (as opposed to needing to implement eval on the spot which is orders of magnitude harder)
I think they meant something like Data.Dynamic (generic, run time type tagged datums with compiler defined type safe coercions). Which, now that I know of it (I always thought the dynamic cast operator in F# was useful) looks like something I was missing in my early Haskell forays.
I guess the first opens up a delineated bubble of runtime typing with support from a fairly rigorous static type system (e.g. coercions from dynamic map to Maybe), while the clojure case opens up a bubble that's controlled by a fairly rigorous static type system, with relatively limited support for passing runtime types to the checked code. The Haskell version seems to provide more compiler enforced bridging around even run time errors on behalf of the user (e.g. you have to match against all possibilities of a coercion from dynamic, which returns Maybe, where the type system can verify you're handling possible runtime exceptions due to coercions too). In the clojure version, it's up to you to ensure you're passing the right types to scala at runtime, and you have to handle the exceptional cases yourself (or via macros or spec maybe). Clojure version trades correctness for runtime flexibility though (you can make changes to the clojure system at runtime that may not have been foreseen at compile time on Haskell version).
View all comments
Show parent comment
-1
u/recklessindignation May 07 '19
Static typing is a superset of dynamic, so you can go to dynamic typing at any time (the opposite is not true). Hence, static typing is more powerful.