Do you find it to be flexible and adaptive to unique situations, the way SHELL programming is?
If you’ve done much with it, can you offer examples of contexts where “scripted C” would be advantageous?
Also, as a script, are there situations you can identify where “daisy-chaining” multiple “C scripts” would be the approach to be used, rather than building the monolithic C program to begin with?
Yes, certainly.
Especially when I have to generate C code on the fly (i.e. during runtime)
I sometimes generate C code with bash (using “here document” features) and pipe the result to tcc. Or run the resulting C-code in a subshell.
Sometimes when scripting in bash, and I need an extra command that bash doesn’t provide (like a custom input sanitation filter), I script it.
I don’t have examples at hand that I can show at the moment.
But I used it in a fully-automated video ingest, edit and distribution server for national/regional TV-news broadcast stations.
I could edit, repair or replace parts of the software while the system was running.
Well, the example above is a good illustration. I am very much a proponent for modularity and late binding.
“daisy-chaining” ? Yes, especially when doing parallel(simultaneous)-processing.
Working with pthreads and IPC is a bit of a drag in C and is not modular unless you clutter it up with fork/exec or system calls (and messagepassing over filedescriptors) which can get quite a painful mess fast if one is not careful.
But combining c-scipts and bash, to parallelize execution and IPC, is easy, fast and certainly a pleasure to work with. It also keeps the amount of LOC much smaller and much easier to navigate.
Since all work is directly executable sourcecode, you can have all scripts together without having an extra /bin/ for the compiled scripts and without having to remember what you did or did not compile recently.
It makes the total workflow (and bugfixing) smooth and fast. Also, bugs are often fixed within minutes without even bringing the application down.
It looks like I feel pedantic today. You see, scripting languages are traditionally associated with interpreters. That why, I’d like to clarify that tcc does not actually interprets C code. tcccompiles C code directly into RAM and executes it. No ELF executable created on HDD.
On the other hand, a number of ‘scripting’ environments do compile scripts into intermediate bytecode (Python), use JIT (Lua, JavaScript)… Now there is the question: what is the difference? I’d like to suggest that scripting environments absolutely have their executable core programs which in their turn run scripts whether compiled or interpreted.
Hence @tkn is correct: tcc can be called a scripting environment for C language.
P.S. I have never used it myself, but they say that ‘C shell’, i.e. csh (and tcsh nowadays) has an objective to provide command language that is stylistically consistent with C.