Typing - way in which computers determines different data formats.
Static Typing - Type defined at compile time
Dynamic Typing - Type defined at run time
Weakly Typed - Variables can change type at run time
Strongly Typed - Variables cannot change type at run time
When I first stated learning development, I used to think of "typing" as "typing on a keyboard" rather than "data typing"
which is why everything was a little bit more confusing at the start. You live and learn tho.
Data typing is a way of describing the type of data we are using. For example, we know that a boolean can only be True or False, or 0 and 1.
This process allows the compilers to determine the required memory to hold data and ensure that the program can be run with no type errors.
If we define the type of data when we declare a new variable such as :
//Java boolean isValid = true; int number;
then this is known as Static Typing where type is explicitly typed before the compiler. Languages such Java or C# as do this.
Attempts to re-assign the variable type will result in an error:
//Java boolean isValid = "naw, mate"; //compilation error
The type checking in this case, is done at Compile Time ( although many IDE's will let you know ahead of time, they are good that way).
Where as in others, this is not the case:
boolean hello = true; hello = "hello"; //error: incompatible types: String cannot be converted to boolean
Sometimes, languages are super flexible, like Go. Whilst being usually considered a strongly typed static language, it allows the compiler to determine the type, but once its set, you cannot change it:
isValid := true isValid = 1 //cannot use 1 (type untyped int) as type bool in assignment
In theory, yes, because the compiler doesn't need to work out what data type it needs.
In practice, this is not the only way to measure performance. In Java vs Go comparison, both languages are statically and strongly typed and yet the performance varies due to a multitude of other factors.
In addition, different languages have different use cases, and have been developed with different purposes in mind
(whether they have kept to it 10yrs down the line, thats a different issue) and so sometimes its like comparing Apples and Oranges.
As always, it depends.
But in majority of the cases, I would argue that this is a code smell and show be avoided where possible. Typescript was created in the big part, to help JS devs eliminate type bugs!
In certain cases it does make sense.