Email or username:

Password:

Forgot your password?
witch hat hacker 🎃 spooky ver

things in programming that seem easy but are actually hard

- measuring the elapsed time between 2 events
- doing something at least once
- checking if 2 pieces of text are equal

4 comments
witch hat hacker 🎃 spooky ver

- it's really easy to use a non-monotonic clock. even supposedly monotonic clocks are sometimes not
- crashes
- unicode sucks lol

witch hat hacker 🎃 spooky ver

doing something exactly once is basically impossible
better to do it at least once and make the thing support being run more than once (idempotency)

witch hat hacker 🎃 spooky ver

a basic strategy (write-ahead-logging) is

- write to disk that you're going to do thing A with parameters B -- ensure this itself is fault tolerant eg with sqlite
- once the log is committed, you can safely return to the caller. don't return before then
- do the thing A with B
- report results
- remove the log entry

finally, on program startup, go through the current log and do everything in it

a basic strategy (write-ahead-logging) is

- write to disk that you're going to do thing A with parameters B -- ensure this itself is fault tolerant eg with sqlite
- once the log is committed, you can safely return to the caller. don't return before then
- do the thing A with B
- report results
- remove the log entry

Hey-da

@haskal in practice oftentimes one can skip the last step of removing the log entry and use a stack of a certain upper bound for the log, then go through and ensure they've all been committed the next time it is mounted.

Go Up