I’ve got a growing appreciation for Rust. There’s a lot of benefits. But it is overkill for most things I guess.
I’m a big fan of type hinting like in Python though. You can have some of the safety of static analysis with the flexibility to fuck around if you find it makes it easier to grok the code.
In programming you declare variables. To keep it simple let’s say there are only 2 types, numbers and words.
Now 1 is obviously a number, and ‘word’ is obviously a word. If I ask you to divide 100 by ‘word’ you’d have to tell me that’s not possible.
Now what if a say divide 100 by the “word” ‘10’? Well I’m a strongly typed programming language, you’d have to tell me “well, because you defined it with the single quotes, that’s actually a word so you can’t do math on it.” In a loosely typed language you’d be like “yeah I get that ‘10’ meant the number 10 so I’ll do the math.
This creates amusing weirdness in loosely typed languages, especially when they use math operators to represent word actions. For instance JavaScript is infamously loosely typed and uses the + sign to join words together so if I say ‘Java’ + ‘Script’, I get back ‘JavaScript’. So all the following are true in JavaScript:
1+1=2
1-1=0
‘1’+1=11 because the ‘1’ makes it think you want to join words and it converts the second number 1 to a word
‘11’-1=10 because there’s no word operation applied to the minus sign, so it converted the word ‘11’ to a number
There’s lots of other tomfoolery, but I’m trying to keep the explanation simple. But any mixing of words and numbers in a strongly typed language would just give you an error.
I’m with the top reply of this thread, you don’t need strong typing if you understand what the code does.
I think strong/static typing with inference is the sweet spot. Complex types can change, so it helps to at least have your boundaries well defined. Within the scope of a function, if you need explicit typing on everything then your function might be getting too complex.
It’s a feature of a programming language that usually, but not always, requires you to declare what sort of data everything is (this is a number, this is text, this is a person object I made, etc.). Then you are required to run your program through a program called a compiler before you are allowed to run it, to (among other things) make sure that everything is what you said it was.
Basically, it requires you to be extra pedantic, but some say it catches common errors. But imo these are the sort of errors that only come up because you have tons of people working on one project.
Static typing can kiss my ass.
The only reason you like it at work is because you are surrounded by idiots.
i like it in personal projects too. it makes everything neater and safer, especially with algebraic data types
I’ve got a growing appreciation for Rust. There’s a lot of benefits. But it is overkill for most things I guess.
I’m a big fan of type hinting like in Python though. You can have some of the safety of static analysis with the flexibility to fuck around if you find it makes it easier to grok the code.
What is static typing?
In programming you declare variables. To keep it simple let’s say there are only 2 types, numbers and words.
Now 1 is obviously a number, and ‘word’ is obviously a word. If I ask you to divide 100 by ‘word’ you’d have to tell me that’s not possible.
Now what if a say divide 100 by the “word” ‘10’? Well I’m a strongly typed programming language, you’d have to tell me “well, because you defined it with the single quotes, that’s actually a word so you can’t do math on it.” In a loosely typed language you’d be like “yeah I get that ‘10’ meant the number 10 so I’ll do the math.
This creates amusing weirdness in loosely typed languages, especially when they use math operators to represent word actions. For instance JavaScript is infamously loosely typed and uses the + sign to join words together so if I say ‘Java’ + ‘Script’, I get back ‘JavaScript’. So all the following are true in JavaScript:
1+1=2 1-1=0 ‘1’+1=11 because the ‘1’ makes it think you want to join words and it converts the second number 1 to a word ‘11’-1=10 because there’s no word operation applied to the minus sign, so it converted the word ‘11’ to a number
There’s lots of other tomfoolery, but I’m trying to keep the explanation simple. But any mixing of words and numbers in a strongly typed language would just give you an error.
I’m with the top reply of this thread, you don’t need strong typing if you understand what the code does.
I think strong/static typing with inference is the sweet spot. Complex types can change, so it helps to at least have your boundaries well defined. Within the scope of a function, if you need explicit typing on everything then your function might be getting too complex.
It’s a feature of a programming language that usually, but not always, requires you to declare what sort of data everything is (this is a number, this is text, this is a person object I made, etc.). Then you are required to run your program through a program called a compiler before you are allowed to run it, to (among other things) make sure that everything is what you said it was.
Basically, it requires you to be extra pedantic, but some say it catches common errors. But imo these are the sort of errors that only come up because you have tons of people working on one project.