Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

node.js does not impose it for everything. Every command in the fs library that has a natural synchronous interpretation (like reading a file, writing a file, ...) has a sync equivalent (readFileSync, writeFileSync, ...)


Try to do that on a production server that has to handle 1000 requests readFileSyncing at the same time ...

sync apis are just a conveniance for console applications, they are not meant for a web server.

So yes node.js DOES impose async programming for everything or node doesnt scale.


Sync is great for initialization. Due to the fact you only start up once, you can be as reckless with your performance hindering practices as much as you want as it will never amount to anything more than a few hundred extra milliseconds of startup time.


> Sync is great for initialization.

This is an interesting point. I've found in practice that the speed of server startup times depends on the scale of operations. For example, at a small scale, a 600 ms vs. a 1.2 sec startup makes little difference.

However, at scale such differences can matter. More so when something is going wrong that's causing erratic restarts.


True, and that helps for cases where you're willing to completely sacrifice concurrency.

But there's no reason we couldn't have syntactically synchronous code that still runs concurrently.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: