On Wed, Jan 02, 2013 at 12:04:21PM +1100, Daniel Bryan wrote: > On the other hand, it's not the fact that C is compiled that makes it > more efficient than the interepreted bash - it's the fact that C is just > reading files and filling buffers, whereas Bash is doing a dozen > fork+execs.
Yes. It's possible to implement pipelines and parallel tasks using coroutines in C, which is a little scary / weird but can be very efficient. Coroutines can be used with multi-threading, using a worker thread per core. http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html But for many tasks, it's simpler just to fork! I seldom find the shell with its process-happy approach becomes too slow or heavy.