什么是编程?¶
编程(Programming)是采用算法并将其编码为符号(一种编程语言)以便计算机可以执行的过程。 尽管存在许多编程语言和许多不同类型的计算机,但重要的第一步是需要有解决方案。 没有算法就不可能有程序。
计算机科学不是编程的研究。 然而,编程是计算机科学家工作的重要组成部分。 编程通常是我们为解决方案创建表示的方式。 因此,这种语言表示及其创建过程成为该学科的基本组成部分。
算法根据表示问题实例所需的数据以及产生预期结果所需的步骤集来描述问题的解决方案。 编程语言必须提供一种表示过程和数据的符号方式。 为此,语言提供了控制结构(control constructs)和数据类型(data types)。
控制结构允许以方便而明确的方式表示算法步骤。 至少,算法需要执行顺序处理、决策选择和重复控制迭代的结构。 只要语言提供了这些基本语句,就可以用于算法表示。
计算机中的所有数据项都表示为二进制数字串。 为了赋予这些字符串含义,我们需要数据类型(data types)。 数据类型提供了对这种二进制数据的解释,以便我们可以用对要解决的问题有意义的术语来思考数据。 这些低级内置数据类型(有时称为 原始(primitive) 数据类型)为算法开发提供了构建块。
例如,大多数编程语言都提供整数数据类型。 计算机内存中的二进制数字串可以解释为整数,并具有我们通常与整数相关的典型含义(例如 23、654 和 -19)。 此外,数据类型还提供了数据项可以参与的运算的描述。对于整数,加法、减法和乘法等运算很常见。 我们期望数字类型的数据可以参与这些算术运算。
我们经常遇到的困难是问题及其解决方案非常复杂。 这些简单的、语言提供的结构和数据类型虽然足以表示复杂的解决方案,但在我们解决问题的过程中通常处于劣势。 我们需要一些方法来控制这种复杂性并协助创建解决方案。
原文
What Is Programming?
Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer. Although many programming languages and many different types of computers exist, the important first step is the need to have the solution. Without an algorithm there can be no program.
Computer science is not the study of programming. Programming, however, is an important part of what a computer scientist does. Programming is often the way that we create a representation for our solutions. Therefore, this language representation and the process of creating it becomes a fundamental part of the discipline.
Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and the set of steps necessary to produce the intended result. Programming languages must provide a notational way to represent both the process and the data. To this end, languages provide control constructs and data types.
Control constructs allow algorithmic steps to be represented in a convenient yet unambiguous way. At a minimum, algorithms require constructs that perform sequential processing, selection for decision-making, and iteration for repetitive control. As long as the language provides these basic statements, it can be used for algorithm representation.
All data items in the computer are represented as strings of binary digits. In order to give these strings meaning, we need to have data types. Data types provide an interpretation for this binary data so that we can think about the data in terms that make sense with respect to the problem being solved. These low-level, built-in data types (sometimes called the primitive data types) provide the building blocks for algorithm development.
For example, most programming languages provide a data type for integers. Strings of binary digits in the computer’s memory can be interpreted as integers and given the typical meanings that we commonly associate with integers (e.g. 23, 654, and -19). In addition, a data type also provides a description of the operations that the data items can participate in. With integers, operations such as addition, subtraction, and multiplication are common. We have come to expect that numeric types of data can participate in these arithmetic operations.
The difficulty that often arises for us is the fact that problems and their solutions are very complex. These simple, language-provided constructs and data types, although certainly sufficient to represent complex solutions, are typically at a disadvantage as we work through the problem-solving process. We need ways to control this complexity and assist with the creation of solutions.
创建日期: 2023年10月10日