DEV Community

Discussion on: Simplify code by promisifying `setTimeout`

darkwiiplayer profile image

I've used more timers less than 1 second or timeouts like 1.5 seconds

What's the problem with sleep(1.5)? I still find that more natural than sleep(1500)

Plus its so standard

No it's not. C uses seconds, the linux command-line program sleep also uses seconds... There's lots of examples out there and milliseconds is far from common.

The only two differences are:

  1. Seconds are the SI base unit.
  2. Seconds are within the orders of magnitude that humans can perceive.

I'd say both of those are clearly benefits of using seconds.

Thread Thread
puruvj profile image
PuruVJ Author

Well, you have a point.

However having seconds measurement in a language that puts milliseconds as first class citizens would incur the cost of context switching.

Thanks for the info

Thread Thread
darkwiiplayer profile image

The context switching is precisely why I want this. If you're dealing with seconds in the backend but have to constantly switch to thinking in milliseconds for the frontend code, that's mental work I could spend thinking about the actual code.