I just received a bug report on JSONTokener.java. It was failing to parse texts that were longer than 2GB in length because had I declared an index variable to be an int instead of a long. The bug occurred because it never occurred to me that a text could be that large. At the time I wrote that code, 2GB was a good size for a disk drive. We now have cheap machines with RAM that is much larger.

It took over a decade before someone stumbled over this bug. Ultimately, it occurred because I had a choice of several number types, and I chose the wrong one.

When we were programming Z80s, it made sense to have an assortment of int sizes because RAM was so incredibly rare. We very carefully invested as few bits as possible into each variable. That kind of economy makes no sense today, but most of our languages today still invite that mistake.
Shared publiclyView activity