There are two kinds of programs the kernel knows of. A binary program is identified by it's ELF (ExtenableLoadableFormat) header, which is usually produced by a compiler. The second one are scripts of any kind.
If a file starts in the very first line with the sequence #! then the next string has to...