music |
| | OSdata.com |
free form vs. columns
summary
Most early programming languages were organized in the columns of a punched card, while modern programming languages are completely (or nearly completely) free form.
free form vs. columns
Programming languages can be free form or column based. Most early programming languages were organized in the columns of a punched card, while modern programming languages are completely (or nearly completely) free form.
Many early programming languages relied heavily on punched cards for entry, including requiring that specific elements of the program appear in specific columns. The Hollerith punch card had 80 columns.
The 80 characters per line continued on almost all computer monitors into the 1980s.
The division of program lines into 80 character lines was specifically because of the widespread use of punched cards for input and output.
Most of the early programming languages included sequence numbers in certain columns so that a dropped set of cards could be restored to correct order (either by hand or by sorting machine).
Note that the gray columns in the following picture are much wider than depicted.
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18-69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
COBOL |
sequence number |
cmnt |
A |
B |
identification |
FORTRAN |
label |
cont |
FORTRAN statements |
ignored |
PL/I |
OS |
PL/I statements |
sequence number |
Almost all modern programming languages are free form, meaning that the programmer has relative freedom to format a program in an easy to read and understand manner.
A continuation character is used in some column-based languages to indicate that some element extends over more than one line. For example, in FORTRAN a programmer places a character other than space or blank in the sixth column to indicate that the card is a continuation from the previous card.
Even though modern languages are generally free form, you will occassionally find vestigages of the older column/card view crop up in places.
Indentation should be used to visually make the source code more comprehensible and easier to read. Consider the following examples (from C and Pascal):
good
main()
{
int i,j,k;
k = 0;
for(i = 1; i <= 10; i++)
{
for(j = 1; j <= 15; j++)
{
k++;
}
}
} |
|
bad
main()
{
int i,j,k;
for(i = 1; i <= 10; i++) { for(j = 1; j <= 15; j++)
{ k++; } } } |
good
procedure SimpleLoop;
var
i: integer;
j: integer;
begin
j := 0;
for i := 1 to 10
do begin
j := j + i;
end; {for]
end; {SimpleLoop} |
|
bad
procedure SimpleLoop;
var i,j: integer; begin
j := 0; for i := 1 to 10 do begin j := j + i;
end; end; |
Not only does good indentation make code easier to read, it also makes it easier to spot many kinds of simple typing errors, such as imbalance of matching pairs.
C is completely free form.
Pascal is completely free form.
PHP is completely free form.
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
Names and logos of various OSs are trademarks of their respective owners.