Remix.run Logo
lokar 2 hours ago

This seems unnecessary to me. In the example, the core of git should be a library yo can link so you don't need to run the binary. That would be better in every way.

1718627440 an hour ago | parent | next [-]

But when you use a process, you get tons of things for free, the subtask is invoked in parallel, you get isolation and you can control execution for free. Unless you are already writing a multithreaded program or already accept passing objects in memory, using a process is actually easier to write than using a library.

If I use a library, I also need to start using threads and need to invent some core synchronization mechanism. I essentially are reinventing a small scheduler, when I already get this from the OS for free. Also know any crash in the third-party code will crash the whole program, the third-party code has access to the whole address space. With invoking a process you also have a standardized API implemented by the OS.

omoikane 26 minutes ago | parent | prev | next [-]

Launching git repeatedly was probably not the best example. But it's hard to think of good examples where launching processes repeatedly is the most performant thing to do, probably because launching processes had been expensive and everyone has learned to do something else (libraries, zygotes, etc). Maybe a different question is: if launching processes were cheap, is there something we would implement as processes instead of libraries?

I can recall just one program that's intentionally not implemented as a library, but I think people have since built a library on top of it:

https://dechifro.org/dcraw/#:~:text=Why%20don%27t%20you%20im...

sanderjd 2 hours ago | parent | prev [-]

There are lots of reasons to want to spawn fresh processes, which aren't solved by linking a library.

lokar an hour ago | parent | next [-]

Sure, but not many times a second

kllrnohj an hour ago | parent [-]

Every build system ever says hello.

aerzen an hour ago | parent | prev [-]

Spawning processes should not be on the hot path of any program.

1718627440 an hour ago | parent | next [-]

Why? That's a very useful processing primitive.

lokar an hour ago | parent [-]

It’s a hack with many disadvantages. Sometimes a hack is the right answer, but the kernel should it add a primitive for it.

MBCook an hour ago | parent [-]

Should bash link in every program the user might want? Load them up as dynamic libraries?

pizlonator an hour ago | parent | prev [-]

It ends up on the hot path of programs that use process isolation aggressively