simply program hello world program (bellow have code of d , of perl) faster in perl (interpreted language) in d (compiled lang). why?
//d language (ldc compiler) import tango.io.stdout; void main() { int i=0; while (i<1000) { stdout("hola món").newline; = i+1; } }
and
my $i = 0; while ($i<1000) { print "hola món\n"; $i = $i+1; }
and time is:
time perl hello.pm real 0m0.047s user 0m0.004s sys 0m0.012s time ./hola real 0m0.070s user 0m0.044s sys 0m0.012s
why?
it seems code 99% syscalls (printf), , perl optimizes surrounding loop well. i'd try more complex doesn't rely heavily on single syscall.
also, makes sense perl optimized quick startup given partial focus on complementing/replacing unix toolbox (sed, awk). guess it's not surprising performs better other dynamic languages compact programs one.
Comments
Post a Comment