Language speed [was Re: Good TK book]

From: Gustaf Neumann (neumann_at_wu-wien.ac.at)
Date: 12/29/04


Date: 29 Dec 2004 14:01:17 -0800

This version seems to need some finishing touch:
i have not looked in details, but found the following strangenesses:
  - thread benchmark: LUA seems to create 1000 threads, not 3000
    as required
  - thread benchmark: Java result failed, but it is counted
  - regex for tcl says: "No program", clicking on it shows a
    tcl program
  - ackermann runs out of stack. It should be possible to fix it
    with "interp recursionlimit ..."; the following version
    should be somewhat faster than the version with expr.

-gustaf
PS: Google news did not let me follow up, so i had to remove the "re:"
from the subject line.

===================================================================
interp recursionlimit {} 100000
set NUM [expr {[lindex $argv 0] < 0 ? 1 : [lindex $argv 0]}]

proc ack {m n} {
    if {$m == 0} { incr n
    } elseif {$n == 0} { ack [incr m -1] 1
    } else { ack [expr {$m - 1}] [ack $m [incr n -1]]
    }
}

puts "Ack(3,$NUM): [ack 3 $NUM]"