3 ms·
The requirements for time in computers have increased drastically since C was invented. Time used to mean what we write down or see on a clock: 2024-08-13 02:2
by immibis 2y ago
The requirements for time in computers have increased drastically since C was invented.
Time used to mean what we write down or see on a clock: 2024-08-13 02:27 PM. The computer had an electronic clock built in, so it could save you a little effort of looking at the clock and copying the numbers. And that was all it did. If your clock was a few minutes off, that was no big deal. People knew clocks only agreed to within one or two minutes. People knew clocks were different in far away lands. Some people knew that you have to adjust your clocks twice per year. The computer clock was just like any other clock but happened to be inside a computer.
Now we expect a globally synchronized unique identifier for each instant, regardless of timezone. This is hard to deliver. Computers use these for synchronization amongst themselves, so they have to be accurate to milliseconds or better. This is hard to deliver. We expect computers to handle requests from far away lands with as much grace as requests from the local operator, and deliver results in a format the people in those lands expect. This is hard to deliver. We expect computers to process requests about the past using information that was current in the past, all over the world. This is hard to deliver. We expect computers to automatically adjust their own clocks twice a year, not just on the dates everyone in your local area does, but for users in all parts of the world on their respective dates. This is hard to deliver. And we still haven't got graceful handling of completely different calendar systems.
- Gibbon1 2y agoInteresting thing about hardware real time clocks. They are usually as bad as the C time API. I worked with a guy that designed three RTC clock cards for an industrial bus system The first had registers for hours minutes, seconds, day, month, year. He was proud it handed the leap years correctly. It had a battery back up. The second design just had a 48 bit counter that counted ticks. You could read and and write it using latches so the read/writes were atomic. The third design was a read only 48 bit counter and a 1024 bit battery back ram. In the second and third design the conversion from time to a string is done in software. In the third the clock just provides a free running timer and you store an offset in battery backed ram along with other time related meta data. The vast majority of hardware RTC clocks today are implemented like the first example. It's a little infuriating since my coworker figured out how to do it right 45 years ago.
- immibis 2y agoIndeed, the first was obviously designed as "make a clock but digital" and the second was designed as "create a unique identifier for each instant" and the last was "also make it as stateless as possible"