Free «Compare And Contrast Java Script, Tcl And Perl» Essay Sample


Scripting languages are essentially used for extending the features of components rather than for writing applications from scratch. JavaScript is a scripting language usually implemented as part of a web browser to provide better user interfaces and dynamic websites while Perl is used mainly for CGI (Common Gateway Interface) web applications. Another popular one, Tcl (pronounced as ‘tickle’) is commonly used for scripted applications, rapid prototyping, GUIs (Graphical User Interface) and testing. Perl was designed by Larry Wall in 1987, then came Tcl in 1988 designed by John Ousterhout and finally Brendan Eich designed JavaScript in 1994(Ivler and Husain, 2011).

Compared to Perl, only JavaScript can execute within the web page loaded in the browser window. It is the best suited one for form error checking, on-page calculations and also for interacting with users instantly. It can also import other external JavaScript files, image files, etc. by typing the file URLs into address bar of the browser even though it lacks the ability to store information on its own to a file or even update databases while Perl can manipulate data files on the server. JavaScript code is part of the web page source code and additional code can be imported from external files into the web page while Perl script can generate web page source code from within itself.



    Preparing Orders



    Active Writers



    Positive Feedback



    Support Agents


Type of service ?
Type of assignment ?
Number of pages ?
Academic level ?
Timeframes ?
Spacing ?
Currency ?
  • Total price
Continue to order

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.

JavaScript & Perl

Perl and JavaScript have different syntaxes but semantics are surprisingly similar. They vary most significantly in OO systems. In JavaScript a user defined function is defined using the syntax ‘function name (arg1, arg2, ….) {‘, while in Perl it is ‘sub name (no arguments)’ (Bosanac, 2007). The syntax for calling this function is also different in both, in JavaScript it is called as ‘name (arg1, arg2)’ compared to Perl where it is called as ‘&name’. In both the arrays start at 0 and function ends with ‘}’. Most of the array operators of JavaScript seem to have been based on Perl and hence have the same names. End of line is represented by ‘//’ in JavaScript and it is denoted by ‘#’ in Perl. There is only two levels of scope in JavaScript and has no block scope and also there is no JavaScript equivalent of Perl’s do {….}. Single quotes do not interpret escape sequence other than \\ and \’ in Perl but the same set of escape sequences are interpreted by both single and double quoted strings in JavaScript. JavaScript doesn’t support \N{NAME} (named Unicode character), \e and \c [(escape/control), \a (alarm bell) while Perl doesn’t support JavaScript’s \v (vertical tab).  JavaScript has ‘+’ while Perl has ‘+’ and ‘.’. In JavaScript ‘+’ coerces to strings when one of the operands is a string while in Perl, it coerces to numbers (Bosanac, 2007). JavaScript has real Boolean but in Perl, you need to use Boolean from CPAN which gives you essentially the same thing. Lots of convenient operators that are there in Perl such as < = > cmp, low-precedence and/or/not,//,=~, ~~, qq(), qx(), qw(),m//, s///,**,etc. Variable scoping is one of Perl’s strength compared to other languages. Both Perl and JavaScript use the same names for their mathematical functions as C but JavaScript puts ‘Math’ before each function name. 

Basically when you compare JavaScript and Perl the features what stands them separate are that JavaScript is executed within the browser window while Perl is not. JavaScript needs HTTP to execute but Perl doesn’t. Source code of JavaScript is within the web page excluding the imported files while Perl it is not within the web page (Bosanac, 2007). Perl can use MySQL and update files on server while JavaScript needs to use non-JavaScript software on the server to do this. Both the scripting languages can however obtain files from other domains on the internet.

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).

Get 24/7 Free consulting
Toll free

For a class C defined in C++ as and a class instance named c, here is a comparison of the three languages

Class C


Public :


            C(const char *s);

            void doA(bool b);

            Static void doB();                                         

            int p;

. . .


Features of JavaScript, Perl & TCL

Feature JavaScript Perl Tcl
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, 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"



What Our Customers Say

Now Accepting Apple Pay!
Click here to chat with us