4 ms·
Ask HN: Is Node.js still good for writing APIs?
Hi,
I wanted to know if NodeJS is still good option to write backend and for REST APIs. How does it stack up against GO? Are there any particular frameworks for high performance in Node.
Thanks!
- _bxg1 6y agoNode is best-suited for when your API itself does very little CPU work. When it serves mainly as a task-delegator to a DB, other APIs, local disk I/O, etc. All of these are non-blocked by JS and automatically handled by underlying native code in parallel. The main advantage of Node compared to Go is that your front- and back-end can be in the same language, which helps with hiring and can even allow for code-sharing. That said I don't think Node would ever match Go on raw performance, even in its wheelhouse. It's all about tradeoffs.
- neophyt3 6y agowhat if wasm become production ready... dont u think that cpu intensive will be native and difference will be somewhat closer?
- jwalgenbach 6y agoNo. Wasm is still executing on a virtual machine, and native compiled go code will still be native.
- _bxg1 6y agoThis question isn't so clear-cut. Go is still garbage-collected, which means that depending on what kind of program we're talking about, some well-memory-managed WASM code could conceivably still be faster.
- gregjor 6y agoWas it ever good?
- PixelPaul 6y agoYes, and still is
- wprapido 6y agoIf you don't need much in terms of computing power or you just use the API for delegation, Node makes for a good choice. It's a mature ecosystem, well documented, well supported, has excellent community.
- el_dev_hell 6y agoI enjoy Node when I'm pulling from several external APIs and need to pipe the data somewhere with minor mutations. Pretty much every API will have a JavaScript library/documentation, which is a huge time saver.
- vekker 6y agoFor the average CRUD app, even complex ones, I really like using NestJS (in combination with Angular in the frontend)
- thepiratesailor 6y agoNode.js does not beat Go Lang in terms of handling large numbers of request and performance (of course) So the question is Node.js good? Depends on your use case. Test yourself and decide yourself for your use case.
- adreamingsoul 6y agoApples and Oranges. Depending on your needs and goals, each has it's own pros/cons. Why are you asking the HN community?
- BrandonBradley 6y agoWhat are your performance requirements? If you have none, this is probably a pre-optimization.
- greatwhitenorth 6y agoIf you don't do much CPU work, node.js is great. If your load is on the DB (or) you offload the work to a background queue, you're good. If you already know JavaScript, just go with Node.js. If you end up with performance bottleneck (CPU bound operation), you can always write that in Go. Don't waste time upfront.
- talmr 6y agoNode is a great choice for fast iteration for a rest api if all you're doing is hitting DB, firing off other services, etc. Express is a solid choice imo due to the tremendous community support. If you ever need to do anything that involves CPU crunching, you can move those requirements to another language that's better suited for it like Go.