But if it's a C library then there are memory issues, buffer overflows, undefined behaviour — everything that's bad about C.
The right thing IMHO would be to use pipes & stdin/stdout/stderr, but with a well-defined machine interface.
Agreed, which is why C should be treated as the "portable macro assembler" it is and just like Assembly, those libraries should be wrapped in higher level languages.
And then someone wraps it in a CLI interface.
What you need is a kernel that exposes programs as a file system like plan9
That is what the REPL like on Lisp Machines, Interlisp-D, Smalltalk, Mesa/Cedar, Oberon is for.
>What you need is a kernel that exposes programs as a file system like plan9