| ▲ | jt2190 2 hours ago | ||||||||||||||||||||||||||||||||||
> Strongly typed and weakly typed do not seem to have good definitions. Is strongly typed not “I compiler/runtime guarantee the bytes I read adhere to type T”? | |||||||||||||||||||||||||||||||||||
| ▲ | dtech 2 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||
There's a lot of nuance to that statement. Most languages, including e.g. Java or Typescript, would not be strongly typed according to your definition, because their type system is "unsound": there are known cases where the type system does not protect you and the types are wrong. We generally still call these languages strongly typed. In Typescript this is by design. The most obvious is array variance. Typescript makes them covariant because that's what a lot of sane TS and JS code uses them as, but they should be invariant because you can write to them. Example: | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||