Computer program
A computer program is a sequence or set of instructions written in a programming language that can be executed by a computer to perform a specific task. A program, together with the data it manipulates and its associated documentation, forms a software component. Programs are fundamental to all digital computing, ranging from simple embedded controllers to complex operating systems and distributed cloud applications. The process of creating a program is called programming, and the person who writes programs is a programmer.
Definition and scope
In formal terms, a computer program is a concrete implementation of an algorithm, expressed in a form that can be executed by a machine. It specifies a sequence of operations, often including arithmetic, logical, input/output, and control flow instructions. The boundary between programs and data can be fluid: a program is treated by the computer as instructions to be executed, while data is the information being processed. In von Neumann architecture, both instructions and data reside in the same memory, allowing programs to be modified or even generated by other programs.
The notion of a program extends beyond machine code. Source code written in a high-level language is not directly executable but is transformed into an executable form by a compiler, interpreter, or assembler. Thus, a program can exist in multiple representations: as human-readable source code, as assembly language, or as binary machine code. In modern computing, programs are often constructed from multiple modules and libraries that are linked together to form a complete executable image.
History
The earliest conceptual form of a program dates to the 19th century, when Ada Lovelace wrote what is often recognized as the first algorithm intended for processing by a machine, Charles Babbage’s Analytical Engine. Her notes contained a step-by-step sequence for computing Bernoulli numbers, representing the first published computer program.
In the 1930s and 1940s, the first electronic computers appeared. Programs were initially entered by setting switches, plugging cables, or feeding punched paper tape. The concept of the stored-program computer, where instructions are held in the same memory as data, was introduced by John von Neumann and others, leading to the design of machines such as the Manchester Baby and the EDVAC. This idea enabled the rapid loading and modification of programs without physical reconfiguration.
The development of assembly language in the 1950s replaced numeric machine codes with mnemonic symbols, and soon high-level languages like FORTRAN, COBOL, and Lisp emerged, abstracting away hardware details. With the rise of operating systems, programs could be managed as processes, and the creation of compilers and linkers allowed programs to become portable across different hardware. The personal computer revolution of the 1970s and 1980s made program creation accessible to a wide audience, while the internet era amplified the distribution of programs and introduced scripting languages, virtual machines, and just-in-time compilation.
Programming
Programming is the activity of designing and constructing an executable computer program to accomplish a specific computing outcome. It involves analysis, algorithm selection, coding in a chosen language, testing, and debugging. Modern programming often uses integrated development environments (IDEs) that provide editors, compilers, and debuggers in a unified interface.
Programs are written in programming languages, which are formal languages with a defined syntax and semantics. They range from low-level languages, such as C and assembly, that are close to hardware, to high-level languages like Python, Java, and JavaScript that emphasize readability and portability. A source program is typically transformed by a compiler into machine code, or executed line-by-line by an interpreter. Some languages, such as Java and C#, compile to an intermediate bytecode that is then executed by a virtual machine, achieving platform independence.
Programming paradigms influence how a program is structured. Common paradigms include imperative programming (specifying steps to change state), declarative programming (describing what result should be attained), functional programming (using pure functions and immutable data), and object-oriented programming (organizing code into objects with data and methods). Many languages support multiple paradigms.
Execution
For a program to run, it must be loaded into the computer’s memory and made available to the central processing unit (CPU). The operating system typically handles this loading, creating a process that contains the program’s machine code, allocated memory regions, and execution context. The CPU then performs a fetch–decode–execute cycle: it retrieves an instruction from memory, decodes what operation is required, executes it, and moves to the next instruction, possibly branching based on conditions.
Modern systems can execute many programs concurrently through multiprogramming and time-sharing. The operating system scheduler rapidly switches between processes, giving the illusion of parallelism. Threads allow a single program to have multiple execution streams sharing the same memory space. Execution may also be interrupted by events such as hardware signals or system calls, causing the program to transition into kernel mode and back.
Programs are distributed in executable files, which follow specific binary formats (e.g., ELF on Linux, PE on Windows, Mach-O on macOS). When a user launches a program, the loader reads the executable header, maps code and data into memory, resolves dynamic library references, and jumps to the entry point. For interpreted and bytecode languages, the runtime environment (e.g., a Python interpreter or a JVM) acts as the program that reads and executes the application’s instructions.
Classification
Computer programs can be categorized by their role, scope, and proximity to hardware:
- System programs provide services to other programs and manage hardware resources. Operating systems, device drivers, firmware, and utility programs such as file managers and disk formatters belong to this category. They are often written in low-level languages for efficiency and direct hardware access.
- Application programs perform specific tasks for users. Examples include word processors, web browsers, spreadsheet software, media players, and games. They rely on system software to interface with hardware and often feature graphical user interfaces.
- Middleware acts as an intermediary layer between system and application software, facilitating communication and data management. Database management systems, message queues, and application servers are typical middleware programs.
- Embedded programs run on dedicated hardware devices such as microcontrollers in automobiles, home appliances, and medical devices. They are typically stored in read-only memory and must meet real-time constraints.
- Scripts are programs written in scripting languages (e.g., shell, Perl, Python) that automate tasks, often interpreted and not compiled to standalone executables. They are heavily used for system administration, web development, and data processing.
- Malware is a program designed for harmful purposes, including viruses, worms, ransomware, and spyware. While undesired, they are still computer programs that exploit system vulnerabilities.
Storage and distribution
The source code of a program is kept in text files, while its executable form is stored as a binary file. During development, programmers use version control systems to track changes and collaborate. Executable programs can be distributed on physical media, downloaded from the internet, or deployed via app stores and package managers. The rise of cloud computing allows programs to be delivered as services (SaaS) where the executable runs on remote servers, accessible through web browsers or APIs.
Libraries and runtime components are often shared among programs. Static linking embeds library code directly into the executable, while dynamic linking loads shared libraries at load time or runtime, reducing duplication and permitting updates without recompilation. Containerization technologies package a program and its dependencies into a single portable unit, further abstracting execution from the surrounding environment.
Relationship to software and data
A program is often distinguished from the broader concept of software. Software encompasses collections of programs, associated libraries, configuration files, and documentation that work together to provide a complete product. For instance, a web browser application includes not only the executable browser program but also rendering engines, JavaScript interpreters, user interface resources, and help files.
Data is the input that a program processes and the output it produces. The boundary can blur when programs generate other programs (e.g., compilers producing machine code) or when data includes executable scripts. In some architectures, such as the Harvard architecture, program and data memories are physically separate, whereas in the von Neumann architecture they share the same storage, enabling self-modifying code and just-in-time compilation.
Legal protection and licensing
Computer programs are protected under intellectual property law, primarily through copyright, which treats source and object code as literary works. Many jurisdictions also allow patents on software-implemented inventions, provided they meet criteria of novelty and technical character, though the patentability of software remains a contentious area of law.
Programs are distributed under specific licenses that define allowed usage, modification, and redistribution. Proprietary software is released under restrictive licenses that keep the source code confidential and limit user rights. Free and open-source software (FOSS) licenses, such as the GNU General Public License (GPL), the MIT License, and the Apache License, grant users freedoms to study, modify, and share the program. Copyleft licenses require that derivative works remain open under the same terms. Dual licensing, shareware, and subscription models represent hybrid distribution strategies. Enforcement of these legal aspects involves both technological measures (e.g., digital rights management) and legal remedies against unauthorized copying or cracking.
你感兴趣的百科
东京
东京(日语:東京,罗马音:Tōkyō),正式名称为东京都,是日本的首都及人口最多的一级行政区(都道府县)。东京位于本州岛东部、东京湾顶端,是日本的政治、经济与文化中心,日本中央政府与皇宫(皇居)均设于此。东京都行政区域内人口约1400万,以...
Gemini
Gemini(意为“双子座”)是谷歌旗下人工智能研究机构谷歌深度思维开发的一系列多模态大语言模型,于2023年12月正式发布。作为谷歌早期PaLM与LaMDA等语言模型的继任者,Gemini在设计之初即被定位为原生多模态模型,能够处理并生成...
Anthropic
Anthropic(中文名称常译作“安斯罗皮克”或音译“人类技术公司”,一般直接使用英文名称)是一家总部位于美国加利福尼亚州旧金山的人工智能安全与研究公司。该公司由前OpenAI研究人员于2021年创立,联合创始人包括达里奥·阿莫迪与达妮埃...
OpenAI
OpenAI(开放人工智能公司)是一家总部位于美国加利福尼亚州旧金山的人工智能研究与发展公司。该公司成立于2015年12月,最初为非营利研究实验室,宣称的使命是确保人工通用智能(AGI)——即设想中能够匹配或超越人类能力的智能系统——造福全...
评论区 (0)
还没有评论,来抢沙发!