Computer program '''Computer programs''' (also '''[[Computer software|software programs]]''', or just '''programs''') are [[Instruction (computer science)|instructions]] for a [[computer]].{{cite book | last = Stair | first = Ralph M., et al | title = Principles of Information Systems, Sixth Edition | publisher = Thomson Learning, Inc. | date = 2003 | pages = 132 | id = ISBN 0-619-06489-7 }} A computer requires programs to function, and a computer program does nothing unless its instructions are executed by a [[Central processing unit|central processor]].{{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 }} Computer programs are usually [[executable]] programs or the [[source code]] from which executable programs are derived (e.g., [[compiler|compiled]]). Computer source code is often written by professional [[computer programmer]]s. Source code is written in a [[programming language]] that usually follows one of two main [[Programming paradigm|paradigms]]: [[imperative programming|imperative]] or [[declarative language|declarative]] programming. Source code may be converted into an [[executable file]] (sometimes called an executable program) by a [[compiler]]. Alternatively, computer programs may be executed by a [[central processing unit]] with the aid of an [[Interpreter (computing)|interpreter]], or may be [[firmware|embedded]] directly into [[Computer hardware|hardware]]. Computer programs may be categorized along functional lines: [[system software]] and [[application software]]. And many computer programs may run simultaneously on a single computer, a process known as [[computer multitasking|multitasking]]. ==Programming== {{main|Computer programming}}
main()
{
output_string("Hello world!");
}
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. === Paradigms === Computer programs can be categorized by the [[programming language]] [[Programming paradigm|paradigm]] used to produce them. Two of the main paradigms are [[imperative programming|imperative]] and [[declarative language|declarative]]. Programs written using an imperative language specify an [[algorithm]] using declarations, expressions, and statements.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Second Edition | publisher = Addison-Wesley | date = 1993 | pages = 75 | id = ISBN 0-201-56885-3 }} A declaration associates a [[variable]] name with a [[datatype]]. For example: var x: integer; . An expression yields a value. For example: 2 + 2 yields 4. Finally, 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.{{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 }} Programs written using a declarative language 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. The principle behind functional languages (like [[Haskell (programming language)|Haskell]]) is to not allow side-effects, which makes it easier to reason about programs like mathematical functions.{{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 }} 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.{{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 }} 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 [[Backtracking|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 or interpretation=== 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 file|executable image]] by a [[compiler]] or executed immediately with the aid of an [[Interpreter (computing)|interpreter]]. Compiled computer programs are commonly referred to as executables, binary images, or simply as [[binary file|binaries]] — a reference to the [[binary numeral system|binary]] [[file format]] used to store the executable code. Compilers are used to translate source code from a programming language into either [[object file|object code]] or [[machine code]]. Object code needs further processing to become machine code, and machine code is the [[Central processing unit|Central Processing Unit]]'s native [[microcode|code]], ready for execution. Interpreted computer programs are either decoded and then immediately executed or are decoded into some efficient intermediate representation for future execution. [[BASIC]], [[Perl]], and [[Python (programming language)|Python]] are examples of immediately executed computer programs. Alternatively, [[Java (programming language)|Java]] computer programs are compiled ahead of time and stored as a machine independent code called [[bytecode]]. Bytecode is then executed upon request by an interpreter called a [[virtual machine]]. The main disadvantage of interpreters is computer programs run slower than if compiled. Interpreting code is slower than running the compiled version because the interpreter must [[decode]] each [[Statement (programming)|statement]] each time it is loaded and then perform the desired action. On the other hand, software development may be quicker using an interpreter because testing is immediate when the compilation step is omitted. Another disadvantage of interpreters is the interpreter must be present on the computer at the time the computer program is executed. Alternatively, compiled computer programs need not have the compiler present at the time of execution. 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. ===Self-modifying programs=== A computer program in [[execution (computers)|execution]] is normally treated as being different from the [[data (computing)|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 programming language|Lisp]], [[cobol|COBOL]], and [[Prolog]]. ==Execution and storage== Typically, computer programs are stored in [[non-volatile memory]] until requested either directly or indirectly to be [[execution (computers)|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 (computing)|process]].{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 97 | id = ISBN 0-201-50480-4 }} Termination is either by normal self-termination or by error — software or hardware error. ===Embedded programs=== [[Image:DSCN0411.JPG|thumb|230px|left|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 [[booting|boot]]. The boot process is to identify and initialize all aspects of the system, from [[Processor register|CPU registers]] to [[Device driver|device controllers]] to [[Volatile memory|memory]] contents.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 30 | id = ISBN 0-201-50480-4 }} 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 [[Peripheral|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.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | date = 1990 | pages = 11 | id = ISBN 0-13-854662-2 }} ===Manual programming=== [[Image:Dg-nova3.jpg|thumb|230px|right|Switches for manual input on a [[Data General Nova]] 3]] Computer programs historically were manually input 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 input via [[paper tape]] or [[punched cards]]. After the medium was loaded, the starting address was set via switches and the execute button pressed.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 6 | id = ISBN 0-201-50480-4 }} ===Automatic program generation=== [[Generative programming]] is a style of [[computer programming]] that creates [[source code]] through [[generic programming|generic]] [[class (computer science)|classes]], [[Prototype-based programming|prototypes]], [[template (programming)|template]]s, [[aspect (computer science)|aspect]]s, and [[Code generation (compiler)|code generator]]s to improve [[programmer]] productivity. Source code is generated with [[programming tool]]s such as a [[template processor]] or an [[Integrated development environment|Integrated Development Environment]]. The simplest form of source code generator is a [[Macro (computer science)|macro]] processor, such as the [[C preprocessor]], which replaces patterns in source code according to relatively simple rules. [[Software engine]]s output source code or [[Markup language|markup code]] that simultaneously become the input to another [[Process (computing)|computer process]]. The analogy is that of one process driving another process, with the computer code being burned as fuel. [[Application server]]s are software engines that deliver applications to [[client computer]]s. For example, a [[Wiki software|Wiki]] is an application server that allows users to build [[dynamic web page|dynamic content]] assembled from [[article (publishing)|articles]]. Wikis generate [[HTML]], [[CSS]], [[Java (programming language)|Java]], and [[Javascript]] which are then [[Interpreter (computing)|interpreted]] by a [[web browser]]. === Simultaneous execution=== {{seealso|Process (computing)|Multiprocessing}} Many operating systems support [[computer multitasking|multitasking]] which enables many computer programs to appear to be running simultaneously on a single computer. Operating systems may run multiple programs through [[process scheduling]] — a software mechanism to [[Context switch|switch]] the CPU among processes frequently so that users can [[Time-sharing|interact]] with each program while it is running.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 100 | id = ISBN 0-201-50480-4 }} Within hardware, modern day multiprocessor computers or computers with multicore processors may run multiple programs.{{cite book | last = Akhter | first = Shameem | title = Multi-Core Programming | publisher = Richard Bowles (Intel Press) | date = 2006 | pages = pp. 11-13 | id = ISBN 0-9764832-4-6 }} == 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 hardware|computer's hardware]] with the application software.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 1 | id = ISBN 0-201-50480-4 }} The purpose of the operating system is to provide an environment in which application software executes in a convenient and efficient manner.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | date = 1994 | pages = 1 | id = ISBN 0-201-50480-4 }} In addition to the operating system, system software includes [[Utility software|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== {{reflist}} ==Further reading== {{refbegin}} *{{cite book | last = Knuth | first = Donald E. | title = The Art of Computer Programming, Volume 1, 3rd Edition | publisher = Addison-Wesley | date = 1997 | location = Boston | id = ISBN 0-201-89683-4 }} *{{cite book |last=Knuth |first=Donald E. |year=1997 |title=The Art of Computer Programming, Volume 2, 3rd Edition |location = Boston |publisher=Addison-Wesley |id=ISBN 0-201-89684-2 }} *{{cite book |last=Knuth |first=Donald E. |year=1997 |title=The Art of Computer Programming, Volume 3, 3rd Edition |location = Boston |publisher=Addison-Wesley |id=ISBN 0-201-89685-0 }}{{refend}} ==External links== *[http://www.webopedia.com/TERM/P/program.html Definition of "Program"] at Webopedia *[http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=software Definition of "Software"] at [[FOLDOC]] *[http://dictionary.reference.com/browse/computer%20program Definition of "Computer Program"] at dictionary.com [[Category:Computer programming]] [[Category:Computing terminology]] [[af:Rekenaarprogram]] [[az:Kompüter proqramları]] [[zh-min-nan:Tiān-náu thêng-sek]] [[be-x-old:Праграма]] [[bs:Računarski program]] [[ca:Programa informàtic]] [[cs:Počítačový program]] [[de:Computerprogramm]] [[et:Arvutiprogramm]] [[es:Programa (computación)]] [[fa:برنامه (رایانه)]] [[fr:Programme informatique]] [[ga:Ríomhchlár]] [[ko:컴퓨터 프로그램]] [[hr:Računalni program]] [[io:Programo]] [[id:Program komputer]] [[is:Tölvuforrit]] [[it:Programma (informatica)]] [[he:תוכנית מחשב]] [[kk:Компьютерлік бағдарлама]] [[lo:ໂປແກມ ຄອມພິວເຕີ]] [[lv:Datorprogramma]] [[lt:Programa (kompiuterio)]] [[nl:Computerprogramma]] [[ja:プログラム (コンピュータ)]] [[pl:Program komputerowy]] [[pt:Programa de computador]] [[ro:Program (informatică)]] [[ru:Компьютерная программа]] [[simple:Computer program]] [[fi:Tietokoneohjelma]] [[sv:Datorprogram]] [[th:โปรแกรมคอมพิวเตอร์]] [[uk:Комп'ютерна програма]] [[ur:شمارندی برنامج]] [[yi:קאמפיוטער פראגראם]] [[zh:程序]]