Skip to content

Elements of Programming Languages

August 7, 2009
There are several elements which programming languages, and programs written in them, typically contain. If you understand these elements and what they’re for, not only will you understand C better, but you’ll also find learning other programming languages, and moving between different programming languages, much easier.
1. There are variables or objects, in which you can store the pieces of data that a program is working on. Variables are the way we talk about memory locations. Variables may be global or local.
2. There are expressions, which compute new values from old ones.
3. There are assignments which store values into variables. In many languages, assignment is indicated by an equals sign; thus, we might have
        b = 3 or c = d + e + 1
 The first sets the variable b to 3; the second sets the variable c to the sum of the variables d plus e plus 1. 
4. There are conditionals which can be used to determine whether some condition is true, such as whether one number is greater than another.
5. Variables and expressions may have types, indicating the nature of the expected values. For instance, you might declare that one variable is expected to hold a number, and that another is expected to hold a piece of text.
There are single characters, integers, and real numbers, strings and there are arrays of integers, reals, or other types. There are types which reference (point at) values of other types. Finally, there may be user-defined data types, such as structures or records, which allow the programmer to build a more complicated data structure, describing a more complicated object, by accreting together several simpler types (or even other user-defined types).
6. There are statements which contain instructions describing what a program actually does. Statements may compute expressions, perform assignments, or call functions.
7. There are control flow constructs which determine what order statements are performed in. A certain statement might be performed only if a condition is true. A sequence of several statements might be repeated over and over, until some condition is met; this is called a loop.
8. An entire set of statements, declarations, and control flow constructs can be lumped together into a function (also called routine, subroutine, or procedure) which another piece of code can then call as a unit.
When you call a function, you transfer control to it and wait for it to do its job, after which it returns to you; it may also return a value as a result of what it has done. You may also pass values to the function on which it will operate or which otherwise direct its work.
9. A set of functions, global variables, and other elements makes up a program.
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: