Monday, August 3, 2009

Computer programing languages

IV

Programming Languages

Programming languages contain the series of commands that create software. A CPU has a limited set of instructions known as machine code that it is capable of understanding. The CPU can understand only this language. All other programming languages must be converted to machine code for them to be understood. Computer programmers, however, prefer to use other computer languages that use words or other commands because they are easier to use. These other languages are slower because the language must be translated first so that the computer can understand it. The translation can lead to code that may be less efficient to run than code written directly in the machine’s language.

A

Machine Language

Computer programs that can be run by a computer’s operating system are called executables. An executable program is a sequence of extremely simple instructions known as machine code. These instructions are specific to the individual computer’s CPU and associated hardware. Machine code instructions are few in number (roughly 20 to 200, depending on the computer and the CPU). Typical instructions are for copying data from a memory location or for adding the contents of two memory locations (usually registers in the CPU). Complex tasks require a sequence of these simple instructions. Machine code instructions are binary—that is, sequences of bits (0s and 1s). Because these sequences are long strings of 0s and 1s and are usually not easy to understand, computer instructions usually are not written in machine code. Instead, computer programmers write code in languages known as an assembly language or a high-level language.

B

Assembly Language

Assembly language uses easy-to-remember commands that are more understandable to programmers than machine-language commands. Each machine language instruction has an equivalent command in assembly language. For example, in one Intel assembly language, the statement “MOV A, B” instructs the computer to copy data from location A to location B. The same instruction in machine code is a string of 16 0s and 1s. Once an assembly-language program is written, it is converted to a machine-language program by another program called an assembler.

Assembly language is fast and powerful because of its correspondence with machine language. It is still difficult to use, however, because assembly-language instructions are a series of abstract codes and each instruction carries out a relatively simple task. In addition, different CPUs use different machine languages and therefore require different programs and different assembly languages. Assembly language is sometimes inserted into a high-level language program to carry out specific hardware tasks or to speed up parts of the high-level program that are executed frequently.




C

High-Level Languages

High-level languages were developed because of the difficulty of programming using assembly languages. High-level languages are easier to use than machine and assembly languages because their commands are closer to natural human language. In addition, these languages are not CPU-specific. Instead, they contain general commands that work on different CPUs. For example, a programmer writing in the high-level C++ programming language who wants to display a greeting need include only the following command:

cout << ‘Hello, Encarta User!’ <<>

This command directs the computer’s CPU to display the greeting, and it will work no matter what type of CPU the computer uses. When this statement is executed, the text that appears between the quotes will be displayed. Although the “cout” and “endl” parts of the above statement appear cryptic, programmers quickly become accustomed to their meanings. For example, “cout” sends the greeting message to the “standard output” (usually the computer user’s screen) and “endl” is how to tell the computer (when using the C++ language) to go to a new line after it outputs the message. Like assembly-language instructions, high-level languages also must be translated. This is the task of a special program called a compiler. A compiler turns a high-level program into a CPU-specific machine language. For example, a programmer may write a program in a high-level language such as C++ or Java and then prepare it for different machines, such as a Sun Microsystems work station or a personal computer (PC), using compilers designed for those machines. This simplifies the programmer’s task and makes the software more portable to different users and machines.

V

FLOW-MATIC


American naval officer and mathematician Grace Murray Hopper helped develop the first commercially available high-level software language, FLOW-MATIC, in 1957. Hopper is credited for inventing the term bug, which indicates a computer malfunction; in 1945 she discovered a hardware failure in the Mark II computer caused by a moth trapped between its mechanical relays. She documented the event in her laboratory notebook, and the term eventually came to represent any computer error, including one based strictly on incorrect instructions in software. Hopper taped the moth into her notebook and wrote, “First actual case of a bug being found.”

VI

Fortran

From 1954 to 1958 American computer scientist John Backus of International Business Machines, Inc. (IBM) developed Fortran, an acronym for Formula Translation. It became a standard programming language because it could process mathematical formulas. Fortran and its variations are still in use today, especially in physics.

VII

BASIC


Hungarian-American mathematician John Kemeny and American mathematician Thomas Kurtz at Dartmouth College in Hanover, New Hampshire, developed BASIC (Beginner’s All-purpose Symbolic Instruction Code) in 1964. The language was easier to learn than its predecessors and became popular due to its friendly, interactive nature and its inclusion on early personal computers. Unlike languages that require all their instructions to be translated into machine code first, BASIC is turned into machine language line by line as the program runs. BASIC commands typify high-level languages because of their simplicity and their closeness to natural human language. For example, a program that divides a number in half can be written as

10 INPUT “ENTER A NUMBER,” X
20 Y=X/2
30 PRINT “HALF OF THAT NUMBER IS,” Y
The numbers that precede each line are chosen by the programmer to indicate the sequence of the commands. The first line prints “ENTER A NUMBER” on the computer screen followed by a question mark to prompt the user to type in the number labeled “X.” In the next line, that number is divided by two and stored as “Y.” In the third line, the result of the operation is displayed on the computer screen. Even though BASIC is rarely used today, this simple program demonstrates how data are stored and manipulated in most high-level programming languages.

VIII

Other High-Level Languages

Other high-level languages in use today include C, C++, Ada, Pascal, LISP, Prolog, COBOL, Visual Basic, and Java. Some languages, such as the “markup languages” known as HTML, XML, and their variants, are intended to display data, graphics, and media selections, especially for users of the World Wide Web. Markup languages are often not considered programming languages, but they have become increasingly sophisticated.

A

Object-Oriented Programming Languages

Object-oriented programming (OOP) languages, such as C++ and Java, are based on traditional high-level languages, but they enable a programmer to think in terms of collections of cooperating objects instead of lists of commands. Objects, such as a circle, have properties such as the radius of the circle and the command that draws it on the computer screen. Classes of objects can inherit features from other classes of objects. For example, a class defining squares can inherit features such as right angles from a class defining rectangles. This set of programming classes simplifies the programmer’s task, resulting in more “reusable” computer code. Reusable code allows a programmer to use code that has already been designed, written, and tested. This makes the programmer’s task easier, and it results in more reliable and efficient programs.



IX

Types of Computers


A

Digital and Analog

Computers can be either digital or analog. Virtually all modern computers are digital. Digital refers to the processes in computers that manipulate binary numbers (0s or 1s), which represent switches that are turned on or off by electrical current. A bit can have the value 0 or the value 1, but nothing in between 0 and 1. Analog refers to circuits or numerical values that have a continuous range. Both 0 and 1 can be represented by analog computers, but so can 0.5, 1.5, or a number like p (approximately 3.14).

A desk lamp can serve as an example of the difference between analog and digital. If the lamp has a simple on/off switch, then the lamp system is digital, because the lamp either produces light at a given moment or it does not. If a dimmer replaces the on/off switch, then the lamp is analog, because the amount of light can vary continuously from on to off and all intensities in between.

Analog computer systems were the first type to be produced. A popular analog computer used in the 20th century was the slide rule. To perform calculations with a slide rule, the user slides a narrow, gauged wooden strip inside a rulerlike holder. Because the sliding is continuous and there is no mechanism to stop at any exact values, the slide rule is analog. New interest has been shown recently in analog computers, particularly in areas such as neural networks. These are specialized computer designs that attempt to mimic neurons of the brain. They can be built to respond to continuous electrical signals. Most modern computers, however, are digital machines whose components have a finite number of states—for example, the 0 or 1, or on or off bits. These bits can be combined to denote information such as numbers, letters, graphics, sound, and program instructions.



Soured by:http://encarta.msn.com

No comments:

Post a Comment

 

Template Design By:
SkinCorner