C as a scripting language
Chris Palmer just told me about a remarkable program called tcc, the Tiny C Compiler. tcc is unbelievably small and fast (it claims to be able to compile the entire Linux kernel in 10 seconds, which I keep thinking must be a misprint every time I see it), so that some people are actually compiling their kernels at boot time as part of the boot process, or so I'm given to understand.
But the other funny thing you can do with tcc is use C as a scripting language. For example,
[schoen@eleos tcc-0.9.22]$ cat hello.c
#!/usr/local/bin/tcc -run
int main(int argc, char *argv[]){
int i;
for(i=0; i<10; i++){
printf("%s: Hello, %d world!\n", argv[0], i);
}
}
[schoen@eleos tcc-0.9.22]$ ./hello.c
./hello.c: Hello, 0 world!
./hello.c: Hello, 1 world!
./hello.c: Hello, 2 world!
./hello.c: Hello, 3 world!
./hello.c: Hello, 4 world!
./hello.c: Hello, 5 world!
./hello.c: Hello, 6 world!
./hello.c: Hello, 7 world!
./hello.c: Hello, 8 world!
./hello.c: Hello, 9 world!