The programming world is strongly moving toward statically typed languages, because today, there's pretty much zero reasons to use a dynamically typed language.
The programming world is strongly moving toward statically typed languages, because today, there's pretty much zero reasons to use a dynamically typed language.
How? Python and Javascript (not Typescript) are two of the most popular languages in the world and still growing very fast by many accounts. Which strongly typed languages are taking over?
For years, dynamic typing has been hyped on HN, while statically typed languages such as C# were routinely scoffed at.
Something in the air has definitely changed recently, with many discovering the very trait they eschewed is actually a major boon - very likely because they had only ever dealt with JavaScript. My guess is this is primarily driven by the growing popularity of TypeScript, Rust and Go.
- Type inference becoming commonplace is an important factor. Previously it felt kind of silly in statically typed langs to supply some of the things compiler could figure out.
- Strict null checking becoming commonplace increased confidence. Previously, even if your code compiled, you would still get null pointer exceptions.
- Type checking became kind of opt-in with langs like TypeScript.
- Statically typed langs used to be associated with heavy IDE's previously. Now you can use most editors and get the benefit of compiler within the editor through language servers.
def handle_data(%{
customer: %{
date_of_birth: %NaiveDateTime{} = dob,
account_balance: %Decimal{} = balance,
name: name,
count_purchases: purchases
}
}) when is_binary(name) and is_integer(count_purchases) do
# work with the data here
end
^ This both asserts on a particular data structure (a map with a "customer" key containing at least those four attributes) and asserts on the types of some of the attributes. I find it pretty handy and practical.---
But I concede that strong+static typing eliminates a class of bugs preliminarily. That is unequivocally true.
Elchemy, Alpaca, and Gleam try bringing static typing to the BEAM, but they're still too immature, unfortunately.
Unfortunately, the tradeoff at the time made us stop using specs altogether.
And this is anecdotal but with good pattern-matching and guards in Elixir, I can’t remember the last time I created a bug that would have been made impossible by static typing.
Wrong, type inference has been aa thing for decades.