5 ms·
In web backend, Node.js is not slower than Go.
by theThree 1y ago
In web backend, Node.js is not slower than Go.
- danpalmer 1y ago[citation needed]
- theThree 1y agoFrom my own testing. In high-concurrency scenarios, their performance is roughly the same, and Node uses less memory. When it comes to string concatenation, Go has to do a lot of extra work (no "+",Estimating string length, Preallocate memory ) just to catch up with the speed of Node (simply using "+").
- Aeolun 1y agoEh, there’s some use cases where you can see some speedup from going to Go/Rust, but I’ll admit they’re pretty minimal.
- 9rx 1y agoExecution performance might be similar, but Node.js and Deno execution performance are also similar (both use v8 – there is only so much you can optimize beyond that), so clearly the comment is not talking about execution performance. Deno sells itself as having faster development performance, so presumably that is what performance is in reference to. It is hard to deny that Go isn't much more performant on the development end. Someone who is inexperienced might be slowed down due to that inexperience negating the performance boost, sure, but when one is concerned about developer performance they will be happy to incur the small upfront cost to become experienced for the bigger payoff later. (It is debatable if Go is really the king of developer performance, you might do even better with another language, but what is certain is that it is not Javascript/Typescript)
- williamstein 1y agoFor some applications especially those that benefit from cpu-bound parallelism, it is possible to write much faster code with Go than Node.js, e.g., consider the recent port of the Typescript compiler from Javascript to Go: - https://news.ycombinator.com/item?id=43332830 https://news.ycombinator.com/item?id=43332830
- gr4vityWall 1y agoI think 9rx agrees with you. Node.js shines as a web server. It can be made fast at CPU-bound tasks as well, but you wouldn't be writing idiomatic JS/TS. The recent tsc port from TS to Go is a good example of that. The TypeScript code in the compiler relied a lot on polymorphism, which made it really hard for the JIT to do a good job. The Go port enabled them to 'rewrite' it keeping the logic more-or-less 1:1 and land a good performance increase. IMO it was a good decision, specially the language choice, and much saner than what a JIT-friendly TS compiler would be.