$ time php -r 'echo "Hello, world!";' # smaller php binaries can be compiled
real 0m0.555s
$ time perl -e 'print "Hello, world!";'
real 0m0.385s
$ time ruby -e 'puts "Hello, world!"' # mri
real 0m0.073s
$ time python -c 'print("Hello, world!")'
real 0m0.067s
$ time lua -e 'print "Hello, world!"'
real 0m0.013s
$ time js -e 'print("Hello, world!")' # spidermonkey
real 0m0.010s
$ time awk 'BEGIN { print("Hello, world!") }'
real 0m0.004s
You're right about one thing. That is very unscientific. You're mainly testing your file system cache, not these programming language implementations.
E.g. perl(1) is faster than ruby(1) at printing "Hello, world!". But since you presumably had ruby hot in cache and not perl the latter seems to be almost 4 times as slow.
Update: Added a C program and ran the shell program in a sub-shell (since perl's system function preloads a shell). Didn't add silentbicycle's SWI Prolog and OCaml since he didn't provide the source.
I added hello world programs for C, SWI Prolog, and OCaml (byte and native compilers). Timings on OpenBSD/amd64.
Edit: Since you can precompile Lua, I added that as 'luac'. It's not usually done, since Lua compiles VERY quickly, and the source is more portable. It's a data point, though. I also added a .pyc for Python - Python byte-compiles more slowly. There's little difference between lua and luac, but the difference between python and py_pyc is huge.
I also added shell with a new subshell, both sh and bash. And, source, as requested.
OCaml:
let _ = print_string "Hello world.\n"
Compile with "ocamlc -o ochello foo.ml" for bytecode, "ocamlopt -o ochello.opt foo.ml" for native.
SWI Prolog:
swipl => sub { system qq[swipl -g "write('Hello world.\n')." -t "halt."] },
luac:
print "Hello, world."
And then compile with "luac hellow.lua", run as "lua luac.out".
Also interesting is how much memory is allocated running the empty program (detected with Valgrind):
Lua 5.1.4: 34k allocated, all memory freed.
Perl 5.10: 195k allocated (140k leaked!)
Ruby 1.8.7: 670k allocated (665kb still reachable at exit)
OpenJDK 6: 1.5M allocated (1M in use at exit).
Python 2.6.5: 3M allocated (1.2MB in use at exit)