#Why is int 8 bytes and not 4?

3 messages · Page 1 of 1 (latest)

verbal wind
#

What was the rationale behind the design decision to have Go's int type represent 8 bytes on a 64-bit architecture instead of the typical 4 in C/C++/Java?

crimson basin
#

int is the type returned by len, so it must be larger than 32 bits to support strings/slices/maps/channels with a length greater than 2^31

#

it's fairly arbitrary that int matches the name used in other languages, because C/C++, for example, features size_t that acts similarly