It's not so much an issue of static typing, as it is one of JS's original design goals to try to never crash.
Ruby, for example, isn't statically typed, but will quite happily throw exceptions if you try to do things like 1 + "1" or even just "foo" + :bar.
(although it can do implicit conversion if you define the appropriate methods, e.g. to_str(), but thankfully the core classes have sensible definitions)
I actually love JS for that. Types were not up to snuff back then, and you don't want your website crashing constantly, nor do you want to take the time to make a formal proof of your photo gallery widget.
It's quick and dirty and durable. Like a bulldozer. It's a stupid tool for treating a patient, or doing your taxes, or a thousand other things, but if you need to just plow through a problem as fast as possible, boy does it go!
Sure, for its original intended use it's fine, but these things have a tendency to outlive intended purposes.
I'm working on an application at my job that was put in place as a temporary measure that needed to be up and running ASAP and would only be needed for a few months. Many design decisions were made on this assumption. This was 5 years ago, and it's vastly outgrown its original purpose, and it's been a heck of a struggle to bring it up to date
Btw don't take this as me hating on JS – I'm actually really rather fond of it.
View all comments
Show parent comment
15
u/caerphoto Jun 21 '18
It's not so much an issue of static typing, as it is one of JS's original design goals to try to never crash.
Ruby, for example, isn't statically typed, but will quite happily throw exceptions if you try to do things like
1 + "1"or even just"foo" + :bar.(although it can do implicit conversion if you define the appropriate methods, e.g.
to_str(), but thankfully the core classes have sensible definitions)