lorenzo

lorenzo

Does my frustration with Node merit switching to Elixir?

Hey everone!

I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any great node framework) and I find I’m wasting a lot of time setting everything up myself: an orm, testing, seeding, typescript, dependency injection etc. I have a basic setup going but it feels brittle. I really don’t know how people can be productive with nodejs. And it’s even worse since I chose to use graphql and most frameworks/docs/tutorials tailor towards REST.

My question is, is it worth switching to Elixir despite having more experience with Javascript/Node? They’re both performant, so my main concern I guess would be productivity. But part of me is thinking “the grass is always greener.” With Elixir I’d have to learn an entire new language and framework. But part of me feels that I’d be easier to learn well since everything fits nicely together.

Other factors:

  • Apollo graphql has done wonders for node.js. It makes a huge framework less necessary, but you still have to figure out how to integrate it with your setup. While absinthe seems to fit nicely with Elixir/Phoenix out of the box.
  • It’s nice to have everything in one monorepo and one language (Javadcript plus typescript). But part of me feels that trying to keep this is causing more headaches than its solving.
  • Deployment with Node.js is a breeze - all it takes is a single command to deploy to zeit’s now. Whereas from what I’ve read deploying Elixir is not as fun.
  • The node.js ecosystem is so fragmented that it’s hard to learn. There isn’t really any great books that guide you through the process since theres so many solutions for everything. Whereas with Elixir, I feel that the path would be more straight-forward. The question is time. I’ve already taken way too much time getting my app going and I feel like I’m running in circles at this point.

Anyway, I’d love to hear any advice or other considerations you may have on this whole backend fiasco, especially if any of you recently switched from Node.js as well.

Thanks!

First 10 of 16 Posts! Switch mode

OvermindDL1

OvermindDL1

Well hey, the Absinthe Elixir library has you covered there!

If you use any of the immutable functional libraries in javascript then you’ve got the ideas of Elixir already down, if not then that will mean learning a bit new of a paradigm.

Elixir is worth learning due to the entire BEAM VM it runs on though, but honestly if your current system runs well and can be maintained without much issue I’d keep it. But if you want to learn a new way, or if you want to be able to scale well, or if you just likely want to shorten your code and improve maintainability then Elixir would be great to use. Just be aware of what you are doing, though porting an existing working project from something else to Elixir is definitely a good way to learn things. :slight_smile:

Yep, Absinthe works with the Apollo client code just fine too!

Never heard of zeit’s, but deploying my elixir server’s is just running a single shell script then bouncing the server via systemd (which I could easily automate too, but haven’t yet because eh… easy enough).

Elixir is exceptionally well documented and has a fantastic community for sure!

But yeah, if your current thing works and you see it doing fine as it is in the future then I’d say just keep at it, only port it over if you want to learn. However if you see pain with it in the future then it may be worth porting to Elixir sooner.

AstonJ

AstonJ

I think many people here will say, yes :003:

If you can spare the cash, I would recommend you get Elixir for Programmers (PragDave) though not to learn Elixir, but to get an insight into why working with Elixir and Phoenix is one of the most exciting ways to develop modern software …Elixir makes so many of the current best practices in development incredibly easy, making it a very natural fit :slight_smile: it will make the hairs on the back of your neck stand up :023:

easco

easco

The one caveat to this is GraphQL subscriptions. The solution that the Absinthe community provides for subscriptions relies on Phoenix Channels as the transport mechanism between a Phoenix server and the client. That means that the GraphQL client must work with the Phoenix Channels transport mechanism and an out-of-the-box Apollo client will use the websocket protocol of the Apollo Server by default.

The Apollo JavaScript client is flexible though, and the Absinthe community has used that flexibility to create a JavaScript Apollo client that handles subscriptions through Phoenix channels (see GitHub - absinthe-graphql/absinthe-socket: Core JavaScript support for Absinthe WS-based operations · GitHub). If you require subscriptions, and want to use the Apollo clients for other platforms (most notably the iOS and Android Apollo clients) they may require additional modification to tie into the transport that Absinthe Phoenix provides by default.

seanc

seanc

I came to Elixir a little more than a year ago from JavaScript and I still share your thoughts here. I spent 30 hours one weekend trying to just research deploying an Elixir/Phoenix application. I’ve asked once on Slack for tips and wasn’t really helped other than a few things like “just do [thing JS devs never deal with]” and it was hard to grok since JS is just so easy to deploy pretty much anywhere. I’ve read a lot of posts here and in every conference talk whenever they mention JS they always make it a joke so I think a lot of Elixir devs just look down on JS in general and haven’t had the pleasure of deploying it :slight_smile:

Ideally I would have liked to keep asking more questions, but I feel like I waste everyone’s time when I ask how to figure out this deployment stuff. I ended setting up an ECS instance for an EC2 cluster, then added an RDS Postgres instance, set up all the security groups and stuff, and put it all behind an Elastic Load Balancer which came with all of its configuration. If anything breaks I’m screwed because I have no idea how it works or how I got it to work in the first place lol.

Anyways, I really hope you find the answer to the deployment story. I’m still looking.

lorenzo

lorenzo

Hmm I wonder how this factors in with cross platform frameworks - e.g. can I still use it for react native or vue-nativescript?

easco

easco

I’m afraid I do not have enough experience with either environment to say. I won’t let that stop me from speculating though. Based on what I do know, the data transport mechanism is generally a very small part of the overall system. Once the data has been squeezed from the server to the client through whatever pipe is used (Apollo’s socket protocol, Phoenix’s channel protocol… whatever) then feeding that data into the top of the React (or presumably Vue) data flow should be fairly straightforward.

OvermindDL1

OvermindDL1

I thought there was an apollo addon library that adds that though?

/me mostly uses graphql on the back-end for as much sense as that makes…

Ah yep that’s it! ^.^

It’s always seemed easy for me? Just release, bind it to systemd, and let it go. Building a new release is just release, copy into the systemd accessed location, and tell systemd to restart it. It’s the same as any other unix style server?

/me is thinking they should make a blog post about systemd deployments sometime…

zimt28

zimt28

I feel the same about deployments. Even though I’ve done it successfully, I don’t think it was that simple. You might want to look into https://nanobox.io/ – they offer a great and simple solution for deploying your apps.

Alternatively have a look at https://gigalixir.com/ or search our deployment tag.

@OvermindDL1 Please write that post :wink:

andre1sk

andre1sk

I think it would be worth mentioning what exactly are you building? Node stuff is “easy” as long as you don’t have to deal with having to offload work to other node processes to keep event loop from blocking. The deployment story is easier for Node but deployment is a kind of thing you setup hopefully once vs development that you have to do every day. As you mentioned Elixir ecosystem is much less fragmented and it is very easy to get going vs Node. The most refreshing thing to me is the ability to write sync code and block in Elixir so it’s much easier to reason about what is going on vs JS/TS. Async/await might look nice but you still better understand what is really happening behind that syntactic sugar. Also on large node projects arch. tends to get vary hairy I am working on large enterprise node app if it was done with Elixir it would literally be 1/4 the size and much easier to understand.

supernova32

supernova32

Regarding deployments, Gigalixir and Heroku are great if you don’t care about the underlying platform. You just push your code and they take care of the rest. (This is pretty much what Zeit Now is, so it is just as easy to deploy Elixir to a hosted service)

In my opinion, doing it yourself is far more satisfying, and allows you to take advantage of the full set of Elixir/Erlang features that come into play once your code is running, like hot code reloading for zero downtime upgrades.

For me the best way to deploy Elixir would be to setup a Digital Ocean droplet, install Elixir, PostgreSQL, and anything else you might need. Then setup edeliver to push your code to the server and run it.

You could also just use Docker to build an image of your project, and Docker Compose to orchestrate the services needed and where to deploy, or build a release manually and use scp to copy it over to the server (provided your local machine and the target machine share the same environment).

It all might sound complicated, but a lot of the steps mentioned above would also have to be performed for Node as well, if you are not deploying to a ready-made PaaS.

Last Post!

akoutmos

akoutmos

Author of Build a Weather Station with Elixir and Nerves

Haha. I had to make the switch for my day job as the tech stack does not include Elixir :'(.

The things you take for granted in Elixir are serious concerns in the Node world. The obvious example being hogging the event loop. Also, while not limited to Node, immutability is something I greatly miss especially in a team environment. You never really know if an object will change out from under you if you pass it around to other functions. If I had to choose between “developer diligence” and “baked in”, I would chose baked in.

Where Next?

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2976 91332 914
New
f0rest8
Hi everyone :waving_hand: Posting here to showcase and announce that Metamorphic is now officially live on a public-facing domain at htt...
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
zachdaniel
Introducing AshStorage! Attachment and file management that slots directly into your resources :smiling_face_with_sunglasses: I had hope...
New

We're in Beta

About us Mission Statement