Jump to content

Computer program: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Restored lead to summary of the article: See Wikipedia:Lead section "The lead should be capable of standing alone as a concise overview of the article..."
Introduction changed to cover both kinds of program discussed in main body + cut irrelevant detail from paradigm categories
Line 1: Line 1:
The terms '''computer program''', '''software program''', or just program are used to refer to either an executable [[program]] (by both lay people and [[computer programmer]]s) or the collection of [[source code]] from which an executable program is created (eg, [[compiler|compiled]]).
A '''computer program''' is one or more [[Instruction_(computer_science)|instructions]] that are intended for execution by a [[computer]]. A computer requires programs to function, and a computer program does nothing unless its instructions are executed by a [[Central_processing_unit|central processor]]. <ref name="osc-ch3-p58">{{cite book
| last = Silberschatz
| first = Abraham
| title = Operating System Concepts, Fourth Edition
| publisher = Addison-Wesley
| date = 1994
| pages = 58
| id = ISBN 0-201-50480-4
}}</ref> Computer programs are the result of the [[compiler|compilation]] or [[Interpreter (computing)|interpretation]] of instructions ([[source code]]) written in a [[programming language]]. Programs may be embedded into [[Computer_hardware|hardware]], loaded by other programs from a storage device, or may be manually inputted to the central processor of a computer.


==Programming==
==Programming==
[[Image:Computer_program_source code.jpg|thumb|230px|right|Source code written in the [[C programming language]]]]
[[Image:Computer_program_source code.jpg|thumb|230px|right|Source code of a program written in the [[C programming language]]]]
{{main|Computer programming}}
{{main|Computer programming}}
[[Computer programming]] is the iterative process of writing or editing [[source code]]. Editing source code involves testing, analyzing, and refining. A person who practices this skill is referred to as a computer [[programmer]] or software developer. 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.
[[Computer programming]] is the iterative process of writing or editing [[source code]]. Editing source code involves testing, analyzing, and refining. A person who practices this skill is referred to as a computer [[programmer]] or software developer. 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.


=== Language paradigm categories ===
=== Language paradigm categories ===
Computer programs can be categorized by the [[programming language]] [[Programming_paradigm|paradigms]] used to produce them. These paradigms include: [[imperative programming|imperative]], [[declarative language|declarative]], or [[Visual programming language|visual]].
Computer programs can be categorized by the [[programming language]] [[Programming_paradigm|paradigms]] used to produce them. Two of the main paradigms are: [[imperative programming|imperative]] and [[declarative language|declarative]].


With imperative languages, an [[algorithm]] is specified using declarations, expressions, and statements. <ref name="cpl-ch4-75">{{cite book
Programs written using an imperative language specify an [[algorithm]] using declarations, expressions, and statements. <ref name="cpl-ch4-75">{{cite book
| last = Wilson
| last = Wilson
| first = Leslie B.
| first = Leslie B.
Line 25: Line 17:
| pages = 75
| pages = 75
| id = ISBN 0-201-56885-3
| id = ISBN 0-201-56885-3
}}</ref> Programs written using a declarative language the specify the properties that have to be met by the output and do not specify any implementation details. Two broad categories of declarative languages are [[functional language]]s and [[logical language]]s.
}}</ref> A declaration is a statement that binds a variable name with a datatype. For example: <code> var x: integer; </code> An expression yields a value. For example: <code> 2 + 2 </code> yields 4. Finally, a statement is a command that normally either assigns an expression to a variable or uses the contents of a variable to alter the program's flow. For example: <code>x := 2 + 2; if x == 4 then do_something();</code> One criticism of imperative languages is the side-effect of an assignment statement on a class of variables called non-local variables. <ref name="cpl-ch9-213">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Second Edition
| publisher = Addison-Wesley
| date = 1993
| pages = 213
| id = ISBN 0-201-56885-3
}}</ref>

With declarative languages, the output is specified and the implementation details are hidden. Two broad categories of declarative languages are functional languages and logical languages. The principle behind functional languages (like [[Lisp]]) is to remove the side-effect of an assignment statement on non-local variables. By doing away with assignments, it is possible to ensure that computer programs behave like mathematical functions. <ref name="cpl-ch9-213">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Second Edition
| publisher = Addison-Wesley
| date = 1993
| pages = 213
| id = ISBN 0-201-56885-3
}}</ref> 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. <ref name="cpl-ch10-244">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Second Edition
| publisher = Addison-Wesley
| date = 1993
| pages = 244
| id = ISBN 0-201-56885-3
}}</ref> 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.


With visual languages, program elements are graphically manipulated rather than textually specified.
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 or interpretation of programming languages===
===Compilation or interpretation of programming languages===

Revision as of 00:14, 14 November 2007

The terms computer program, software program, or just program are used to refer to either an executable program (by both lay people and computer programmers) or the collection of source code from which an executable program is created (eg, compiled).

Programming

Source code of a program written in the C programming language

Computer programming is the iterative process of writing or editing source code. Editing source code involves testing, analyzing, and refining. A person who practices this skill is referred to as a computer programmer or software developer. 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.

Language paradigm categories

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

Programs written using an imperative language specify an algorithm using declarations, expressions, and statements. [1] Programs written using a declarative language the specify the properties that have to be met by the output and do not specify any implementation details. Two broad categories of declarative languages are functional languages and logical languages.

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 or interpretation of programming languages

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

Self-modifying computer programs

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 Lisp, COBOL, and Prolog.

Program execution and storage

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 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. [2] Termination is either by normal self-termination or by error — software or hardware error.

Computer programs embedded into hardware

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

Some computer programs are embedded into hardware. 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 CPU registers to device controllers to memory contents. [3] Following the initialization process, this initial computer program loads the operating system and sets the program counter to begin normal operations. 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. [4]

Computer programs manually inputted

Switches for manual input on a Data General Nova 3

Computer programs historically were manually inputted to the central processor via switches. 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 inputted via paper tape or punched cards. After the medium was loaded, the starting address was set via switches and the execute button pressed. [5]

Simultaneous execution

Many computer programs may run simultaneously on a single computer, which is known as multitasking, through either software or hardware mechanisms. Modern operating systems may run multiple programs through process scheduling — a software mechanism to switch the CPU among processes frequently so that users can interact with each program while it is running. [6] Within hardware, modern day multiprocessor computers or computers with multicore processors may run multiple programs. [7]

Functional categories

Computer programs may be categorized along functional lines. These functional categories are system software and application software. System software includes the operating system which couples the computer's hardware with the application software. [8] The purpose of the operating system is to provide an environment in which application software executes in a convenient and efficient manner. [8] In addition to the operating system, system software includes utility programs that help manage and tune the computer. If a computer program is not system software then it is application software. Application software includes middleware, which couples the system software with the user interface. Application software also includes utility programs that help users solve application problems, like the need for sorting.

References

  1. ^ Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 75. ISBN 0-201-56885-3.
  2. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 97. ISBN 0-201-50480-4.
  3. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 30. ISBN 0-201-50480-4.
  4. ^ Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p. 11. ISBN 0-13-854662-2.
  5. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 6. ISBN 0-201-50480-4.
  6. ^ Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 100. ISBN 0-201-50480-4.
  7. ^ Akhter, Shameem (2006). Multi-Core Programming. Richard Bowles (Intel Press). pp. pp. 11-13. ISBN 0-9764832-4-6. {{cite book}}: |pages= has extra text (help)
  8. ^ a b Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 1. ISBN 0-201-50480-4.

Further reading

  • Knuth, Donald E. (1997). The Art of Computer Programming, Volume 1, 3rd Edition. Boston: Addison-Wesley. ISBN 0-201-89683-4. {{cite book}}: Check date values in: |date= (help)
  • Knuth, Donald E. (1997). The Art of Computer Programming, Volume 2, 3rd Edition. Boston: Addison-Wesley. ISBN 0-201-89684-2. {{cite book}}: Check date values in: |year= (help)CS1 maint: year (link)
  • Knuth, Donald E. (1997). The Art of Computer Programming, Volume 3, 3rd Edition. Boston: Addison-Wesley. ISBN 0-201-89685-0. {{cite book}}: Check date values in: |year= (help)CS1 maint: year (link)