music
OSdata.com: programming text book 

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 computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

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):

C

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++; } } }

Pascal

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

    C is completely free form.

Pascal

    Pascal is completely free form.

PHP

    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).


return to table of contents
free downloadable college text book

view text book
HTML file

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.

previous page next page
previous page next page

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2007, 2010, 2011 Milo

    Created: September 8, 2007

    Last Updated: January 12, 2011


return to table of contents
free downloadable college text book

previous page next page
previous page next page