Elixir/Phoenix for building a real-time browser chat app?

Hello, I am an entrepreneur and novice web developer.
I am building a real-time one-on-one browser chat app with similarities
to Omegle but with database functionality as well.

Initially I thought of building the back-end on Python, but then I heard
of Elixir, and being the contrarian that I am, it caught my interest immediately.

Unfortunately since I am such a beginner in webdev I am still not smart
enough to know if an app like mine would benefit from being implemented in Elixir +
Phoenix instead of say something like Python and Flask, so I was hoping to get your advice on this.

So if you don’t know about Omegle, the way it works is it’s a random
chat app, there’s no search at all, all you do is request to chat and it connects
you with a random person. A couple hundred thousand chats occur at any given time.
It’s mostly I/O bound by network operations.

So I am curious if Elixir/Phoenix will be a good platform for building this app or if it is overkill. Additionally it’s also important for me that the languages used for building are fairly expressive and can achieve results with less code.

Thanks.

2 Likes

Hello @alice and welcome!
My 2 cents: you can build such an application almost out of the box with Phoenix, implementing channels and an Ecto repo for the persistence layer on a DB. Just start hacking a proof of concept to see it with you eyes! It won’t take much, have fun!

P.S. Phoenix generators are your best friends to start with, follow the official tutorial. You’ll get plenty of answers to your future questions in this forum, and from much more skilled people than me!

P.S.2 I find hard to find a language more clear, explicit and expressive than Elixir.

2 Likes

Elixir/Phoenix will do an awesome job, to give you a head start I recommend Real-Time Phoenix by @sb8244

3 Likes

There are some great tutorials too. e.g. https://elixircasts.io/multiple-room-chat-application - this doesn’t use LiveView which would make it even more straightforward as you wouldn’t need to code any javascript to build the front end.

2 Likes

WhatsApp is built with Erlang and Elixir compiles to Erlang and uses same ecosystem OTP (Open Telecom Platform) and virtual machine BEAM. Discord is built with Elixir with some Rust sprinkled in. Discord Blog

So yes Elixir is very suited for building chat apps. I don’t think Discord uses Phoenix but I don’t see why it wouldn’t work great. I don’t think using Elixir is overkill at all. I’m C# programmer by profession and I’m no Elixir professional and only use it in my hobby projects, but I do feel more productive using Elixir than using C#. I also feel that Elixir code is lot more readable than C# and I think that is very important for a big project.

3 Likes

As written above. This is the easiest platform to get started with regarding this subject and there are tons of resources on the web now for chats apps.

The only downside to Phoenix compared to other frameworks is that you’ll have to build a lot of things yourself – or, if you don’t build them, you will definitely have to properly assemble the already-built pieces together.

F.ex. Rails and Flask have ready-made authentication solutions that you more or less simply include in your project, while Elixir’s Pow library you have to specifically install inside your app and configure here and there. And it allows a lot of customisability.

Elixir and Phoenix are amazing and I never regretted learning both. They made me much more productive than when I worked with Rails and Java before that.

But there are people who expect everything to just work out of the box with minimal effort from their side. Those people usually get disappointed by Phoenix.

3 Likes

I chose Elixir / Phoenix specifically because of the chat app type features you get out of the box (Phoenix Channels).

I was previously a non-technical founder of a software company that I sold recently. Last year I decided to learn Elixir and am building Logflare. In a couple months I was able to have an MVP, and based on the response of that I have continued to invest in it.

I’ve found everything surprisingly straightforward, and more than that the community is very willing to help!

4 Likes

I don’t disagree. I am just saying that there are drop-in libraries that you put inside your project and you get authentication with almost zero effort. While in Phoenix you actually have to work on that – Pow generates files inside your project and you can then further edit/refine them.

That’s what I meant.

Sorry wasn’t specifically replying to you (I always accidentally hit that reply button).

There are definitely less drop in libraries for things, but a lot of times I find that I either spend my time a) learning the library and implementing it or b) writing something myself. And yes, the thing I write is no where near as “complete” as the library usually but good enough for my need at the time and I understand it fully vs partially (initially) understanding the library. But this is another debate entirely!

1 Like

Sorry, didn’t mean to look like I am on your neck. :heart:

1 Like

Thanks guys,
I will give Elixir, Phoenix and Ecto a go!
I read that Elixir was optimized for concurrency which from what I understand mostly has to do with CPU-bound apps, where mine is I/O bound so that’s why I was wondering if it was an overkill.

1 Like

Elixir actually benefits more from I/O concurrency than CPU concurrency (although it benefits from being able to use all of your cores effectively). You’re not going to run into CPU issues from normal operations, but it’s not considered a “number crunching” language.

So, it sounds like you’ll be in good hands with Elixir.

4 Likes

Erlang and Elixir’s runtime – the BEAM VM – is optimized for all kinds of parallelism and concurrency. It fairly distributes load and none of your tasks should lag.

And as you have been told, I/O benefits the most from that.

1 Like