PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in
PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in

posted in Technology

lemmydividebyzero@lemmydividebyzero@reddthat.com
⁨20⁩d

Name before type: why 'age int' is better than 'int age'

benhoyt.com/writings/name-before-type/
benhoyt.comName before type: why 'age int' is better than 'int age'A variable's name is more important than its type, so the name should be more prominent and come first in declarations.
101035
Open original page
BoostsQuotesFavs
∟⊔⊤∦∣≶@luthis@lemmy.nz
⁨20⁩d

Replying to @⁨lemmydividebyzero@reddthat.com⁩

Hard disagree. Is that a joke? Type is far More important than name. Just ask the compiler.

7000
Open original page
BoostsQuotesFavs
chrash0@chrash0@lemmy.world
⁨20⁩d

Replying to @⁨luthis@lemmy.nz⁩

a lot of modern languages explicitly disagree, eg Kotlin and Rust

2000
Open original page
BoostsQuotesFavs
andallthat@andallthat@lemmy.world
⁨20⁩d

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

⁨Jul⁩ ⁨26⁩, ⁨2026⁩, ⁨06:26⁩en
1000
Open original page
BoostsQuotesFavs
chrash0@chrash0@lemmy.world
⁨20⁩d

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.

0000
Open original page
BoostsQuotesFavs