Computer program

Last updated

A computer program is a collection of instructions [1] that can be executed by a computer to perform a specific task.

Contents

A computer program is usually written by a computer programmer in a programming language. From the program in its human-readable form of source code, a compiler or assembler 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 collection of computer programs, libraries, and related data are referred to as software. Computer programs may be categorized along functional lines, such as application software and system software. The underlying method used for some calculation or manipulation is known as an algorithm. The way data is organized is referred to data structures.

History

Code-breaking algorithms have existed for centuries. In the 9th century, the Arab mathematician Al-Kindi described a cryptographic algorithm for deciphering encrypted code, in A Manuscript On Deciphering Cryptographic Messages. He gave the first description of cryptanalysis by frequency analysis, the earliest code-breaking algorithm. [2]

Early programmable machines

The earliest programmable machines preceded the invention of the digital computer. As early as the 9th century, a programmable music sequencer was invented by the Persian Banu Musa brothers, who described an automated mechanical flute player in the Book of Ingenious Devices . [3] [4] In 1206, the Arab engineer Al-Jazari invented a programmable drum machine where musical mechanical automata could be made to play different rhythms and drum patterns. [5] In 1801, Joseph-Marie Jacquard devised a loom that would weave a pattern by following a series of perforated cards. Patterns could be woven and repeated by arranging the cards. [6]

Analytical Engine

Lovelace's diagram from Note G, the first published computer algorithm Diagram for the computation of Bernoulli numbers.jpg
Lovelace's diagram from Note G, the first published computer algorithm

In 1837, Charles Babbage was inspired by Jacquard's loom to attempt to build the Analytical Engine. [6] The names of the components of the calculating device were borrowed from the textile industry. In the textile industry, yarn was brought from the store to be milled. The device would have had a "store"—memory to hold 1,000 numbers of 40 decimal digits each. Numbers from the "store" would then have then been transferred to the "mill" (analogous to the CPU of a modern machine), for processing. A "thread" is the execution of programmed instructions by the device. It was programmed using two sets of perforated cards—one to direct the operation and the other for the input variables. [6] [7] However, after more than 17,000 pounds of the British government's money, the thousands of cogged wheels and gears never fully worked together. [8]

During a nine-month period in 1842–43, Ada Lovelace translated the memoir of Italian mathematician Luigi Menabrea. The memoir covered the Analytical Engine. The translation contained Note G which completely detailed a method for calculating Bernoulli numbers using the Analytical Engine. This note is recognized by some historians as the world's first written computer program. [9]

Universal Turing machine

In 1936, Alan Turing introduced the Universal Turing machine—a theoretical device that can model every computation that can be performed on a Turing complete computing machine. [10] It is a finite-state machine that has an infinitely long read/write tape. The machine can move the tape back and forth, changing its contents as it performs an algorithm. The machine starts in the initial state, goes through a sequence of steps, and halts when it encounters the halt state. [11] This machine 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 the von Neumann architecture name. [12]

Early programmable computers

The Z3 computer, invented by Konrad Zuse (1941) in Germany, was a digital and programmable computer. [13] A digital computer uses electricity as the calculating component. The Z3 contained 2,400 relays to create the circuits. The circuits provided a binary, floating-point, nine-instruction computer. Programming the Z3 was through a specially designed keyboard and punched tape.

The Electronic Numerical Integrator And Computer (Fall 1945) was a Turing complete, general-purpose computer that used 17,468 vacuum tubes to create the circuits. At its core, it was a series of Pascalines wired together. [14] Its 40 units weighed 30 tons, occupied 1,800 square feet (167 m2), and consumed $650 per hour (in 1940s currency) in electricity when idle. [14] It had 20 base-10 accumulators. Programming the ENIAC took up to two months. [14] Three function tables were on wheels and needed to be rolled to fixed function panels. Function tables were connected to function panels using heavy black cables. Each function table had 728 rotating knobs. Programming the ENIAC also involved setting some of the 3,000 switches. Debugging a program took a week. [14] The programmers of the ENIAC were women who were known collectively as the "ENIAC girls" [15] and included Jean Jennings Bartik, Betty Holberton, Marlyn Wescoff, Kathleen McNulty, Ruth Teitelbaum, and Frances Spence. [16]

The ENIAC featured parallel operations. Different sets of accumulators could simultaneously work on different algorithms. It used punched card machines for input and output, and it was controlled with a clock signal. It ran for eight years, calculating hydrogen bomb parameters, predicting weather patterns, and producing firing tables to aim artillery guns.

"hello, world" computer program by Brian Kernighan (1978) Hello World Brian Kernighan 1974.jpg
"hello, world" computer program by Brian Kernighan (1978)

The Manchester Baby (June 1948) was a stored-program computer. [17] Programming transitioned away from moving cables and setting dials; instead, a computer program was stored in memory as numbers. Only three bits of memory were available to store each instruction, so it was limited to eight instructions. 32 switches were available for programming.

Later computers

Switches for manual input on a Data General Nova 3, manufactured in the mid-1970s Dg-nova3.jpg
Switches for manual input on a Data General Nova 3, manufactured in the mid-1970s

Computers manufactured until the 1970s had front-panel switches for programming. 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 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. [18]

In 1961, the Burroughs B5000 was built specifically to be programmed in the ALGOL 60 language. The hardware featured circuits to ease the compile phase. [19]

In 1964, the IBM System/360 was a line of six computers each having the same instruction set architecture. The Model 30 was the smallest and least expensive. Customers could upgrade and retain the same application software. [20] Each System/360 model featured multiprogramming. With operating system support, multiple programs could be in memory at once. When one was waiting for input/output, another could compute. Each model also could emulate other computers. Customers could upgrade to the System/360 and retain their IBM 7094 or IBM 1401 application software. [20]

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

A computer program written in the imperative programming style Object-Oriented-Programming-Methods-And-Classes-with-Inheritance.png
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 languages

Imperative programming languages specify a sequential algorithm using declarations, expressions, and statements: [21]

  • 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. [22]

Declarative languages

Declarative programming languages describe what computation should be performed and not how to compute it. Declarative programs omit the control flow and are considered sets of instructions. 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. [22] 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. [23] 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.

Compilation and 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 image by a compiler or assembler, 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. [24] 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.

Some compiled and assembled object programs need to be combined as modules with a linker utility in order to produce an executable program.

Interpreters are used to execute source code from a programming language line-by-line. The interpreter decodes each statement and performs its behavior. One advantage of interpreters is that they can easily be extended to 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 just before execution. For example, the Java virtual machine Hotspot contains a Just In Time Compiler which selectively compiles Java bytecode into machine code – but only code which Hotspot predicts is likely to be used many times.

Either compiled or interpreted programs might be executed in a batch process without human interaction.

Scripting languages are often used to create batch processes. 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, Java is thought of as an interpreted language and C a compiled language, despite the existence of Java compilers and C interpreters.

Storage and execution

In the 1950s, computer programs were stored on perforated paper tape Papertape3.jpg
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. [25] Termination is either by normal self-termination, by user intervention, or by error – software or hardware error.

Simultaneous execution

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. [26] Within hardware, modern day multiprocessor computers or computers with multicore processors may run multiple programs. [27]

Self-modifying 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 machine code, assembly language, Lisp, C, COBOL, PL/1, and Prolog.

Functional categories

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. [28] The purpose of the operating system is to provide an environment in which application software executes in a convenient and efficient manner. [28] 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

Example of an app: GCalctool, a software calculator Gcalctool-scientific.png
Example of an app: GCalctool, a software calculator

There are many types of application software:

Utility programs

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

Operating system

An operating system is the low-level software that supports a computer's basic functions, such as scheduling tasks and controlling peripherals. [28]

In the 1950s, the programmer, who was also the operator, would write a program and run it. After the program finished executing, the output may have been printed, or it may have been punched onto paper tape or cards for later processing. [18] More often than not the program did not work. The programmer then looked at the console lights and fiddled with the console switches. If less fortunate, a memory printout was made for further study. In the 1960s, programmers reduced the amount of wasted time by automating the operator's job. A program called an operating system was kept in the computer at all times. [29]

Originally, operating systems were programmed in assembly; however, modern operating systems are typically written in C.

Boot program

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. [30] Following the initialization process, this initial computer program loads the operating system and sets the program counter to begin normal operations.

Embedded programs

The microcontroller on the right of this USB flash drive is controlled with embedded firmware. USB flash drive.JPG
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. [29]

Microcode programs

Microcode programs control some central processing units and some other hardware. This code moves data between the registers, buses, arithmetic logic units, and other functional units in the CPU. Unlike conventional programs, microcode is not usually written by, or even visible to, the end users of systems, and is usually provided by the manufacturer, and is considered internal to the device.

See also

Related Research Articles

Assembly language Low-level programming language

In computer programming, assembly language, sometimes abbreviated asm, is any low-level programming language in which there is a very strong correspondence between the instructions in the language and the architecture's machine code instructions. Because assembly depends on the machine code instructions, every assembly language is designed for exactly one specific computer architecture. Assembly language may also be called symbolic machine code.

Software Non-tangible executable component of a computer

Software is a collection of instructions and data that tell a computer how to work. This is in contrast to physical hardware, from which the system is built and actually performs the work. In computer science and software engineering, computer software is all information processed by computer systems, including programs and data. Computer software includes computer programs, libraries and related non-executable data, such as online documentation or digital media. Computer hardware and software require each other and neither can be realistically used on its own.

Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: analysis, generating algorithms, profiling algorithms' accuracy and resource consumption, and the implementation of algorithms in a chosen programming language. The source code of a program is written in one or more languages that are intelligible to programmers, rather than machine code, which is directly executed by the central processing unit. The purpose of programming is to find a sequence of instructions that will automate the performance of a task on a computer, often for solving a given problem. Proficient programming thus often requires expertise in several different subjects, including knowledge of the application domain, specialized algorithms, and formal logic.

In computing, a compiler is a computer program that translates computer code written in one programming language into another language. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language to create an executable program.

Forth is a procedural, stack-based programming language and interactive environment designed by Charles H. "Chuck" Moore and first used by other programmers in 1970. Although not an acronym, the language's name in its early years was often spelled in all capital letters as FORTH, but Forth is more common.

Java virtual machine Virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

Machine code Set of instructions executed directly by a computers central processing unit (CPU)

In computer programming, machine code is a low-level programming language, consisting of machine language instructions, used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very specific task, such as a load, a store, a jump, or an arithmetic logic unit (ALU) operation on one or more units of data in the CPU's registers or memory.

Prolog is a logic programming language associated with artificial intelligence and computational linguistics.

In computing, source code is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source code. The source code is often transformed by an assembler or compiler into binary machine code that can be executed by the computer. The machine code might then be stored for execution at a later time. Alternatively, source code may be interpreted and thus immediately executed.

In computing, a virtual machine (VM) is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination.

Interpreter (computing) Program that executes source code without a separate compilation step

In computer science, an interpreter is a translator that repeatedly reads instructions and translates them to machine code. It then executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interpreter generally uses one of the following strategies for program execution:

  1. Parse the source code and perform its behavior directly;
  2. Translate source code into some efficient intermediate representation or object code and immediately execute this;
  3. Explicitly execute stored precompiled code made by a compiler which is part of the interpreter system.

In software engineering, porting is the process of adapting software for the purpose of achieving some form of execution in a computing environment that is different from the one that a given program was originally designed for. The term is also used when software/hardware is changed to make them usable in different environments.

Source-code compatibility (source-compatible) means that a program can run on computers, independently of binary-code compatibility and that the source code is needed for portability.

A programming tool or software development tool is a computer program that software developers use to create, debug, maintain, or otherwise support other programs and applications. The term usually refers to relatively simple programs, that can be combined together to accomplish a task, much as one might use multiple hands to fix a physical object. The most basic tools are a source code editor and a compiler or interpreter, which are used ubiquitously and continuously. Other tools are used more or less depending on the language, development methodology, and individual engineer, often used for a discrete task, like a debugger or profiler. Tools may be discrete programs, executed separately – often from the command line – or may be parts of a single large program, called an integrated development environment (IDE). In many cases, particularly for simpler use, simple ad hoc techniques are used instead of a tool, such as print debugging instead of using a debugger, manual timing instead of a profiler, or tracking bugs in a text file or spreadsheet instead of a bug tracking system.

Execution in computer and software engineering is the process by which a computer or virtual machine reads and acts on the instructions of a computer program. Each instruction of a program is a description of a particular action which must be carried out, in order for a specific problem to be solved. As the executing machine follows the instructions, specific effects are produced in accordance with the semantics of those instructions.

Breakpoint

In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. It is also sometimes simply referred to as a pause.

In computer science, the term automatic programming identifies a type of computer programming in which some mechanism generates a computer program to allow human programmers to write the code at a higher abstraction level.

A2 is a modular, object-oriented operating system, with some unconventional features, including automatic garbage-collected memory management, and a zooming user interface. It was developed originally at ETH Zurich in 2002. It is free and open-source software under a BSD-like license.

Computer Automatic general-purpose device for performing arithmetic or logical operations

A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as programs. These programs enable computers to perform a wide range of tasks. A computer system is a "complete" computer that includes the hardware, operating system, and peripheral equipment needed and used for "full" operation. This term may also refer to a group of computers that are linked and function together, such as a computer network or computer cluster.

Software is a set of programmed instructions stored in the memory of stored-program digital computers for execution by the processor. Software is a recent development in human history, and it is fundamental to the Information Age.

References

  1. Rochkind, Marc J. (2004). Advanced Unix Programming, Second Edition. Addison-Wesley. p. 1.1.2.
  2. Dooley, John F. (2013). A Brief History of Cryptology and Cryptographic Algorithms. Springer Science & Business Media. pp. 12–3. ISBN   9783319016283.
  3. Koetsier, Teun (2001), "On the prehistory of programmable machines: musical automata, looms, calculators", Mechanism and Machine Theory, Elsevier, 36 (5): 589–603, doi:10.1016/S0094-114X(01)00005-2.
  4. Kapur, Ajay; Carnegie, Dale; Murphy, Jim; Long, Jason (2017). "Loudspeakers Optional: A history of non-loudspeaker-based electroacoustic music". Organised Sound . Cambridge University Press. 22 (2): 195–205. doi: 10.1017/S1355771817000103 . ISSN   1355-7718.
  5. Noel Sharkey (2007), A 13th Century Programmable Robot, University of Sheffield
  6. 1 2 3 McCartney, Scott (1999). ENIAC – The Triumphs and Tragedies of the World's First Computer. Walker and Company. p.  16. ISBN   978-0-8027-1348-3.
  7. Bromley, Allan G. (1998). "Charles Babbage's Analytical Engine, 1838" (PDF). IEEE Annals of the History of Computing . 20 (4).
  8. Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p.  15. ISBN   978-0-13-854662-5.
  9. J. Fuegi; 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
  10. Rosen, Kenneth H. (1991). Discrete Mathematics and Its Applications. McGraw-Hill, Inc. p.  654. ISBN   978-0-07-053744-6.
  11. Linz, Peter (1990). An Introduction to Formal Languages and Automata. D. C. Heath and Company. p. 234. ISBN   978-0-669-17342-0.
  12. Davis, Martin (2000), Engines of Logic: Mathematicians and the origin of the Computer (1st ed.), New York NY: W. W. Norton & Company, ISBN   978-0-393-32229-3, (pb.)
  13. "History of Computing".
  14. 1 2 3 4 McCartney, Scott (1999). ENIAC – The Triumphs and Tragedies of the World's First Computer. Walker and Company. p.  102. ISBN   978-0-8027-1348-3.
  15. Frink, Brenda D. (1 June 2011). "Researcher reveals how "Computer Geeks" replaced "Computer Girls"". Gender News. Stanford University. Archived from the original on 12 March 2015. Retrieved 22 October 2018.
  16. Bartik, Jean Jennings (2013). Rickman, Jon; Todd, Kim D. (eds.). Pioneer programmer: Jean Jennings Bartik and the computer that changed the world. Truman State University Press.
  17. Enticknap, Nicholas (Summer 1998), "Computing's Golden Jubilee", Resurrection (20), ISSN   0958-7403, archived from the original on 9 January 2012, retrieved 19 April 2008
  18. 1 2 Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 6. ISBN   978-0-201-50480-4.
  19. Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p.  20. ISBN   978-0-13-854662-5.
  20. 1 2 Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition . Prentice Hall. p.  21. ISBN   978-0-13-854662-5.
  21. Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 75. ISBN   978-0-201-56885-1.
  22. 1 2 Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 213. ISBN   978-0-201-56885-1.
  23. Wilson, Leslie B. (1993). Comparative Programming Languages, Second Edition. Addison-Wesley. p. 244. ISBN   978-0-201-56885-1.
  24. "What is a Compiler?" . Retrieved 2012-01-10.
  25. Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 97. ISBN   978-0-201-50480-4.
  26. Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 100. ISBN   978-0-201-50480-4.
  27. Akhter, Shameem (2006). Multi-Core Programming. Richard Bowles (Intel Press). pp. 11–13. ISBN   978-0-9764832-4-3.
  28. 1 2 3 Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 1. ISBN   978-0-201-50480-4.
  29. 1 2 Tanenbaum, Andrew S. (1990). Structured Computer Organization, Third Edition. Prentice Hall. p.  11. ISBN   978-0-13-854662-5.
  30. Silberschatz, Abraham (1994). Operating System Concepts, Fourth Edition. Addison-Wesley. p. 30. ISBN   978-0-201-50480-4.

Further reading