Hacker News new | ask | show | jobs
by peter_d_sherman 1245 days ago
>"The next interesting behavior is supervisor. Supervisors are processes which sole job is to make sure that other processes are healthy and doing their job. If a supervised process fails then the supervisor can restart it according to some predefined strategy."

This is an interesting software pattern -- especially applied to having it entirely supported entirely inside of one programming language... We see this software pattern in such things as Windows Services (they restart automatically if they fail), Unix/Linux daemons, as one of the original purposes of the original Unix 'init' process, and in high-availability, mission-critical 24/7 systems (databases, etc.).

Having all of that fault-tolerant infrastructure entirely inside of a programming language is indeed, somewhat novel.

But let's work up what a given language must have as prerequisites to support this...

First, we need the ability to run multiple processes inside of a language. Many languages can accomplish this with threads, but of the languages that do this, many need additional cumbersome programming to guarantee thread safety...

So the language needs to support the notion of a threaded process inside of that code -- without having to code extra to support this threaded process.

Next, the language needs some form of communication between supervisor (process A) and supervised (process B) code. Message passing is the solution -- but that requires each process to have its own message queue.

And message passing requires interfaces...

Here we're starting to sound like we're duplicating a mini Operating System inside a language(!) (should the language have pipes, too?) -- and/or that the complexity of most OS's would be deeply mitigated by designing them inside of a language that supported these constructs...

Whatever the case, I think it's a fascinating software pattern.

Yes, Go exists and supports features like this, Rust exists, and people are using it to write Operating Systems. And there are probably all other kinds of languages (both existing and existing in the future) that do/will support some form of these constructs...

But there's another interesting, purely academic, purely theoretical question here...

That is: What is the simplest full-featured OS (processes, IPC, synchronization primitives, memory management, hardware resource management, syscalls, scheduling, etc.) that could be written in the smallest amount of lines of code if the language it was written in had intrinsic knowledge of all of those underlying constructs?

Anyway, a fascinating article about Erlang, and it definitely gave the impression that Erlang was a whole lot more than I thought it was... I will be checking out Erlang for future projects!

1 comments

>Here we're starting to sound like we're duplicating a mini Operating System inside a language

In case you didn't know, Joe Armstrong actually calls Erlang/OTP an "Application Operating System(AOS)" in his thesis paper.

That is the entire point of that language's design.

I did not know that! Interesting! I will have to check out Joe Armstrong's paper...
The discussion in this thread is actually missing the forest for the trees and probably giving a wrong impression of Erlang for people new to it.

Erlang is always spelled as Erlang/OTP (i.e. language/patterns of components provided in libraries) + Erlang Run Time System(ERTS) (the BEAM VM + support components). The whole "System" is what makes it so powerful and uniform with a single environment. Every single "feature" exists only in the context of the whole and cannot be discussed in isolation (See https://blog.stenmans.org/theBeamBook/#_layers_in_the_execut... for a graphic).

Compared to the babel/hodge-podge of languages/tools/frameworks used to duct-tape current-day distributed apps, Erlang/OTP is a godsend. It is purely an accident of fate that it never became mainstream for distributed Web programming for which it is eminently suited for. Imagine Erlang running in the Browser frontend and also on the Server backend. Everything would be uniform and clean and one would have a robust distributed system with all parameters taken care of by the "System" itself; we would just need to focus on the "business logic" and be done with "app development".

>Imagine Erlang running in the Browser frontend and also on the Server backend. Everything would be uniform and clean and one would have a robust distributed system with all parameters taken care of by the "System" itself; [...]

That is a very compelling idea -- the idea of a language which supports concurrency natively -- such that a given source code base could be split up into "client" (web browser) and "server" (web server) components (and/or source code) easily, ideally automatically...

I think that is a very compelling idea, indeed!

This language might indeed be Erlang/OTP + Erlang(ERTS) + BEAM VM -- but it could conceivably be another language -- if that language was designed with the appropriate concurrency in mind: (https://en.wikipedia.org/wiki/List_of_concurrent_and_paralle...)

But that being said, Erlang/OTP+ERTS+BEAM VM -- definitely looks like it is worth further exploration!