Table of Contents
Perl is most commonly used in UNIX and also on WINDOWS to some extent. It is not common on iSeries but can be extended on any platform with extended libraries and can even access databases such as MySQL and others. It can generate web pages dynamically and files can be imported and parsed or displayed on the server. Tcl is used in full form and in other small-footprint versions of embedded systems platforms. SSI tag can be used to launch and execute a Perl Script and is preferred by those who prefer the software’s source code to be separate from the web page file.
Perl & TCL
When Perl is compared to Tcl, it comes with different functions and extensions so when you want to do an equivalent thing in Tcl as in Perl, you might have to search, download and install an extension or write one on your own. Tcl is much smaller and simpler compared to Perl and is also easier to customize, embed and extend. Tcl is also more portable than Perl. VFS capabilities are also more advanced in Tcl than in Perl. Tcl is also more immune to ‘format string vulnerabilities’(Wall, 2007). Perl has references like pointers in C while Tcl doesn’t have those but only names. When the reference count of a data item becomes zero, in Perl, the data item is garbage collected while one has to write own garbage collection code in Tcl for the lack of such references. There is significant difference in how strings are handled in Perl and Tcl (Wall, 2007). In Tcl, strings are C strings, so if you want the length or add to the end, you will need to search the entire string for null making it more time consuming and costly while in Perl, as it carries the length, both of these can be done easily. Binary data cannot be used in Tcl as in Perl also Arrays can be passed only by names in Perl while it is possible to pass by value or reference in Perl. Mathematical operations are faster in Perl as numbers are stored as numbers in Perl while they are stored as numbers only if they are within ‘expr’ statement in Tcl (Harrison, 1998). The script is parsed first and then turned to a syntax tree before optimizing it allowing scope for optimizations which are available to Tcl. The debugging option that is available in Perl is not in Tcl as it parse and execute one line at a time. Anonymous subroutines can be passed around as arguments and treated just like a reference to a regular subroutine in Perl. Such subroutines can also be used as closures in Perl. In Tcl, function names or strings which are to be evaluated as code can be passed around, but neither of these fully replaces the value of anonymous subroutines, and also Tcl doesn't provide closures (Harrison, 1998). Perl comes with references that allow arbitrarily complex data structures including structures that are self-referential but strings are used simulate nested lists in Tcl that can be put inside of a hashed array(Donald, Thomas & Wyke, 2000).
For a class C defined in C++ as and a class instance named c, here is a comparison of the three languages
C(const char *s);
void doA(bool b);
Static void doB();
. . .
|Default object construction||var c = new C();||my $c = C -> new ();||set c [construct C]|
|Construction with Argument||my $c = C->new("orange");||my $c = C->new("orange");||set c [construct C "orange"]|
|Getting a property||x = c.p;||$x = $c->p;||set x [property get $c p]|
|Setting a property||c.p = 10;||$c->p(10);||property set $c p 10|
|Equality testing||test.compare(c.p, 2);||test::compare($c->p, 2);||test compare [property get $c p] 2|
|Convert to native string||s = String(c);||set s [toString $c]|
|Native Boolean values||true, false||true, false||- (use 1 and 0)|
|Compare with application objects||s == "Max"||compare $s "Max"|
|Call a member function||c.doA(true);||$c->doA(1);||invoke $c doA true|
|Call a class function||C.doB();||C::doB();||invoke C doB|
|Send Key Presses||type("namewidget", "Max");||type("namewidget", "Max");||invoke type "namewidget" "Max"|