Main Content
Variable storage - Perl, Tcl and Python compared Archive - Originally posted on "The Horse's Mouth" - 2009-10-08 06:04:44 - Graham Ellis
From Monday to Wednesday, I was teaching Python to a group of delegates at a company where I have previously taught Tcl and Expect and Perl . And this interesting diagram shows just what a contrast there is between the three languages right from the start - in terms of how data is stored into variables!
In Tcl , all data is stored a strings so the number 21 would be 2 bytes - the character 2 followed by the character 1.
In Perl , you have a much more 'traditional' model where the name of the variable - which has a leading $ - may be considered to be a direct label on the storage element
And in Python , everything is an object, so your variable name contains a reference to a location on the heap at which the data is stored.
Some other articles
Y102 - Python - Fundamentals A reminder of the key issues to consider in moving from Python 2 to Python 3 Mutable v Immuatble objects in Python, and the implication Learning to program - variables and constants BODMAS - the order a computer evaluates arithmetic expressions Formatting output - why we need to, and first Python example Some terms used in programming (Biased towards Python) Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. Beware - a=a+b and a+=b are different - Python Python - fresh examples from recent courses Learning to program in Python 2 ... and / or in Python 3 This article Python - fresh examples of all the fundamentals Pascals Triangle in Python and Java Python - input v raw input Question on division (Java) - Also Perl, PHP, Python ... Integer v float - Python Python security - trouble with input Getting rid of variables after you have finished with them Copying a reference, or cloning Making programs easy for any user to start T202 - Tcl Fundamentals Tcl variable names - no real limits! Learning to program - variables and constants BODMAS - the order a computer evaluates arithmetic expressions This article Curley brackets v double quotes - Tcl, Tk, Expect Buffering up in Tcl - the empty coke can comparison Stringing together Tcl scripts Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP Converting between Hex and Decimal in Tcl The ireallyreallywanna operator Comments in Tcl Making programs easy for any user to start Joining lists in Tcl. Indirect variables in Tcl. Looking for a donkey P202 - Perl Fundamentals Learning to program - variables and constants BODMAS - the order a computer evaluates arithmetic expressions Perl functions such as chop change their input parameters What order are operations performed in, in a Perl expression? Perl - making best use of the flexibility, but also using good coding standards Perl from basics Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. AND and OR operators - what is the difference between logical and bitwise varieties? Object Orientation in an hour and other Perl Lectures Different perl examples - some corners I rarely explore Are you learning Perl? Some more examples for you! This article Variable Types in Perl Perl - Subs, Chop v Chomp, => v , Hot Courses - Perl Question on division (Java) - Also Perl, PHP, Python ... Some one line Perl tips and techniques Getting rid of variables after you have finished with them MTBF of coffee machines