Hacker News new | ask | show | jobs
by scotty79 1783 days ago
> ... such as arbitrary predicate validation, freely composable schemas, automated instrumentation and property testing ...

Why static typing makes those things impossible?

1 comments

They don't make these impossible, they typically just don't let you express these within the type system and they typically don't let you not specify your types.

I should have made clear that I'm emphasizing the advantages of being dynamic to describe and check the shape of your data to the degree of your choosing. Static typing is very powerful and useful, but writing dynamic code interactively is not just "woopdiedoo" is kind of the point I wanted to make without being overzealous/ignorant.

That largely depends on the type system. Languages like Haskell and Scala which have much more powerful type systems than C/Java/Go/etc absolutely do allow you to do those sorts of things. It is a bit harder to wrap your head around to be sure and there are some rough edges, but once you get the hang of it you can get the benefits of static typing with the flexibility of dynamic typing. See https://github.com/milessabin/shapeless or a project that I've been working on a lot lately https://github.com/zio/zio-schema.
I think TypeScript is best of both worlds.

Typesystem strong enough to express dynamic language and completely optional wherever you want.