Computer program

From Wikipedia, the free encyclopedia
  (Redirected from Program (machine))
Jump to: navigation, search
For the TV programme, see The Computer Programme.
program hello;
  writeln('Hello, World!');
Source code of a "Hello, World!" program written in the Pascal programming language.

A computer program is a sequence of instructions,[1] performing a specific task when executed by a computer. A computer requires programs to function, and typically executes the program's instructions in a central processing unit.[2]

A computer program is usually written by a computer programmer in a programming language. From the program in its human-readable source code form, a compiler can derive machine code: a form consisting of instructions that the computer can directly execute. Alternatively, a computer program may be executed with the aid of an interpreter.

A small part of a computer program that performs a well-defined task is known as an algorithm. A collection of computer programs and related data is referred to as software. Computer programs may be categorized along functional lines, such as application software or system software.


Lovelace's diagram from Note G, the first published computer algorithm

The earliest programs preceded the invention of the digital computer and were used to direct the behavior of machines such as Jacquard looms and player pianos.[3]

During a nine-month period in 1842–43, Ada Lovelace translated the memoir of Italian mathematician Luigi Menabrea about Charles Babbage's newest proposed machine, the Analytical Engine. With the article she appended a set of notes which specified in complete detail a method for calculating Bernoulli numbers with the Analytical Engine, recognized by some historians as the world's first computer program.[4]

Alan Turing introduced the universal Turing machine in 1936–37, a Turing machine that can simulate an arbitrary Turing machine on arbitrary input. The universal machine essentially achieves this by reading both the description of the machine to be simulated as well as the input thereof from its own tape. This model is considered by some to be the origin of the stored program computer—used by John von Neumann (1946) for the "Electronic Computing Instrument" that now bears von Neumann's name: the von Neumann architecture.[5]

Switches for manual input on a Data General Nova 3

The Z3 computer, by German inventor Konrad Zuse in 1941, was the first working programmable, fully automatic computing machine. The ENIAC (Electronic Numerical Integrator And Computer) was the first electronic general-purpose computer, announced to the public in 1946. It was Turing-complete, digital, and capable of being reprogrammed to solve a full range of computing problems. The Manchester Small-Scale Experimental Machine was the world's first stored-program computer and ran its first program on 21 June 1948.[6]

Computer programs historically[when?] were manually input to the central processor via switches. The computer program was written on paper for reference. An instruction was represented by a configuration of on/off settings. After setting the configuration, an execute button was pressed. This process was then repeated. Computer programs also historically were manually input via paper tape or punched cards. After the medium was loaded, the starting address was set via switches and the execute button pressed.[7]

Computer programming[edit]

Main article: Computer programming

Computer programming is the process of writing or editing source code. Editing source code involves testing, analyzing, refining, and sometimes coordinating with other programmers on a jointly developed program. A person who practices this skill is referred to as a computer programmer, software developer, and sometimes coder.

The sometimes lengthy process of computer programming is usually referred to as software development. The term software engineering is becoming popular as the process is seen as an engineering discipline.

Programming languages[edit]

Main article: Programming language
A computer program written in the imperative programming style

Computer programs can be categorized by the programming language paradigm used to produce them. Two of the main paradigms are imperative and declarative.

Imperative programming languages specify an algorithm using declarations, expressions, and statements:[8]

  • A declaration couples a variable name to a datatype – for example: var x: integer;
  • An expression yields a value – for example: 2 + 2 yields 4
  • A statement might assign an expression to a variable or use the value of a variable to alter the program's control flow – for example: x := 2 + 2; if x = 4 then do_something();

One criticism of imperative languages is the side effect of an assignment statement on a class of variables called non-local variables.[9]

In turn, declarative programming languages specify the properties that have to be met by the output. They do not specify details expressed in terms of the control flow of the executing machine but of the mathematical relations between the declared objects and their properties. Two broad categories of declarative languages are functional languages and logical languages. The principle behind functional languages (like Haskell) is to not allow side effects, which makes it easier to reason about programs like mathematical functions.[9] The principle behind logical languages (like Prolog) is to define the problem to be solved — the goal — and leave the detailed solution to the Prolog system itself.[10] The goal is defined by providing a list of subgoals. Then each subgoal is defined by further providing a list of its subgoals, etc. If a path of subgoals fails to find a solution, then that subgoal is backtracked and another path is systematically attempted.

The form in which a program is created may be textual or visual. In a visual language program, elements are graphically manipulated rather than textually specified.

Compilation and interpretation[edit]

A computer program in the form of a human-readable, computer programming language is called source code. Source code may be converted into an executable image by a compiler or executed immediately with the aid of an interpreter.

Compilers are used to translate source code from a programming language into either object code or machine code.[11] Object code needs further processing to become machine code, and machine code consists of the central processing unit's native instructions, ready for execution. Compiled computer programs are commonly referred to as executables, binary images, or simply as binaries — a reference to the binary file format used to store the executable code.

Interpreters are used to execute source code from a programming language immediately, without an intermediate file. The interpreter decodes each statement and performs its behavior. One advantage of interpreters is the ability to generate an interactive session. The programmer is presented with a prompt, and individual lines of code are typed in and performed immediately.

The main disadvantage of interpreters is computer programs run slower than when compiled. Interpreting code is slower because the interpreter must decode each statement and then perform it. However, software development may be faster using an interpreter because testing is immediate when the compiling step is omitted. Another disadvantage of interpreters is an interpreter must be present on the executing computer. By contrast, compiled computer programs need no compiler present during execution.

Just in time compilers pre-compile computer programs ahead of time and interpret them later. For example, Java computer programs are pre-compiled into a file containing bytecode. Bytecode is then executed by an interpreter called a virtual machine.

Either compiled or interpreted programs might be executed in a batch process without human interaction. Batch programming languages are called scripting language. One common scripting language is Unix shell, and its executing environment is called the command-line interface.

No properties of a programming language require it to be exclusively compiled or exclusively interpreted. The categorization usually reflects the most popular method of language execution. For example, BASIC is thought of as an interpreted language and C a compiled language, despite the existence of BASIC compilers and C interpreters.

Storage and execution[edit]

In the 1950s computer programs were stored on perforated paper tape

Typically, computer programs are stored in non-volatile memory until requested either directly or indirectly to be executed by the computer user. Upon such a request, the program is loaded into random access memory, by a computer program called an operating system, where it can be accessed directly by the central processor. The central processor then executes ("runs") the program, instruction by instruction, until termination. A program in execution is called a process.[12] Termination is either by normal self-termination or by error — software or hardware error.

Self-modifying programs[edit]

Main article: Self-modifying code

A computer program in execution is normally treated as being different from the data the program operates on. However, in some cases, this distinction is blurred when a computer program modifies itself. The modified computer program is subsequently executed as part of the same program. Self-modifying code is possible for programs written in machine code, assembly language, Lisp, C, COBOL, PL/1, and Prolog.

Simultaneous execution[edit]

Many operating systems support multitasking which enables many computer programs to appear to run simultaneously on one computer. Operating systems may run multiple programs through process scheduling — a software mechanism to switch the CPU among processes often so users can interact with each program while it runs.[13] Within hardware, modern day multiprocessor computers or computers with multicore processors may run multiple programs.[14]

Multiple lines of the same computer program may be simultaneously executed using threads. Multithreading processors are optimized to execute multiple threads efficiently.

Functional categories[edit]

Computer programs may be categorized along functional lines. The main functional categories are application software and system software. System software includes the operating system which couples computer hardware with application software.[15] The purpose of the operating system is to provide an environment in which application software executes in a convenient and efficient manner.[15] In addition to the operating system, system software includes embedded programs, boot programs, and micro programs. Application software designed for end users have a user interface. Application software not designed for the end user includes middleware, which couples one application with another. Application software also includes utility programs. The distinction between system software and application software is under debate.

Application software[edit]

Main article: Application software
Example of an app: GCalctool, a software calculator

There are many types of application software:

Utility programs[edit]

Utility programs are application programs designed to aid system administrators and computer programmers.

Operating system[edit]

Computer programs accessing devices connected to the motherboard constitute the operating system. The operating system must ensure the correct operation of the computer. It must prevent application software from interfering with the proper operation of the other systems.[15] Operating System programs are written in low-level programming languages, like assembly or C.

Boot program[edit]

A stored-program computer requires an initial computer program stored in its read-only memory to boot. The boot process is to identify and initialize all aspects of the system, from processor registers to device controllers to memory contents.[16] Following the initialization process, this initial computer program loads the operating system and sets the program counter to begin normal operations.

Embedded programs[edit]

The microcontroller on the right of this USB flash drive is controlled with embedded firmware.

Independent of the host computer, a hardware device might have embedded firmware to control its operation. Firmware is used when the computer program is rarely or never expected to change, or when the program must not be lost when the power is off.[17]

Microcode programs[edit]

Microcode programs control the central processing unit. This code moves data between the registers, buses, arithmetic logic unit, graphics processing unit, and memory. Micro instructions are divided into nine functional groups.[18]

  • Instructions load the A bus from registers.
  • Instructions load the B bus from registers.
  • Instructions control loading the registers from the C bus.
  • Instructions control the A and B latches.
  • Instructions control the arithmetic logic unit functions.
  • Instructions control the shifter.
  • Instructions control the memory address register and memory buffer register.
  • Instructions to indicate memory read and memory write.
  • Instructions to control the analog multiplexer.

Industrial programs[edit]

A computer program can be deemed an industrial or commercial product when that is useful for the concerns of a business model, which involves such aspects as labor, markets, profitability, and quality-control. This is how most proprietary software is classified, though open-source software can also be regarded as a product if a commercial entity specializes in it; e.g. Red Hat, Inc. or SUSE, as both which develop and maintain open-source software products.

See also[edit]


  1. ^ Stair, Ralph M.; et al. (2003). Principles of Information Systems, Sixth Edition. Thomson Learning, Inc. p. 132. ISBN 0-619-06489-7. 
  2. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 58. ISBN 0-201-50480-4. 
  3. ^ Ettinger, James (2004) Jacquard's Web, Oxford University Press
  4. ^ J. Fuegi and J. Francis (October–December 2003), "Lovelace & Babbage and the creation of the 1843 'notes'", Annals of the History of Computing 25 (4): 16, 19, 25, doi:10.1109/MAHC.2003.1253887 
  5. ^ Davis, Martin (2000), Engines of Logic: Mathematicians and the origin of the Computer (1st ed.), New York NY: W. W. Norton & Company, ISBN 0-393-32229-7, (pb.) 
  6. ^ Enticknap, Nicholas (Summer 1998), "Computing's Golden Jubilee", Resurrection (The Computer Conservation Society) (20), ISSN 0958-7403, retrieved 19 April 2008 
  7. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 6. ISBN 0-201-50480-4. 
  8. ^ Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 75. ISBN 0-201-56885-3. 
  9. ^ a b Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 213. ISBN 0-201-56885-3. 
  10. ^ Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 244. ISBN 0-201-56885-3. 
  11. ^ "What is a Compiler?". Retrieved 2012-01-10. 
  12. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 97. ISBN 0-201-50480-4. 
  13. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 100. ISBN 0-201-50480-4. 
  14. ^ Akhter, Shameem (2006). Multi-Core Programming. Richard Bowles (Intel Press). pp. 11–13. ISBN 0-9764832-4-6. 
  15. ^ a b c Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 1. ISBN 0-201-50480-4. 
  16. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 30. ISBN 0-201-50480-4. 
  17. ^ Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p. 11. ISBN 0-13-854662-2. 
  18. ^ Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p. 172. ISBN 0-13-854662-2. 

Further reading[edit]