CSC300 / CSC402: Extras: Scope [11/11] |
Python | Java | ||||
---|---|---|---|---|---|
|
|
Java compiler removes names for variables. Only the values are
stored at runtime. The variable names are replaced with numbers
(offsets in memory). This is one characteristic of static
languages.
Python keeps names for variables at runtime. It stores a
map (aka, a dictionary) from variable names to values. This
is characteristic of dynamic
languages.
Java's approach is more efficient. Python's is more flexible.
Scripting languages
, such as perl and javascript, use the
python approach. Most other languages, including C, C++, C#,
objective-C, swift and FORTRAN, use the java approach.