News for hackers. Stuff that matters.
Re:Go Run by jitl on Wednesday February 21, 2024 @11:13PM (#39463176)
If Node/Typescript isn't performant enough, you need to move a lot of bytes around, but training a developer team on Rust seems like a massive organizational expenditure.

Go is probably the most efficient language for 0 -> Production. The standard library has everything you need to build a production backend service. There's zero build system shenanigans. Anyone who's seen a C-like language can start writing mediocre code today, and be pretty well off in 2 weeks.

So far at Notion we're solving all our problems with Typescript/NodeJS, but I'm currently working on a distributed system with Consul that needs to move a lot of bytes in and out of files in somewhat complicated ways, and boy howdy am I feeling the painful performance ceiling of single-core NodeJS, and I'm sure if I sat down to rewrite the performance sensitive part in Go, I'd be done in a few days and it'll do 10x the throughput of the NodeJS service with the same resources.

Re:Go Run by winrid on Wednesday February 21, 2024 @11:39PM (#39463322)
I mostly agree but... you can't use worker threads or something with Node to distribute the work? It's only like one line to submit a job to a worker thread, how is that much more than "go thing()"?
Re:Go Run by jitl on Thursday February 22, 2024 @12:10AM (#39463477)
There’s tools for parallel execution in Javascript like Worker or node:worker_threads but they have two big drawbacks that make them somewhere between annoying and useless:

1. No shared objects between threads. You can share non-resizable contiguous byte arrays (SharedArrayBuffer) but 98% of existing code makes normal objects and arrays, and if you want to send those to another thread, you pay a serialization memcopy round trip (no cast a buffer in this language). This severely limits threading to “shared nothing” style workloads. Can you pass a node HTTP request to another thread? No :(

2. Each thread worker needs to boot up from scratch from its own entry point file. This forces some pretty weird code layout and imposes a big boilerplate overhead as well as runtime overhead. And remember - no sharing! So if your threads need a common resource like a Postgres connection pool, they’re going to create their own copy.

Re:Go Run by winrid on Thursday February 22, 2024 @04:32AM (#39464993)
Yeah I agree. I made it work for one big system but Java or Go would have been nicer lol. Luckily I was able to just:

2. You can do this w/o restarting worker each time, which helps. Just keep it alive and submit work to it.

and then coordinate state in parent worker.

Re:Go Run by kalekold on Thursday February 22, 2024 @04:53AM (#39465117)
Node is single threaded.

No more needs to be said after that.