3 ms·
For those coming into this that aren't of an Elixir background, here's some of the things that make BEAM (Erlang VM that Elixir is built on) interesting for sof
by sb8244 5y ago
For those coming into this that aren't of an Elixir background, here's some of the things that make BEAM (Erlang VM that Elixir is built on) interesting for soft real-time features:
* BEAM provides out-of-the-box capability to network nodes together. This is extremely important in real-time flows because server A may originate a message that needs to get pushed to a user connected to server B + C (2 tabs open). The capability to both connect + send messages between nodes is built in.
* The process model in the BEAM provides a really natural fit for WebSocket connections. Each connection is its own process, and other processes are spawned off of that for various needs. The benefit here is that a failure in one process (connection drop, code error, crash, etc) won't affect other users. It's not an issue of whether the code is written well to prevent it, it's just intrinsic to the runtime. State is also stored per-process, which is convenient when it comes to writing your application.
Phoenix itself has a really nice abstraction over WebSockets (Channels, which this post goes in depth on). I won't say too much since the article does, but it's just really enjoyable to work with. Also, Phoenix LiveView is built on channels, so knowing channels provides some benefit there.
If it's interesting to you, I wrote a book that basically walks you through "I don't know anything about Elixir" to building a demo "sneaker drop" store https://pragprog.com/titles/sbsockets/real-time-phoenix/ https://pragprog.com/titles/sbsockets/real-time-phoenix/
- aloukissas 5y ago+1 for the RT Phoenix book!
- stingraycharles 5y ago> BEAM provides out-of-the-box capability to network nodes together. It’s been half a decade since I last did Erlang, but wasn’t BEAM the Erlang VM and OTP the library that makes the networking possible?
- sb8244 5y agoYes, that's a fair point. I should have written BEAM/OTP because they're separate things. BEAM enables the process model, but the implementation of things like networking is in OTP. I'm not sure how far deep the actual process implementation goes, (is it in BEAM or OTP?) I think it's BEAM but I could be wrong. I'm not really going that low in the stack.
- syspec 5y agoGreat book! +1