Version 8 of Why Tcl is so much slower than Perl

Updated 2006-10-02 23:38:21

It's not. It used to be, but it's not now, with Tcl interpreters after 8.0. [Refer to objective evidence.] It is necessary to answer the question, though, because so many antique claims to that effect continue to circulate.


Tcl is often somewhat slower than Perl for comparable operations. Algorithms that match Perl's regular expressions well generally favor Perl, sometimes by a large factor; a lot of work has gone into optimizing Perl's REs.


[Explain other penalties--correct Unicode and thread handling, ...]


Naive Tcl coders rarely understand the simple steps that boost Tcl performance. [Explain why this affects Tcl differentially.]


See http://www.equi4.com/md5/ for one example where Tcl is not that much slower.

Perhaps JCW will update these tests to reflect the new md5 code...


Arjen Markus From my own experience I can add that Perl and Tcl may have different ideas about what seems the same task. For instance: reading a file line by line. I noticed in a slightly naive test that Tcl would convert the end-of-line sequence, and Perl would not. (Note: I have not delved into the details and it may be specific to the particular releases I used then). This means that setting up a performance test requires a thorough understanding of what each language will do.

Furthermore, slight changes in the implementation of the algorithms may make all the difference. (Somewhere I see apples and pears lurking behind shrubberies of intricacies!)


DKF - Just noting here that 8.4 is the fastest Tcl to date, even faster than 8.0, as listed in Tcl Benchmarks. Despite having i18n and thread support...


Setok - The topic isn't even true for straightforward examples. I converted the Perl intro available at http://www.altparty.org/archive/invi.pl direct to Tcl 8.4 and it was faster (there is also a more optimised version at http://www.altparty.org/archive/invi.tcl ).


Tcl's not that slow compared to Perl: http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=tcl&lang2=perl


Category Advocacy - Category Performance