News for hackers. Stuff that matters.
Re:Go 2, here we come by throwaway34241 on Thursday November 29, 2018 @03:42PM (#18563797)
Which would you choose instead? To default to 32 bits (even on 64 bit systems) or to default to 64 bits (even on 32 bit systems).

Defaulting to 64 bit math on 32 bit systems will have a huge performance penalty on generally the slowest/oldest systems where this penalty is least desirable. It's not clear to me what the benefit to this would be for most programs.

Running 32 bit ints on 64 bit systems will cause problems handling large arrays on systems with a lot of memory. I think it also complicates generating efficient loop code, although C++ gets around this with signed integer overflow being "undefined behavior".

Of course Go has int64 and int32 types if you want to use them (and all conversions require explicit casting), but the default type for array lengths etc is the platform native type. But what is the better alternative?

Re:Go 2, here we come by tigershark on Friday November 30, 2018 @03:22AM (#18567581)
I would use int and long like in C# for example, with no magic int that can be 32 or 64 bit depending on the platform to avoid any confusion.
Re:Go 2, here we come by throwaway34241 on Friday November 30, 2018 @07:09PM (#18573993)
And as a result of this, you can't have a 3GB byte array in C#. I think there needs to be a big benefit to make hard-coding a restriction like that into the language worth it.

Unfortunately I've read every comment in this HN thread (so far) and I haven't found any specific one mentioned, just people calling it "crazy" and "confusing" over and over.

Go is a language that has explicit pointers! And of course those can be 32 or 64 bits and change struct sizes, field offsets etc. There are certainly things about Go that are confusing but I've never thought this was one of them.

Just FYI Go has int8, int16, int32, int64, and int types. Only the 'int' type is the machine-native one. It's always been obvious to me that 'int' is the one without a fixed size, but I think this would be less obvious if the naming convention was different using short, int, long etc.

Re:Go 2, here we come by toyg on Thursday November 29, 2018 @03:55PM (#18563915)
The subset of Go users who deploy on 32bit hardware in 2018 and care about performance at that level, is likely to be vanishingly small.
Re:Go 2, here we come by LukeShu on Thursday November 29, 2018 @05:32PM (#18564762)
32 bit ARM is still very common.
Re:Go 2, here we come by coldtea on Friday November 30, 2018 @07:36AM (#18568627)
What about Go in 32 bit ARM?
Re:Go 2, here we come by throwaway34241 on Thursday November 29, 2018 @04:16PM (#18564093)
Even if it's OK to degrade the performance of a small minority of users, is there a big benefit to emulating 64 bit ints everywhere on 32 bit hardware? (I'm not saying there isn't a benefit, just that it's not clear to me what it is).

I don't know how many users are still on 32bit. Maybe low power network devices? Older mobile phones (Go isn't usually run on mobile, but it's possible...).

If at some point in the future 32 bit systems become totally irrelevant for Go users, maybe a release of Go could drop support for it altogether and make int an alias for int64, and save people some type casts. 32 bit systems probably aren't at that point yet though.

Re:Go 2, here we come by coldtea on Friday November 30, 2018 @07:37AM (#18568630)
>I don't know how many users are still on 32bit. Maybe low power network devices? Older mobile phones (Go isn't usually run on mobile, but it's possible...).

Well, 16 bit would also be possible if someone took the effort. Perhaps it just shouldn't be encouraged.

Re:Go 2, here we come by throwaway34241 on Friday November 30, 2018 @06:37PM (#18573807)
By 'possible' I meant that it's currently supported by the Go toolchain.