See all glossary terms
- The Static/Dynamic spectrum is about when type information is acquired. Static types are acquired at compile time, and can show errors in your editor. Dynamic types are acquired at runtime, and can only show errors when the code is executed. But Dynamic also almost always means that types can change at runtime.
- The Strong/Weak spectrum is about how strictly types are enforced; can they be automatically converted from a type to another, and can you read a type as another type.
- Explicit/Implicit is about how types are declared. In explicit languages, you need to declare the type of a variable. In implicit languages, the type is inferred from the value assigned to the variable. Some languages mix both, like GDScript or Typescript. "Explicit/Implicit" is not a technical term.
I used "spectrum" to signify that languages are either one or the other, most languages will have aspects of both.
"Dynamic languages" is often opposed to "Strongly typed languages", but that isn't actually always the case.
It would be more correct to call languages like GDScript, Python, or Javascript "implicitely typed". The types are always there! You might just not know.
When you write var number = 10
, number is an integer. The type is there, and it is enforced when used in an operation: in GDScript, you can't do "hello" + 10
. You need to convert the number to a string first. There is very little implicit coercion.
GDScript is optionally typed, and when that happens, those types become "Strictly typed", because you cannot reassign a different type to a variable.
On the other hand, Javascript will happily juggle from one type to another. 1 + {}
is perfectly valid in Javascript. It has much more implicit coercion. But even Javascript is more strongly typed than C++ for example. In C++, the language allows you to read a class as an integer, for example, or use any type as any other, since values are just a bunch of bits.
And for yet another example, Rust is explicitly and strongly typed, but a variable can change its type (through a process called "shadowing").See Also
Related terms in the Glossary
school.gdquest.com - 0.3.5-2024-12-12T18:17:18.104Z-a38dc74be3238fd1ea161f4df67b95520741da9d-release