I'm excited to share a new actor system we've been building for Swift's distributed actors: swift-erlang-actor-system. This actor system enables Swift programs to join a distributed Erlang cluster. Here's an example of a simple chat program using the actor system: Demo Video Erlang (and other languages that run on its VM) can connect multiple runtime systems together with distributed Erlang. Each runtime is referred to as a "node". Erlang also supports "C nodes", which allow a program other than the Erlang runtime system to communicate with Erlang nodes and other C nodes. We've wrapped this C node functionality into an actor system that can be used with Swift's distributed actors. Here's how you can try it out: Getting Started Install Elixir following their instructions. For example, on macOS you can install with Homebrew: brew install elixir Start epmd, the "Erlang Port Mapper Daemon". This is how Erlang nodes discover each other by name, instead of IP and port: epmd Start an interactive Elixir node and get the cookie and hostname: iex --sname elixir_node iex(elixir_node@YOUR_HOSTNAME)> Node.get_cookie() :YOUR_COOKIE Create a Swift package with a dependency on otp-interop/swift-erlang-actor-system, and setup a node and distributed actor: import ErlangActorSystem import Distributed // 1. Declare a distributed actor @StableNames distributed actor Counter { typealias ActorSystem = ErlangActorSystem private(set) var count: Int = 0 @StableName("increment") distributed func increment() { count += 1 print(count) } @StableName("decrement") distributed func decrement() { count -= 1 print(count) } } // 2. Create a node let actorSystem = try await ErlangActorSystem(name: "swift_node", cookie: "LJTPNYYQIOIRKYDCWCQH") // 3. Connect to another node try await actorSystem.connect(to: "elixir_node@DCKYRD-NMXCKatri") // 4. Create an instance of a distributed actor using the ErlangActorSystem. let counter = Counter(actorSystem: actorSystem) // 5. Give the actor a name so we can find ...
First seen: 2025-07-22 19:51
Last seen: 2025-07-23 13:54