News for hackers. Stuff that matters.
Re:Strong typing, a hill I'm willing to die on by loup-vaillant on Wednesday October 04, 2023 @09:57AM (#37765256)
> Many dynamically typed languages have static analyzers, but retain the flexibility of not needing to prescribe types up front

Almost all static type systems have escape hatches that let you go dynamic when you really really need it. Also, I bet that most of your use cases for dynamic typing could be solved with a simple tagged union. Most people bemoaning the lack of flexibility of static typing just don’t know about how tagged unions can easily emulate dynamic typing when we need it, such that we rarely even need to reach for the actual escape hatches.

> (it’s impossible to know exactly what data structure you need at the start of a project)

Thankfully data structures are even easier to change with static typing: change it, gets a ton of type errors, fix them, done. With dynamic typing you run the risk of missing a call site.

> Having to prescribe the types I need before I actually need them goes against how I tend to build.

There’s type inference for that. I personally take advantage of it any chance I get.

There are no comments on this comment yet.