posted in Technology
Name before type: why 'age int' is better than 'int age'
benhoyt.com/writings/name-before-type/posted in Technology
Name before type: why 'age int' is better than 'int age'
benhoyt.com/writings/name-before-type/Replying to @lemmydividebyzero@reddthat.com
Hard disagree. Is that a joke? Type is far More important than name. Just ask the compiler.
Replying to @luthis@lemmy.nz
a lot of modern languages explicitly disagree, eg Kotlin and Rust
Replying to @chrash0@lemmy.world
I think that’s so type inference can work by just omitting the type, instead of having to use “var” or “auto” in front of the variable name
Replying to @andallthat@lemmy.world
not precisely. Rust has let mut and Kotlin has val; ie the member layout and the mutability are treated differently, since those languages have mutability rules.
this is a circular argument anyway. the language designers could have figured out a way to do type inference like, eg, Java, but, again, explicitly chose not to.
Replying to @chrash0@lemmy.world
let foo : String;
In rust the variable name is before its type (which can be omitted if the compiler can infer it).