Many computer languages are available for writing computer programs. They each have advantages for certain kinds of tasks.
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.
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!
|
|||
FORTRAN |
= 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"
|
|||
COBOL |
= 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.
|
|||
BASIC |
= 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.
|
|||
C |
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.
|
|||
Java |
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.
|
More examples of programming langugaes: The web site Rosetta Code 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
of programming tasks)