Is your program a function or a service?

January 04, 2021 [Programming, Tech]

Maybe everyone knows this already, but for my own clarity, I think there are really two types of computer program:

How functions work

Programs that are essentially functions should:

*The Halting Problem shows that you can't prove they stop, so I won't ask you to do that.

Writing functions is relatively easy.

How services work

Programs that are services should:

Writing services seems a little harder than writing functions.

What about UIs?

I suggest that programs with UIs are just a special case of services. Do you agree?

What about let-it-crash?

I think that let-it-crash is a good way to build services, but when you build a service that way, I consider the whole system to be the real service: this means the code we are writing, plus the runtime. In this case, the runtime is responsible for keeping the service running (by restarting it), and telling the user about problems.

In effect, let-it-crash allows us to write programs that look like functions (which I claim is easier), and still have them behave like services, because the runtime does the extra work for us. Erlang seems like a good example of this.

What are the implications?

If you are writing a service, your program should start when asked, and keep running until it is asked to stop, even if things are bad.

For example:

Why not stop when things are wrong?

What are the down sides?

More: 12 Fractured Apps