Dynamic vs Static Typing
Dynamic typing in programming languages is better than static typing
This statement used to be true for various reasons. It’s not anymore. Let’s dig into why.
Dynamically typed languages and frameworks like Ruby on Rails and LAMP stack blew up in popularity for various reasons. Let’s rewind the clock back a couple decades or so and look at the context.
Software development was dominated by statically typed languages like C++, Java, and C#.
Ruby on Rails and LAMP stacks were positioned perfectly to sweep and dominate the entire ecosystem at this point.
领英推荐
I obviously haven’t been around that long, but those who have remember static typing not as it is today, but as it was back then. It was an indicator of ceremony, slow feedback loops, and proprietary dinosaurs.
Static typing has made a major comeback over the last decade, and almost everything that turned people away from them and towards the comfort of PHP and Ruby has been UNO reversed.
The factors that blew up Rails and LAMP in popularity are now the same factors that favor ecosystems that offer complete type safety. Dynamic typing has become, to put it strongly, obsolete. They are artifacts of the past.
Yes you can use dynamically typed languages to build real systems for scale. But you will pay the cost of maintenance, performance, and scalability, and eventually will have to rebuild using infrastructure that offers much better guarantees.
Dynamically typed languages are used not because they are dynamically typed, but because they have specific technical benefits (e.g. Elixir for building distributed systems) or ecosystem benefits (e.g. Python for data science).
Starting off with type-safe languages will give you faster feedback loops, more helpful IDE tools, more freedom to make changes without breaking stuff, and better collaboration through internal contracts and documentation at a very low cost.
“…a couple decades ago…”; “…as it was back then…” — gosh feeling old right now ?? “Modern static languages like Typescript have ridiculously low learning curves” Having onboarded a team of junior to mid engineers onto a typescript app, the learning curve is still as steep as any typed language. And it only gets steeper the greater the complexity of the types required. Simple typing? Sure, easy to execute, but there is still a lot of ceremony. Leveling up engineers to write concrete, meaningful types takes a lot of work and still we know many senior engineers (and typescript fans) vent frustrations. The cost of the path to greatness is a ruin of terrible typing along the way where I’ve seen some applications were better off not typing at all. At the end of the day choosing a language is another technical trade-off like any other, but by no means will dynamic languages be obsolete any time soon. Many of the reasons that made them great choices the first time around are still valid.
Software Developer
1 年It depends on the problem and how you express yourself. Dynamic typing could theoretically motivate you to express intent better - I think. You would think twice before writing. Because of no static type checking. You are not primarily thinking about values that have types, but values that have a meaning.