3 ms·
>Nim is a statically typed programming language, meaning that the type of an assignment needs to be declared before using the value. This is not strictly true,
by sullyj3 8y ago
>Nim is a statically typed programming language, meaning that the type of an assignment needs to be declared before using the value.
This is not strictly true, in languages with type inference (which are becoming increasingly common)
- PMunch 8y agoNim has type inference as well, but the type still has to be known before we can use a value. From the tutorial: > Nim also has type inference ability — the compiler can automatically detect the type of a name assignment from its value, without explicitly stating the type.
- MaxBarraclough 8y agoWell that's exactly the point. It's statically typed, so of course types have to be known at compile-time, but it can use type inference rather than explicitly expressing type in declarations. Static typing with type inference is still static typing. Vaguely related: many people also confuse 'dynamically typed' and 'untyped', despite that they're not even close.
- jerf 8y agoI've seen that called "type deduction" to distinguish it from "type inference". It's a much simpler feature. Arguably it's more of a convenience, whereas "type inference" tends to have real effects on the idiomatic way to design solutions in the language. A nice one though; I wouldn't care to go back to a language where I'm double-specifying types all the time like that.