Computer Programming 简明教程

Computer Programming - Environment

尽管环境设置不是任何编程语言的元素,但在开始编写程序之前,它是必须遵循的第一步。

Though Environment Setup is not an element of any Programming Language, it is the first step to be followed before setting on to write a program.

当我们说环境设置时,它仅仅表示一个基础,我们可以在其基础上进行编程。因此,我们需要具备所需的软件设置,即在我们的电脑上安装将用于编写计算机程序、编译和执行它们的软件。例如,如果您需要浏览互联网,那么您需要在您的机器上进行下列设置:

When we say Environment Setup, it simply implies a base on top of which we can do our programming. Thus, we need to have the required software setup, i.e., installation on our PC which will be used to write computer programs, compile, and execute them. For example, if you need to browse Internet, then you need the following setup on your machine −

  1. A working Internet connection to connect to the Internet

  2. A Web browser such as Internet Explorer, Chrome, Safari, etc.

如果您是 PC 用户,那么您会识别出以下屏幕截图,这是我们在浏览 tutorialspoint.com 时从 Internet Explorer 中获取的。

If you are a PC user, then you will recognize the following screenshot, which we have taken from the Internet Explorer while browsing tutorialspoint.com.

internet explorer

同样,您还需要以下设置才能开始使用任何编程语言进行编程。

Similarly, you will need the following setup to start with programming using any programming language.

  1. A text editor to create computer programs.

  2. A compiler to compile the programs into binary format.

  3. An interpreter to execute the programs directly.

如果您没有足够的计算机知识,您将无法设置上述任何软件。因此,我们建议您向周围的任何技术人员寻求帮助,以在您的机器上设置编程环境,您可以从该环境开始。但对于您来说,了解这些项目是什么非常重要。

In case you don’t have sufficient exposure to computers, you will not be able to set up either of these software. So, we suggest you take the help from any technical person around you to set up the programming environment on your machine from where you can start. But for you, it is important to understand what these items are.

Text Editor

文本编辑器是用于编写计算机程序的软件。您的 Windows 电脑必须拥有一个记事本,该记事本可用于编写程序。您可以按以下步骤启动它:

A text editor is a software that is used to write computer programs. Your Windows machine must have a Notepad, which can be used to type programs. You can launch it by following these steps −

Start Icon → All Programs → Accessories → Notepad → Mouse Click on Notepad

它将启动记事本,并显示以下窗口:

It will launch Notepad with the following window −

notepad

您可以使用此软件键入您的计算机程序并将其保存到任何位置的文件中。您可以下载并安装其他优秀的编辑器,如免费提供的 Notepad++

You can use this software to type your computer program and save it in a file at any location. You can download and install other good editors like Notepad++, which is freely available.

如果您是 Mac 用户,那么您将拥有 TextEdit ,或者可以安装其他商业编辑器,例如 BBEdit 来开始。

If you are a Mac user, then you will have TextEdit or you can install some other commercial editor like BBEdit to start with.

Compiler?

使用您最喜欢的编程语言编写计算机程序,并将其保存在一个名为程序文件文本文件中。

You write your computer program using your favorite programming language and save it in a text file called the program file.

现在,让我们尝试更详细地了解计算机如何理解您使用编程语言编写的程序。事实上,计算机无法直接理解您以文本格式给定的程序,所以我们需要将这个程序转换成计算机可以理解的二进制格式。

Now let us try to get a little more detail on how the computer understands a program written by you using a programming language. Actually, the computer cannot understand your program directly given in the text format, so we need to convert this program in a binary format, which can be understood by the computer.

从文本程序到二进制文件的转换是由另一个称为编译器的软件完成的,而这种从文本格式程序到二进制格式文件的转换过程称为程序编译。最后,您可以执行二进制文件以执行已编程的任务。

The conversion from text program to binary file is done by another software called Compiler and this process of conversion from text formatted program to binary format file is called program compilation. Finally, you can execute binary file to perform the programmed task.

我们不会深入了解编译器的详细信息和编译的不同阶段。

We are not going into the details of a compiler and the different phases of compilation.

以下流程图给出了该过程说明——

The following flow diagram gives an illustration of the process −

compiler

因此,如果您打算使用任何需要编译的语言编写程序,例如 C、C++、Java 和 Pascal 等,那么在开始编程之前,您需要安装它们的编译器。

So, if you are going to write your program in any such language, which needs compilation like C, C++, Java and Pascal, etc., then you will need to install their compilers before you start programming.

Interpreter

我们刚刚讨论了编译器和编译过程。如果您打算以编程语言编写程序,那么需要编译器将其编译成二进制格式,然后再执行。

We just discussed about compilers and the compilation process. Compilers are required in case you are going to write your program in a programming language that needs to be compiled into binary format before its execution.

还有其他编程语言,例如 Python、PHP 和 Perl,它们不需要编译成二进制格式,而解释器可以用来逐行读取此类程序,并在无需进一步转换的情况下直接执行它们。

There are other programming languages such as Python, PHP, and Perl, which do not need any compilation into binary format, rather an interpreter can be used to read such programs line by line and execute them directly without any further conversion.

interpreter

因此,如果您打算用 PHP、Python、Perl、Ruby 等编写程序,那么在开始编程之前,您需要安装它们的解释器。

So, if you are going to write your programs in PHP, Python, Perl, Ruby, etc., then you will need to install their interpreters before you start programming.

Online Compilation

如果您无法在计算机上设置任何编辑器、编译器或解释器,那么 tutorialspoint.com 提供了一个功能,只需单击一下即可轻松编译和运行几乎所有程序。

If you are not able to set up any editor, compiler, or interpreter on your machine, then tutorialspoint.com provides a facility to compile and run almost all the programs online with an ease of a single click.

所以不要担心,让我们继续进行,按照简单易行的步骤,体验成为一名计算机程序员的激动人心的旅程。

So do not worry and let’s proceed further to have a thrilling experience to become a computer programmer in simple and easy steps.