Douglas Crockford discovered JSON and he also wrote a reference implementation for JSON in Java. One of the great stories I heard him share was on Hanselminutes episode 396: He was contacted by some developers that were getting syntax errors while parsing JSON using his reference implementation. It turned out that they were transferring JSON documents more than 2GB in size but the Java implementation was using a 32 bit integer to keep track if the number of characters in the JSON document. The maximum value of a 32 bit
int in Java is:
2^31-1 = 2.147.483.647 ~ 2 billion = 2G
So because 2GB of data has a higher number of characters than can be stored in a 32 bit integer, that was obviously a problem. As Douglas Crockford says in the podcast, he had no idea that anyone would ever use JSON to store so much data yet it happened anyway and all of a sudden it was actually a bug.
Historical design decisions and their consequences for modern day computing are very interesting and I recommend listening to the entire Hanselminutes show through the link above. I just wanted to share a recent example of the same kind of problem. Here is a screenshot from the landing page for Rocksmith (a guitar hero kind of game but with a real guitar):
The interesting part of this screenshot is the highest arcade score. It is exactly the maximum value of an
int (2.147.483.647). I do not think it is a coincidence. I think the Rocksmith developers simply did not think that anyone would ever get more than 2 billion points in the arcade game and it was probably a fair guess. I could be wrong of course, but it is still a good reminder that even small decisions like choosing a datatype to keep track of a score has consequences for the software we produce.