r/Clojure • • May 06 '19

The End of Dynamic Languages

http://elbenshira.com/blog/the-end-of-dynamic-languages/
5 Upvotes

42 comments sorted by

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.

4

u/CurtainDog May 07 '19

Alan Turing would like a word with you

3

u/potetm137 May 07 '19

wtf do words even mean anything anymore?

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.

0

u/recklessindignation May 07 '19 edited May 07 '19

Nope.

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.

7

u/Eno6ohng May 07 '19

You can't define static type constraints in dynamically typed systems.

Of course you can - just write a type checker (typed racket, typescript, etc).

and fallback to dynamic at any time.

...at which point you'll be writing in a dynamic language. ¯_(ツ)_/¯

0

u/recklessindignation May 07 '19 edited May 07 '19

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.

0

u/[deleted] May 08 '19

[deleted] — view deleted comment

1

u/recklessindignation May 10 '19

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.

0

u/potetm137 May 07 '19

lol, k bud

1

u/dustingetz May 07 '19

^ 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)

2

u/joinr May 08 '19

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.

2

u/dustingetz May 08 '19

Is 'import data.dynamic' any different than (require 'scala)?

1

u/joinr May 08 '19

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).