by lll-o-lll · 3y ago · 0 comments
The example of C as the de facto cross-language standard (it’s not just in Linux), is also interesting. Creating a C interface imposes on a library author a set of restrictions in expression, but is anything truely lost in doing this?
I am much more interested in the concepts/ideas being expressed than I am the language being used to express it.
E.g. beautiful Rust wrapper -> “Ugly C interface” -> “Ugly C interop layer” -> beautiful Go library
I mean, it’s a pain to maintain “ugly C interop”, but as these tend to be built after the fact anyway, other than cost I don’t see anything lost.
Much like with human translations of poetry. A good translation is not word for word, the translator captures the essence and re-expresses it in the other language. When done well, it is frankly a work of genius.
So the C interface is just a medium a “translation dictionary” if you will. To do it well requires the author of the wrapper to express the ideas in a form palatable to users of the other language. I get that this is not always done well, requires a bunch of work, and may raise the question “why not re-write?”. I’m happy to consider better alternatives.
The thing about Erlang behaviors is that they rely on several other pieces of Erlang to work well.
One big one is being able to be notified when another process goes down, or is aborted.
The other big one is being able to reason about state in the face of such failure.
Erlang decided to go with immutable data structures, shared nothing processes, and the OTP behaviors generally expect you to decompose the behavior of the various bits into functions that represent a single atomic step.
The more of those properties that you don't share with Erlang, the harder it will be to adopt OTP style semantics in your system.
In Erlang, a sync API behavior can safely have a failable async implementation, and that is powerful