Re:JavaScript: The Modern Parts
by rgoulter on Saturday August 24, 2019 @12:56PM
(#20788230)
While it's fair to say that a static type system adds friction which isn't suitable for some development mindsets,
I think it's worth expanding on problems people run into with types.
Bad types at runtime: with a static type system you make the effort to be sure the code does what it says. With plain ol' JS you can get that confidence from tests.
-- different trade-offs made each way.
But another benefit to static types is knowing the structure of the data you're dealing with and how to manipulate it, while you're developing/maintaining the code.
-- sure: naming, unit tests, documentation etc. can help, but I find not having the static types handy makes things tricky when there's enough indirection/complexity.
As with the stuff about runtime errors, tastes vary, of course.
Bad types at runtime: with a static type system you make the effort to be sure the code does what it says. With plain ol' JS you can get that confidence from tests. -- different trade-offs made each way.
But another benefit to static types is knowing the structure of the data you're dealing with and how to manipulate it, while you're developing/maintaining the code. -- sure: naming, unit tests, documentation etc. can help, but I find not having the static types handy makes things tricky when there's enough indirection/complexity.
As with the stuff about runtime errors, tastes vary, of course.