Why were blocking calls invented when the underlying nature of computers is a state machine? [closed]

Your question makes some pretty substantial assertions / assumptions:

the underlying nature of computers is a state machine?

Well, surely you can model computers as state machines, but that does not in itself mean that such a model represents some fundamental “underlying nature”.

I understand that implementing a state machine is the perfect way to program the computer.

Then by all means, write all your programs as state machines. Good luck.

In real life, some tasks can be conveniently and effectively written as state machines, but there are many for which a state-machine approach would be cumbersome to write and difficult to understand or maintain.

There is no “perfect” way to program a computer. Indeed, it would be pretty pretentious to claim perfection even for a single program.

Since state machines are typically programmed using non-blocking calls,

You don’t say? I think you would need to be a lot more specific about what you mean by this. I have written state-machine based software at times in the past, and I would not characterize any of it as having been implemented using non-blocking calls, nor as exposing a non-blocking external API.

I wonder why blocking calls similar to the Berkeley sockets APIs were invented? Don’t they encourage bad programming practice?

Before we could even consider this question, you would have to define what you mean by “bad programming practice”. From what I can see, however, you are assuming the conclusion:

  • you assert that a state-machine approach to programming is ideal, with the implication that anything else is sub-par.
  • you claim, without support, that only non-blocking calls have state-machine nature
  • you conclude that anything that uses blocking calls must exhibit bad programming practice.

Your conclusion is not consistent with the prevailing opinion and practice of the programming community, to the extent that I can gauge it. Your argument is hollow and unconvincing.

Browse More Popular Posts

Leave a Comment