FastAPI vs Node.js
Posted by AssumptionVast4395@reddit | learnprogramming | View on Reddit | 12 comments
Pros and cons for these two as a backend for js + some framework
Posted by AssumptionVast4395@reddit | learnprogramming | View on Reddit | 12 comments
Pros and cons for these two as a backend for js + some framework
oliver_extracts@reddit
the runtime vs framework distinction is worth knowing but the practical question is still valid. if your team (or just you) is already writing JS for the frontend, Express or Fastify keeps you in one language, which matters more than people admit when youre debugging at midnight. if youre doing anything ML-adjacent or heavy on data processing, FastAPI wins because the Python ecosystem just has more tools for that. pick based on where your logic actually lives.
ehs5@reddit
This is a oddly phrased question. FastAPI is a web application framework. Node.js is a runtime where you run any sort of code. Totally different categories.
To compare you would have to specify what sort of web application framework you would want to use in Node.js, like Express or Hono.
AssumptionVast4395@reddit (OP)
Node + Express (and libraries necessary for collab filtering)
opentabs-dev@reddit
for collab filtering specifically i'd just go fastapi — numpy/scipy/implicit/surprise/torch are all there and battle-tested, and you don't pay for the python<->js boundary. you can absolutely do it in node (mljs, tfjs, or call a python microservice) but for anything matrix-heavy you're basically wrapping a python lib anyway.
if your frontend is a js framework and your backend is mostly crud + auth + a recommender endpoint, the cleanest split imo is node for the api gateway and a small fastapi service behind it that just serves the model. one ecosystem per concern.
TheCityzens@reddit
Node if your frontend is already JS. Less context switching, less weirdness.
FastAPI feels really clean for API work though. Kinda depends if you want to stay in one ecosystem or not
Financial-Grass6753@reddit
Node I think - simpler for learners.
FastAPI introduces couple of concepts you won't need instantly but are hard to understand in a dim of time.
AssumptionVast4395@reddit (OP)
What about if you start working with algorithms for the backend? Like collaborative filtering. I know you can technically achieve the same effect in Node with extra work but is it worth it to choose node over FastAPI even in that case?
Financial-Grass6753@reddit
for colab filtering there were a couple of libs iirc, - not an issue in this case.
What are your actual requirements? You can achieve +- same outcome both with FastAPI as well as with Node.
AssumptionVast4395@reddit (OP)
In that case, I guess I want the one that is the most straightforward to work with and easier to scale. Ideally, whichever one is faster. I know python but I don't know FastAPI (currently learning) and I have used node + express in the past but wasn't really a big fan of it
Financial-Grass6753@reddit
well, then take sth new - FastAPI in your case.
AssumptionVast4395@reddit (OP)
Okay, tysm!
speyerlander@reddit
Node is not a framework, it's a runtime, so you'll still have to choose a framework to use in it if you wanna built a backend in JS. In general, if your backend serves rendered UI components, then there's not much of a replacement for a JS framework. If the backend is a logic heavy API, some people (including myself) would opt using FastAPI due to its serialization behavior, easy ORM and the (somewhat) bigger ecosystem.