6 ms·
Using Node.js again instead of my usual Elixir and all I can think is "Y'all live like this?". I feel for anyone using a Node.js backend. Y'all really don't kn
by hmmokidk 3y ago
Using Node.js again instead of my usual Elixir and all I can think is "Y'all live like this?".
I feel for anyone using a Node.js backend. Y'all really don't know what you're missing.
Also dealing with bugs is infinitely harder. Try catch is infinitely more wordy and messy. And you lose out on so so many valuable CI steps the Elixir community has from sobelow to credo.
And then there's writing tests. In the Node.js community it is an actual joke. It is so hard to write tests and I have yet to see any framework create a nice sandboxed test environment that just works.
All of this stuff in Elixir is free.
And like someone else said, the best ORM is Ecto and it's hard to disagree with that.
Making a reliable and organized Node.js application is actually so difficult.
If my pet project was in Node.js I would not even be able to accomplish it. And that's a fact. Elixir makes me so much more productive and the code I write is so much less buggy and less complex.
I love that HN loves Elixir. If only it was more common in the workplace.
- izelnakri 3y agoI so far agree with all you said and strong think already based on limited info available to me that you are a well-versed Elixir dev. However nothing beats the short term dev speed of scripting up some JS with npm. Have you seen the latest test runner efforts on node.js and advancements in deno? I think this gap is slowly closing but node is still not near Elixir in terms of long-term productivity, in future it will take over though I think if types dont get into the Elixir language fast.
- hmmokidk 3y agoI have to transpile my scripts if I want to copy-paste which I often need to do. And there's no repl if you're using transpiled code. I have tried using `ts-node` but that didn't work. In Elixir this stuff just works. Maybe there's some tooling I am missing out on with Node.js. I am not familiar with Deno.
- revskill 3y agoUse a real NodeJS framework then. Also nowadays it's Typescript tooling that gave superpower to NodeJS backend.
- Vaguely2178 3y agoWere you using Typescript with Node? I really can't imagine working on a project that's even moderately complex without static typing. Having a static type checker is like having an assistant that writes automated tests on its own, and having those tests constantly running in the background. Refactoring code without static type checking is a nightmare. If you're using a strict statically typed ORM like Prisma [1], you can change your data model then run tsc --noEmit --watch in your terminal and the compiler notifies you of every error with their associated file names and line numbers. In VSCode you can even click the line number and it'll open the specific file where the error occurred. Before adopting Typescript, I basically never attempted large refactors, and when I did it consisted of a long process of grepping for specific symbols in the project, and manually writing lots of tedious and verbose tests to do a fraction of what the compiler does automatically. I remember developers from the Elm community years ago constantly advocating for static typing, and thinking "this has to be hyperbolic". Richard Feldman gave a talk about how he wrote code on an airplane for hours without an internet connection, and without actually running the code, and how the compiler ensured that the code just worked [2]. Typescript is not as sound as a Hindler-Milney type system, but the benefits are similar (especially if you're running Typescript in strict mode). [1] https://www.prisma.io/ https://www.prisma.io/ [2] https://youtu.be/sKxEwjKQ5zg?t=384 https://youtu.be/sKxEwjKQ5zg?t=384
- Kamq 3y agoIt's unlikely that the typing is their grief is around static typing, since the language they're comparing node to (elixir) is dynamically typed.
- Vaguely2178 3y agoI'm not saying the lack of static typing is their grief, I'm saying it should be their grief.
- Vaguely2178 3y agoOr in other words, the presence of a static typing ecosystem is one of the advantages Node has over Elixir. So while the original commenter might not care that Elixir lacks static typing, they should care because it increases productivity.
- POiNTx 3y agoAgree with all you said, except for the ORM part. Ecto is good but I think the Django ORM does it better. The ORM in Django[0] is dead simple and easy to understand. The only caveat being that Django doesn't have changesets, which I do like. It also integrates nicely with the Django Admin. You setup your models, and you can very easily generate an admin interface to CRUD on those models. One annoyance I have with Ecto is that migration files are handwritten. There's a generator tool, but it only gives you a skeleton migration that you then have to manually fill in. This gives you 2 sources of truth, which is error prone. Automating this process like in Django solves this issue. Ash[1] (which uses Ecto under the hood) does solve most of these issues, although at the moment the documentation can be hard to navigate. [0] https://docs.djangoproject.com/en/4.2/topics/db/queries/ https://docs.djangoproject.com/en/4.2/topics/db/queries/ [1] https://ash-hq.org/ https://ash-hq.org/
- melx 3y agoDjango ORM is nice but too simple for some advanced examples. Tried to solve some Postgres CTE in Django? Good luck.
- sph 3y ago> Ecto is good but I think the Django ORM does it better. Oh no, I strongly disagree. I know both very well, and Ecto is much better and flexible. SQLAlchemy was great, when I last used it two aeons ago, but still subpar compared to Ecto. But also apples and oranges. Django has an ORM (i.e. stateful), Ecto is a stateless data mapper.
- bsder 3y ago> I feel for anyone using a Node.js backend. Y'all really don't know what you're missing. This is why there was so much push in Rust to get async anything up and running. There are a LOT of people fed up with the current web backend ecosystems.
- pictur 3y agoWhat's the point of selling languages like elixir as silver bullets like this? Each language has advantages and disadvantages over each other. I wouldn't want to work in the same place as someone who makes such stupid comments. programming perspective should not be so shallow.
- hmmokidk 3y agoIt isn't a silver bullet. But it does have a lot of distinct advantages. I can come into any Elixir project and very easily write tests. I can't do this in Node. This is a huge disadvantage, and extremely dangerous, and in my opinion should render the entire language useless as a backend language for any serious project. Elixir may not be a silver bullet. But Node.js is definitely a vampire...that isn't on your side.