In C
main(){}
In C
main(){}
That’s what I thought too - sure the shortest program code would be in assembler - not a HLL
But will it work without the ‘return 0’?
Why dont you test it?
Something like a JMP instruction to itself.
Would run forever but be short code.
Okay, will try…
We can cheat a little more: The exit
builtin being not mandatory in shells, we can say the shortest program in bash
(and other shells) is the empty program: $ bash -c ""
is equivalent to $ bash -c exit
.
For most interpreted/script languages, this rule is true (the end-of-program instruction/builtin is optional at the end of the script), and the same idea can be used:
$ php -r ""
or $ php -r exit;
$ python -c ""
or $ python -c exit
$ perl -e ""
or perl -e exit
So, the shortest program in bash/perl/python/etc.
is… the empty string