One simple example: when you read a telephone number, you care very much whether it's a string or an integer. The reasons are:
- 004412......... and 4412..... are completely different things. You care also about how you annotate base of integers, because anything starting with "0" might be an 8-base integer.
- Even if we assumed local numbers don't start with 0, there are some places where such number doesn't fit into an integer. 32b int is only 10 digits in dec base.
So yes - whether it's C or JS you should very much care what the actual type is. This isn't very theoretic either. Some time ago, twitter started using id which were larger than 32b fields. Even though people should've been treating those ids simply as opaque strings, some used integers, leading to twitter client update panic.
well yes but i was talking about how it's stored in memory. Like in js all the numeric operations can be performed on strings that are just numbers. Think of it as an intelligent string that behaves according to it's contents. if it's contains an integer, it behaves like one. since there are finite number of types a variable can have, it shouldn't be a huge deal to automate this. But since this has not already been done, i am obviously missing something here.
No, it doesn't. If it's a string, it's a string: "1" + "1" -> "11". I know what you mean (it would if the first op wasn't a string), but see how this got confusing even in your short message. I'm still not sure why would you want to automate all types into a magic one that does what you want... unless you split all operators into N distinct ones giving you different results. But then you get the same result really - ops determine your results.
Again using phones example:
country + area + ending
is different depending on what the actual types are. This is simply an issue we cannot ignore. In this case I'm expecting the concatenation and the result cannot depend on "contents of the string".
- 004412......... and 4412..... are completely different things. You care also about how you annotate base of integers, because anything starting with "0" might be an 8-base integer.
- Even if we assumed local numbers don't start with 0, there are some places where such number doesn't fit into an integer. 32b int is only 10 digits in dec base.
So yes - whether it's C or JS you should very much care what the actual type is. This isn't very theoretic either. Some time ago, twitter started using id which were larger than 32b fields. Even though people should've been treating those ids simply as opaque strings, some used integers, leading to twitter client update panic.