←back to thread

setBigTimeout

(evanhahn.com)
210 points cfj | 8 comments | | HN request time: 0.001s | source | bottom
Show context
yesco ◴[] No.41881325[source]
> In most JavaScript runtimes, this duration is represented as a 32-bit signed integer

I thought all numbers in JavaScript were basically some variation of double precision floating points, if so, why is setTimeout limited to a smaller 32bit signed integer?

If this is true, then if I pass something like "0.5", does it round the number when casting it to an integer? Or does it execute the callback after half a millisecond like you would expect it would?

replies(3): >>41881670 #>>41881685 #>>41884172 #
1. arp242 ◴[] No.41881670[source]
You're correct about JS numbers. It works like this presumably because the implementation is written in C++ or the like and uses an int32 for this, because "25 days ought to be enough for everyone".
replies(1): >>41882076 #
2. drdaeman ◴[] No.41882076[source]
I thought most non-abandoned C/C++ projects have long switched to time_t or similar. 2038 is not that far in the future.
replies(4): >>41883127 #>>41884022 #>>41884079 #>>41884616 #
3. andrewmcwatters ◴[] No.41883127[source]
2038 is even "now" if you're calculating futures.
4. bobmcnamara ◴[] No.41884022[source]
Debian conversion should be done mid2025.
5. afavour ◴[] No.41884079[source]
Yes but JS always has backwards compatibility in mind, even if it wasn’t in the spec. Wouldn’t be surprised if more modern implementations still add an arbitrary restriction.
6. asveikau ◴[] No.41884616[source]
There's a shocking amount of systems that still have 32 bit time_t.

Linux and glibc only started supporting it on 32bit systems in the current decade.

replies(1): >>41885509 #
7. kelnos ◴[] No.41885509{3}[source]
I mean, we still have 14 years to go. It's not like it's 1999 and everyone is freaking out about y2k. We still have plenty of time.

That doesn't mean it's fine to wait and leave it until the last minute, but we have quite a few last minutes left at this point.

replies(1): >>41886750 #
8. lloeki ◴[] No.41886750{4}[source]
> we have quite a few last minutes left at this point.

    C’est l’histoire d’un homme qui tombe d’un immeuble de 50 étages.

    Le mec, au fur et à mesure de sa chute, il se répète sans cesse pour se rassurer:
    
    "Jusqu’ici tout va bien."
    "Jusqu’ici tout va bien."
    "Jusqu’ici tout va bien..."

    Mais l’important c’est pas la chute, c’est l’atterrissage.
Tx'd:

    There's this story of a man falling off a 50 floor building. Along his fall the guy repeats to himself in comfort:

    "So far, so good"
    "So far, so good"
    "So far, so good..."

    What matters though is not the fall, but the landing.
- Hubert, in La Haine (1995), Mathieu Kassovitz

https://youtube.com/watch?v=U-v6QVlpReU