execute
has to fork, call execv
in the child, wait for the child, and save output and status code in memory. Using execv
directly makes your compiler become the program you're running, without ever creating an additional process. Not only is this more efficient, execute
will simply not work for programs with large (or infinite) output.