Live data from Hacker News

Chess.com stopped working on 32bit iPads because 2^31 games have been played

chess.com

21–30 of 338 posts

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#21
post #6

were they ever expecting negative number of games? why signed integer?

I read somewhere in the swift documentation that unless you have a specific need for a UInt, that Int is preferred even if you know that the value will always be nonnegative. I think compatibility is one reason they give.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#22
post #14
post #3

How many other examples like this have occurred throughout computing history?

IIRC at least slashdot and twitter had to do some non trivial database migrations because they hit maximum value of some ID field.

Twitter's was called the twitpocalypse and it was a pretty big deal at the time. I don't know how bad it was internally, but it hit a lot of third-party apps that stored tweet IDs in 32-bit integers.

One interesting aspect of it was that Twitter realized what was going to happen in advance, and artificially pushed their IDs over the edge at a preplanned time so they could have as many people available as possible to work on any problems that appeared.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#23

This reminds me YouTube changed its view counter from 32-bit integers to 64-bit integers due to the popularity of 'Gangnam style' https://www.wired.com/2014/12/gangnam-style-youtube-math/

That was a joke; it was always a 64-bit integer.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#25
post #6

were they ever expecting negative number of games? why signed integer?

You need to first establish that the type was chosen intentionally before asking why it was intentionally chosen. Otherwise the question is ill-formed.

It looks like they are using PHP/MySQL/Javascript/Flash, with only MySQL having any explicit types.

Even so, an error is often preferable to overflow, which is usually undefined behavior and could lead to a duplicate primary key anyways if it wraps to the first game.

A better question is "why 32-bit over 64-bit", but the site dates back to 2005 where that was the norm and the question has the same issues.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#26
post #13
post #6

were they ever expecting negative number of games? why signed integer?

Because signed is default for some reason in most languages, and most developers aren't taught to think critically about how decisions like simple datatypes might affect scalability.

The problem is momentum. I could use unsigned int everywhere, but then I have to constantly typecast to int and back anywhere I use a library expecting signed ints. If we all switched to unsigned int by default, then everything would make more sense but we'll all live in typecasting hell during the migration.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#27
post #6

were they ever expecting negative number of games? why signed integer?

Compilers can optimize for signed integers better. Overflow/underflow on signed integers is undefined behavior, which is space for compilers to optimize. But unsigned ints are defined for all cases, so you get less optimal code.

Also, you have problems whenever you compare against signed ints.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#28

It's fascinating... the Y2K problem never came to fruition because - arguably - of the immense effort put in behind the scenes by people who understood what might have happened if they hadn't. The end result has been that the entire class of problems is overlooked, because people see it as having been a fuss over nothing. I sometimes think it would've been better if a few things had visibly failed in January 2000.

My long-term active retirement plan involves building a year-2038 consultancy.
Post reply on HN