Some terms used in programming (Biased towards Python)
Archive - Originally posted on "The Horse's Mouth" - 2011-12-12 05:00:43 - Graham Ellis
Some of the elements of your program
Command
- typically a keyword followed by series of parameters
- a "unit" of shell / batch / Tcl programming
(You don't really have commands in Python)
Statement
- an atomic operational unit of a program
- a "unit" of Python / Perl / PHP / Lua / C etc programming
- does NOT start with a keyword (even though it looks like it in hello world!)
Block
- a series of statements (like sentence -> paragraph)
- blocks are a logical combination of multiple statements - molecular unit
Operator
- an action that is performed on operands (variables, constants, expressions)
- examples are + - * / = == print if (etc)
Operand
- something an operator works on (variable, constant or expression)
Variable
- a named memory location which contains a value that may be altered during a run
Constant
- Something that doesn't every change unless you edit the program
Expression
- a combination of variables, operators and constants that gives a result value
Function
- a named operator that performs on a number of expressions
- each expression passed into a function is known as a "parameter"
- there are a lot or prewritten functions, and you can define your own too.
- typically, using a function allows you to package common statement sequences
Method
- a function the performs its actions against a specific type of data
Separator
- the item that comes between statements or between parameters
- in Python, it's a new line or a ; between statements
- in Python, it's a comma between parameters
High Level
- Shorter instructions where a lot is done underneath and assumed for you
Low level
- Instructions where you give more minute detail of what you're doing
e.g. in Python ... "print" is high(er) level because it automatically adds spaces and new lines
... "write" is low(er) level because you tell it exactly the characters you want to output
How a program is translated and run
True Interpretter / Interpretive language
- Each statement is interpreted and then run as the program as a whole runs
- Simple structure
- Slow to run when you have loops - repeatedly re-interpreting the same thing
Examples - Shell, Tcl
Compiled language
- Source code (original text you wrote) translated into internal / binary format
- lots of other bits of standard code added to it to make an executable file
- Big song and dance routine to set up an executable even for a small change but
- potentially lightening fast to run
Examples - C, C++ Fortran
So what do all the other languages use?
- Source code is translated into a binary format that's common to all platforms
- A "Virtual Machine" reads and runs each statement from that binary format
- Other bits of standard code are loaded in as needed, also run via the Virtual Machine
Examples - Perl, Python, PHP, Ruby, Lua of languages we teach
Not quite identical - Java, where the translation from source to binary is done ahead of time and saved.
Note - Python STORES the binary format of modules as it translates them for the first time
- this makes for a quicker start-up when you rerun the program
- files are timestamped, and a check is made that the binary format is current