DEV Community

Mike Rispoli
Mike Rispoli

Posted on

Elixir Phoenix vs. Serverless Node

So this is not another comparison post, I've read enough of those to understand the basic differences between these two. This is basically an open discussion for anyone familiar with both of these technologies.

But first, why write anything other than javascript if you are a web engineer? I know this sounds super naive on it's face but after writing javascript for nearly a decade it's very hard to justify building new projects with all the pain that comes from fumbling through an unfamiliar language. Most of the time, I'm more excited by the idea itself than the technology I'm going to use, so having a half completed project in elixir is more heartbreaking than a complete one in javascript.

But alas I think I'm getting tired of being fluent in one language and have an idea that can benefit from something else. I've also grown frustrated with a few things in javascript over the years.

  1. No type safety
  2. a single error can just tank the entire system
  3. Runs hot on memory
  4. Not great at concurrency

Here's where elixir phoenix comes in.

  1. Functional/immutable patterns deal with type safety
  2. Resilience, errors kill a process without taking down the entire app
  3. Runs lighter on memory
  4. A beast at concurrent tasks

But of course I've not yet dove in and while the setup was easy, I know there is much pain to come on this route.

So here's my javascript angel on my shoulder saying just come back to what you know.

  1. Typescript gives you back type safety
  2. If you use typescript in strict mode you should avoid most common errors
  3. You can go serverless here and use lambda functions to mitigate the issues of the old node monolith and memory problems.
  4. Serverless functions effectively spin up a new process for each call so really you would get the advantages of elixir phoenix concurrency.

Here's where you come in. Have you built apps in both of these types of setups? Am I correct in thinking there isn't much difference in the load a serverless node setup and elixir can handle? Anyone test any of these? And lastly but more generally, how do you resist the urge to just fall back on good ol' javascript when the learning gets tough?

Top comments (2)

Collapse
 
mrispoli24 profile image
Mike Rispoli

Alright, so I took a bit of time to setup a sample Phoenix app and build out basic authentication and setup an Elm frontend just to push things a bit more. I found the setup itself relatively easy, and the microseconds service time is indeed true and as advertised. That being said, despite it's comparison to Ruby and Rails, I have not found Elixir and Phoenix very easy to grok. While Phoenix resembles rails in many ways, I did not find Elixir to be the easiest thing to just fumble around in for a while the way Ruby lends itself so nicely to.

So that being said, how do you resist the urge to fall back on what you know? I didn't I'm going to be moving forward with node since I have less time than I would like to make this project. When it comes to Elixir I will need to have some time to sit down and really learn the language for this one. Some languages lend themselves well to learning as you go, like Ruby, but Elixir development without understanding the fundamentals was moving painfully slow for me.

One other strike against Elixir that I found in my research was that the deployment and hosting of Elixir apps can be notoriously painful. This scared me quite a bit as I find nothing more frustrating that building an entire app locally and then needing to spend two or more hours working out a deployment pipeline.

In the end the problem of dealing with millions of concurrent connections is a problem I do not have at a projects outset. And at the point that my application reaches this need I'm probably going to be a very happy camper and be able to get some help scaling things up. Too many users is a good problem to have, and can be planned for at a later time. Best not to outrun your headlights. That and there are many many examples of software built in Node that scales just fine.

So I was happy for this little experiment and look forward to studying up on some Elixir on the side and possibly taking on a bigger Elixir project at a later date when I have more time. At the very least I find when you study a new language you can take that new style and apply them to your crafting of javascript.

Collapse
 
fractal profile image
Fractal

I appreciated this write-up, as I've been contemplating the same thing!