Anonymous
7/8/2025, 7:22:40 PM
No.105839709
>>105840152
>>105840379
>>105840516
>>105840705
>>105841153
>>105841180
>>105841255
>>105841334
>>105842417
>>105842807
>>105843146
>>105843159
>>105843411
>>105843701
>>105845056
>>105845064
>>105845550
>>105845609
>>105845750
>>105845905
>>105846994
>>105847052
>>105848774
Declaring variables
Please someone explain to me why some new typed languages are declaring variables by putting the data type after the name of the variable?
I've only heard reasoning that the variable name is more important than the type (not true) and that the conversion from JavaScript to TypeScript is easier for AI (not true either) and that it's better for visual representation for humans. None of this makes any sense to me.
In C/C++ we often use separate header files to list declarations, which could then be shared among different files. The name of the variable is most certainly not the most important thing there. Consider:
char sex;
int phone;
double height, weight;
versus
let height:double
let phone:int
let sex:char
let weight:double
It's pretty clear the latter is meant for script kiddies who learned to program with JavaScript, as for them everything is automatically a string/object. Commonly also used in Bash scripts.
As for real programmers, types matter the most. It's how computers actually work. You store types in memory. Back in the day when memory was limited (and still is in embedded devices), you would actually need to calculate the memory, e.g.
char is 1 byte
int is 4 bytes
long is 8 bytes
double is 8 bytes
And thus you would know that int can take 4 chars, long can take 8. So if you needed to store a letter with say, a newline character, you'd know you have to use int rather than char.
And the bottom line is, I don't think there was a reason to change from the C/C++/Java/C# style other than edgelords who wanted to be different. There's like a ton of actual reasons why the C style is superior.
I've only heard reasoning that the variable name is more important than the type (not true) and that the conversion from JavaScript to TypeScript is easier for AI (not true either) and that it's better for visual representation for humans. None of this makes any sense to me.
In C/C++ we often use separate header files to list declarations, which could then be shared among different files. The name of the variable is most certainly not the most important thing there. Consider:
char sex;
int phone;
double height, weight;
versus
let height:double
let phone:int
let sex:char
let weight:double
It's pretty clear the latter is meant for script kiddies who learned to program with JavaScript, as for them everything is automatically a string/object. Commonly also used in Bash scripts.
As for real programmers, types matter the most. It's how computers actually work. You store types in memory. Back in the day when memory was limited (and still is in embedded devices), you would actually need to calculate the memory, e.g.
char is 1 byte
int is 4 bytes
long is 8 bytes
double is 8 bytes
And thus you would know that int can take 4 chars, long can take 8. So if you needed to store a letter with say, a newline character, you'd know you have to use int rather than char.
And the bottom line is, I don't think there was a reason to change from the C/C++/Java/C# style other than edgelords who wanted to be different. There's like a ton of actual reasons why the C style is superior.