Skip to content

Comment on Concurrent Programming, with Examplesparent

Comments

Yep Erlang is fairly procedural as a language in a sense. I don't think being functional was ever a priority, more like a side-effect. I don't know how mailboxes and message passing would really work in a purely functional language anyway, could be awkward to work with them. Particularly with a functional (ML or what have you) type system (how to type mailboxes?).

it doesn't help with exploiting more cores.

Yeah you're right, I believe the aim is to get rid of those garbage collection pauses for better concurrency (not parallelism).

From what I understand, GHC can do pre-emptive or cooperative scheduling. Pre-emptive being better for concurrency, just like Erlang does it.

how mailboxes and message passing would really work in a purely functional language anyway, could be awkward to work with them.

It works really well and intuitively I would say, and even more; this is a common application to show the advantages of functional programming. Here is an article comparing sending messages asynchronously between threads in Elixir and Clojure (two common functional languages) https://bentomi.github.io/posts-output/2017-06-04-message-se...

Elixir and Clojure are not pure functional languages at all. They allow you to perform side effects freely, such as sending messages to different threads. They're not reflective of what the actor model would look like when implemented in a more purely functional language.

Moreover, I was mainly referring to using the actor model in a language with a static type system of functional languages (ML). What would be the type of the mailbox? The message? I believe even Facebook (Whatsapp) has struggled to find a solution to this question, they're developing a statically typed language on top of BEAM right now.

There's been plenty of good discussion around implementing a strong static type system around BEAM, here's some bits for reference: https://elixirforum.com/t/how-hard-would-it-be-to-have-a-str...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.