logoalt Hacker News

lexicalityyesterday at 7:12 PM3 repliesview on HN

> This makes it possible to write simple code that’s both concurrent and safe.

Yeah, great, my hello world program is deterministic.

What happens when you introduce I/O? Is every network call deterministic? Can you depend on reading a file taking the same amount of time and being woken up by the scheduler in the same order every time?


Replies

PufPufPufyesterday at 7:33 PM

This is about durable execution -- being able to resume execution "from the middle", which is often done by executing from the beginning but skipping external calls. Second time around, the I/O is exactly replayed from stored values, and the "deterministic" part only refers to the async scheduler which behaves the same as long as the results are the same.

Coincidentally I have been experimenting with something very similar in JavaScript in the past and there the scheduler also has the same property.

TeMPOraLyesterday at 9:12 PM

No, but determinism reduces the number of stones you need to turn over when debugging hairy problems such as your program occasionally returning different results for the same inputs. You may not have control over the timing of I/O operations or order of external events (including OS scheduler), but at least you know that your side of the innovation/response is, in isoaltion, behaving predictably.

KraftyOneyesterday at 7:22 PM

That's the cool thing about this behavior--it doesn't matter how complex your program is, your async functions start in the same order they're called (though after that, they may interleave and finish in any order).

show 1 reply