> it limits my thought process when i have to think what the variable's type is after every line of code
Why do you feel the need to think about the variable's type on every line though? Since they're typed, you should pretty much know exactly what they are, instead of trying to figure it out. Since they're not dynamic, they're never changing.
let me give an example. there is no easy or straight forward way to make a string's length variable. i cannot for example do something like 'int string1[n]' where n is something i got through scanf. also there are different functions to get user's input for intigers and strings. Why would anyone have so many different things like scanf, getch, getche, gets, etc. why not make one simple function and take other things as an argument?
So i need to stop and think how can i input a variable from user, which function should i use. I was just defending js. I don't oppose C, i am just saying its about perspective. C is as much crazy to me as is JS to some other people. this does not make C evil.
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".
Why do you feel the need to think about the variable's type on every line though? Since they're typed, you should pretty much know exactly what they are, instead of trying to figure it out. Since they're not dynamic, they're never changing.