Does mac restart work reliably with restoring open applications and restoring states in every case?

Solution 1:

In practice you can't rely on it.

The hooks are there in the OS to allow perfect restoration but each app has to be written to keep track of its changes and most aren't. Often that is the correct design decision as it allow the app to start in a controlled state rather than work out all the possible changes.

If you want the same state don't log out just put the machine to sleep.

Solution 2:

No. It will lose or potentially corrupt some state. It seems to depend a lot on which applications are open. Sublime Text is great about managing its state, but XCode is not just to offer 2 examples. I do not know of many bugs about this (here's one, warning: language).