Jan's Illustrated Computer Literacy 101 Logo:Jegsworks Jan's Illustrated Computer Literacy 101

Home > Jan's CompLit 101 > Computer Basics > Programming > Languages
Icon: Arrow - Previous pagePrevious    NextIcon: Arrow - Next page

Jan's Computer Basics:

Programming: Languages

Many computer languages are available for writing computer programs. They each have advantages for certain kinds of tasks.

Computers talking in different computer languages

Let's check out some examples of the various types of computer languages and see what they are used for.

Machine Language

= The native tongue of the CPU.

Each design for a CPU has its own machine language. This is the set of instructions that the chip uses itself. So it is made up of sets of 0's and 1's, that is binary numbers. Very hard for people to work with.

 10  23
 11  FF
 12  12
 13  10
 14  50
 15  23
 16  30
 17  40
 18  C0
 19  00

Machine language looks like it's just numbers.

In the program segment at left the first column tells the computer where to fill memory and the hexadecimal (base 16) numbers in the second column are the values to put into memory at those locations.

For more information on hexadecimal numbers, see Base Arithmetic.

Here's another example of machine language.

The segment of Java code:

	   int counter = 0;
	   counter = counter + 1;	
might be translated into machine language as:

Assembly Language

= Codes or abbreviations for the machine language instructions

In an assembly language each machine language instruction is assigned a code. So instead of having to remember a string of 0's and 1's, the programmer would only need to remember short codes like ADD, MOV, or JLE. Certainly an improvement over 000101000100010001000100001000101010111110!! But not really "user friendly" either.

The assembly language program below reads two characters and prints them on the screen. The text to the right of the semicolons ( ; ) is ignored by the computer. It's there to explain the program to anyone looking at the code. Notice that each little step must be coded. All this just to display 2 characters!

;name of the program:one.asm
.model small
     mov AH,1h    ;Selects the 1  D.O.S. function 
     Int 21h      ;reads character and return ASCII 
			;  code to register AL
     mov DL,AL    ;moves the ASCII code to register DL
     sub DL,30h   ;makes the operation minus 30h to 
			;  convert 0-9 digit number
     cmp DL,9h    ;compares if digit number it was
			;  between 0-9
     jle digit1   ;If it true gets the first number 
			; digit (4 bits long)
     sub DL,7h    ;If it false, makes operation minus
		;  7h to convert letter A-F digit1:
     mov CL,4h    ;prepares to multiply by 16 
     shl DL,CL    ;multiply to convert into four bits upper 
     int 21h      ;gets the next character 
     sub AL,30h   ;repeats the conversion operation 
     cmp AL,9h    ;compares the value 9h with the content
			;  of register AL 
     jle digit2   ;If true, gets the second digit number 
     sub AL,7h    ;If no, makes the minus operation 7h 
			;  digit2:
     add DL,AL    ;adds the second number digit 
     mov AH,4CH
     Int 21h      ;21h interruption
     End	  	;finish the program code


= Formula Translation

FORTRAN was created around 1957 to help scientists, engineers, and mathematicians write programs that describe complex situations, like nuclear power plant monitoring, nuclear explosions, and space flight. This is still a widely used language. It was the first successful high-level program. Newer versions have been released. The most recent standard version is Fortran 2008 which was finalized Sept. 2010. (Originally FORTRAN in all caps was required but recent version names can use normal case.)

The example Fortran program below accepts the bus number 99 and displays the command "TAKE BUS 99"

      BUS_NUM = 99
      WRITE(*,*) ' TAKE BUS ', BUS_NUM


= Common Business Oriented Language

COBOL was written about 1960 with business applications in mind. It has a very English-like structure, using sentences and paragraphs, though they are certainly different from those in a novel. This helps business people who are not high-powered programmers to be able to write or edit a program. But it has the disadvantage of tending toward wordy, lengthy programs. It is a good language for direct, simple programs. 

COBOL was used to create many programs for the main frames of large companies. These programs were upgraded during the Y2K fixes for the year 2000.  So it seems likely that COBOL programs will be around for a long time yet.

The example below accepts two numbers, multiplies them, and displays the numbers and the result. Look at the PROCEDURE DIVISION to see where the calculation is done.

PROGRAM-ID.  FragmentA.
AUTHOR.  Michael Coughlan.


01  Num1                                PIC 9  VALUE ZEROS.
01  Num2                                PIC 9  VALUE ZEROS.
01  Result                              PIC 99 VALUE ZEROS.

    ACCEPT Num1.
    MULTIPLY Num1 BY Num2 GIVING Result.
    ACCEPT Num2.
    DISPLAY "Result is = ", Result.


= Beginner's All Symbolic Instruction Code

This language was written in 1964 (truly the age of dinosaurs for computers!) for college students to use to learn programming concepts. Originally BASIC was intended only for classroom use. But the language has proven to be highly useful in the real world. A wide variety of "dialects" of BASIC developed through the years. Visual Basic is now very popular for programming Windows applications. Microsoft Visual Basic for Applications is an example of a subset of BASIC that is modified to help users write small subprograms called scripts or macros for use with applications like MS Word. Some applications used to have their own variety of BASIC for writing their macros, like Word Basic and Excel Basic.

The creators of BASIC wanted a language that felt more like regular English. So while it doesn't LOOK much like English, it uses enough of the syntax of English to give it a more natural feel than many other computer languages.

The short program below is written in BASIC. It accepts a distance in miles, yards, feet, and inches and converts it to kilometers, meters, and centimeters. Notice how the programmer can write equations to do the calculations.

' English to Metric Conversion
' J. S. Quasney
' ****************************
PRINT : PRINT "English to Metric Conversion"
INPUT "Miles: ", Miles
INPUT "Yards: ", Yards
INPUT "Feet: ", Feet
INPUT "Inches: ", Inches
Inches = 63360 * Miles + 36 * Yards + 12 * Feet + Inches
Meters# = Inches / 39.37#
Kilometers = INT(Meters# / 1000)
Meters# = Meters# - 1000 * Kilometers
Final.Meters = INT(Meters#)
Centimeters = Meters# - Final.Meters
Centimeters = 100 * Centimeters
Centimeters = INT((Centimeters + .005) * 100) / 100
PRINT "Kilometers:"; Kilometers
PRINT "Meters:"; Final.Meters
PRINT "Centimeters:"; Centimeters


Originally created for writing system software, C has evolved into  C++. Both are widely used by programming professionals for all sorts of programs.

The program below is written in C++. It accepts 3 numbers and checks to see if the third is equal to the difference of the first two.

#include <iostream.h>
void main()
	int a, b, c;
	cout << "Please enter three numbers\n";
	cout << "a: ";
	cin >> a;
	cout << "\nb: ";
	cin >> b;
	cout << "\nc: ";
	cin >> c;

	if (c==(a-b))
		cout << "a: ";
		cout << a;
		cout << " minus b: ";
		cout << b;
		cout << " equals c: ";
		cout << c << endl;
		cout << "a-b does not equal c:" << endl;


The language Java is used to write both full computer applications and small applets for web pages. Its goal is to create applications that will run on any computer, unlike other languages which are not cross-platform.

(By the way, don't confuse Java with JavaScript, a scripting language commonly used on web pages. The only thing they share is the letters in their names! JavaScript started life as LiveScript in about 1994. Netscape bought it and renamed it, apparently for marketing reasons.)

The example below draws a box on an HTML page and counts the number of times you have clicked inside the box.

import java.applet.*;
import java.awt.*;
public class exfour extends Applet
    int i;
    public void init()
    public void paint(Graphics g)
     g.drawString("You clicked the mouse "+i+" Times",50,50);
    public boolean mouseUp(Event e, int x, int y)
      return true;

More examples of programming langugaes: The web site Rosetta Code Icon: Off site has many pages that show how various programming languages accomplish the same task. Below are links to the pages for two 'simple' tasks. These are simpler in some languages than in others! (Full list Icon: Off site of programming tasks)