150 points by elixir_gamer 6 months ago flag hide 14 comments
john_doe 6 months ago next
Great tutorial! I've been looking for something to help me get started with building multiplayer games in Elixir.
elixir_expert 6 months ago next
I'm glad you found it helpful, @john_doe! Would you like any specific assistance with your project?
functional_thinker 6 months ago prev next
I've just started working with Elixir and this tutorial looks interesting. I'm not sure about the real-time aspect, but I think I can manage basic game mechanics using this method. Do you have any recommendations on real-time libraries for Elixir?
elixir_player 6 months ago next
@functional_thinker, have you tried using Channels from Elixir's Phoenix Framework? That should help you with real-time scenarios.
functional_thinker 6 months ago next
@elixir_player, I'll look into that, thank you!
another_user 6 months ago prev next
This looks amazing! I'd like to know more about how to keep game state updated between multiple players. Anyone know how to do this?
game_developer 6 months ago next
@another_user, there are several ways to do it depending on the architecture you choose. I'd recommend using an Agent to keep track of the game state in your backend and using Channels to push updates to the game UI.
new_programmer 6 months ago prev next
Does Elixir support multicore and will that be useful in this scenario?
concurrency_guru 6 months ago next
@new_programmer, Elixir utilizes the Erlang VM that provides a lightweight concurrency model with isolated processes. These processes have their own memory and run independently, which is useful for real-time multiplayer game development.
new_programmer 6 months ago next
@concurrency_guru, thanks for explaining, now I understand. Will this be enough to handle high concurrency in my real-time multiplayer game?
super_programmer 6 months ago next
@new_programmer, you can easily handle high concurrency using Elixir. For example, WhatsApp uses Erlang/OTP, the virtual machine behind Elixir for handling 50+ million clients concurrently.
performance_enthusiast 6 months ago prev next
Interested to know the performance differences between Elixir and Node.js for this scenario? Can anyone help with any benchmarks or testing?
scalability_expert 6 months ago next
@performance_enthusiast, Elixir runs on the Erlang VM, which was built for scenarios that require high performance and supervision of processes. It's generally better at handling high concurrency than Node.js due to its message passing architecture and lightweight processes.
node_guru 6 months ago prev next
@performance_enthusiast, Node.js can also handle real-time multiplayer games efficiently. But you'll have to use specific libraries and architectures, like WebSockets and Cluster, to maximize the performance potential. In general, Erlang/OTP and Elixir are very good and highly performing, but Node.js can be an efficient alternative depending on the use case.