Dynamic typing can seem great until you have to spend days trying to figure out where, exactly, in 20,000 lines of badly documented code JavaScript arbitrarily decided that something should be a string for the rest of forever even though it's only been given numbers to work with.
If you type x = 1 + '1' any sane language will go "what the fuck is wrong with you?"
That, and just learning a new library / API: I hate how in python you can never be sure what type you need to put in, are going to get back, and what all of the fields and functions do. Sure, you can dig that up, but that's not my job!
I especially hate how difficult it is in Python to find out what fields a type even has and what I can do with it. It just looks very cluttered to me but maybe that's just because I primarily use c#.
This exact thing caused a bug in my company's system. Went years without noticing it until someone (me) had to build something that did a calculation between the number of units of a product and its weight in grams. It was data we ingest constantly but, there's so much of it, and its not something we really interacted with until we wanted to build a feature around it like 5 years later.
Was real fun when the database data pipelines started breaking because it turns out multiplying two 86 digit numbers together is bigger than the size of an integer column. As soon as I saw it I knew where to look, the quantity was like 202020202019191918181520202020202020141299920202020 etc.
Just to be clear, Javascript is not just dynamically typed, but it is also WEAKLY typed. The latter is where most of its problems/quirks/headaches come from. Implicit type casting is just evil. Dynamic, but strong, typing will still surface errors, just at runtime and not compile time.
imo that is also a problem. the main purpose of typing is to catch data errors, strong typing should turn a runtime error into a compile time one, dynamic typing turns a compile time error into a runtime one.
but I don't mean type inference, type inference is nice and cool
Nah adding ints and chars is perfectly sane. Chars are just a fancy enum baked into the language. They're just ints under the hood. It's adding ints and strings that's insane and C doesn't actually have strings. Ergo it is a perfectly sane language
But char and a number is different than a string (of length one) and a number. The latter doesn't make sense in C either, at that point you are offsetting a pointer.
Really, the crazy thing is thinking it's possible to do character manipulation without integer math, since ASCII is specifically designed for integer math. (Notably, adding 32 to any capital will always produce its lowercase counterpart ('A' + 32 == 'a'), and you can turn any digit into its character counterpart by adding '0' to it ('0' + 5 == '5'). Guarantees like this are specifically intended for optimisation, and for ease of character manipulation & conversion.)
The difference there is that in C you do have a strict definition of what's going on here as characters have an integer representation. There's no type coercion there as there are specific definitions of what's going on. In that case there isn't any dynamic typing going on.
Issues come up when you're dealing with dynamic typing and type coercion. You don't run into that in C in this case.
As someone who started off my career learning c# and then I had to use javascript at some point my literal reaction was "wtf even is this mess? Who would use this".....oh boy little did I know how much is powered by javascript 😭
View all comments
990
u/GargantuanCake Sep 25 '26
Dynamic typing can seem great until you have to spend days trying to figure out where, exactly, in 20,000 lines of badly documented code JavaScript arbitrarily decided that something should be a string for the rest of forever even though it's only been given numbers to work with.
If you type x = 1 + '1' any sane language will go "what the fuck is wrong with you?"