Hacker News new | ask | show | jobs
by fakedrake 3167 days ago
Typeclasses and parametric types are there to leverage the typesystem. It's hard to see how you can benefit from these abstractions if all you have is ducktyping.
2 comments

Not a genuine answer, but JavaScript has a great ability to inspire respect for type systems, due to that duck typing.

I suppose the GP enforced it manually?

Javascript doesn't support duck typing. It doesn't support any typing actually: it's dynamically typed.

If Javascript can inspire respect for type systems, it's by making you realize that not having type annotations leads to terrible, unmaintainable code.

> Javascript doesn't support duck typing. It doesn't support any typing actually: it's dynamically typed.

Dynamically typed doesn't mean untyped; you still have types in JavaScript. Most dynamic languages are strongly typed, not untyped. You're conflating a few unrelated things. JavaScript is duck typed, as virtually all dynamic languages are.

Dynamic typing isn't lack of typing.

The fact that types cannot be statically checked doesn't mean you don't have any.

Bash only has one type, the string, and is thus statically typed.

Is Bash's type system better than say, Python's ?

Yes, that was my point.
Dynamic typing is a typing. Also, duck typing is used more in the dynamic sense than the static sense, where in the latter it is instead called structural typing.
Those abstractions are about static typing, not functional programming. Functional programming doesn't require static types.
dingdingding! we have a winner

)))