编程语言世代
计算机是数字机器。它只能理解 ON 或 OFF 或 1 或 0 的电信号。但是我们如何与这个数字机器进行通信呢?就像我们相互交流有多种语言一样(例如,英语、印地语、泰米尔语、古吉拉特语等)。但是计算机无法理解我们的语言。我们可以通过机器语言、汇编语言、C、C++、 Java等多种语言与计算机进行交互。
基本条款:
Computer language: A computer language is a way to give instructions to a computer to perform desired tasks.
Program: A set of instruction written in a specific sequence for the computer to accomplish a given task.
Machine language: The binary medium of communication with a computer through a designed set of instruction specific to each computer.
Assembly language: A medium of communication with a computer in which programs are written in mnemonics. An assembly language is specific to a given computer.
Mnemonic: A combination of letter to suggest the operation of an instruction. E.g, ADD, HALT etc.
计算机语言的类别
有两种类型的计算机语言:
低级语言:这些语言以计算机硬件易于理解的方式向计算机发出指令。这些语言对计算机来说更容易理解,但对人类来说却难以理解。这种语言依赖于机器或特定于给定的计算机。两种低级语言是机器语言和汇编语言。
高级语言:这些语言是用类似英语的语言编写的。因此,这些对于人类来说更容易理解,但对于计算机来说却难以理解。它们可以使用翻译器在机器上执行。这种语言与机器无关。有许多高级语言,例如 C. C++。 Java、COBOL、 PHP等
计算机语言的演变
计算机在使用电力时可以理解电信号方面的指令。电信号要么是 ON 要么是 OFF,或者我们可以说 1 代表 ON 或 0 代表 OFF。当我们发明计算机时,首先以 1 和 0 的形式给出指令。这种语言形式被称为机器语言或第一代语言。
第一代语言:
首先,以 1 和 0 的形式向计算机提供指令。这种语言称为机器语言或第一代语言。计算机无需任何转换即可直接理解它。这种语言也称为机器语言或二进制语言。因为二进制语言只有两个符号 1 和 0。
第二代语言:
机器语言只有 1 和 0,其中错误查找和纠正非常困难。所以我们必须开发第二代语言。也称为汇编语言。
在这种语言中,指令被一些称为助记符的编码术语取代。这样它就变得更容易阅读、理解和纠正了。计算机只能理解和处理机器代码。所以汇编语言需要一个叫做Assembler的特殊软件将助记符转换成机器语言。
第三代语言:
首先,两代语言对计算机来说相对更容易理解,但人类很难阅读、理解和编码。因此,出现了像编程语言一样的英语来向计算机发出指令。这些语言被称为高级语言,因为它们更容易被人类理解。
C、C++、 Java、COBOL Pascal 等是一些高级语言。
第四代语言:
第三代语言需要详细的程序,而第四代语言只需要“我们想要从代码中得到什么”而不是“怎么做”。即程序。这些语言类似于主要用于数据库编程的人类语言中的语句。例如Python、Ruby、SQL、MatLab。
SQL-Structured Query Language 就是这样一种语言,例如,您只需编写 SELECT ALL department Name FROM EmployeeTable 即可获取所有部门名称:无需详细程序。
第五代语言:
第五代语言更侧重于人工智能的实现。这些具有开发程序的可视化工具。 Prolog、OPSS Mercury 等是一些 SGLS。例如 Prolog、OPS5、Mecury 等。
示例问题
问题一:讨论机器语言的特点。
回答:
(i) Code is written in binary language.
(ii) Binary codes for machine instructions can run directly on hardware.
(iii) No extra tool required for code conversion.
(iv) Machine language depends upon the processor of a computer. So, for a different processor, machine language codes will differ.
问题2:讨论汇编语言的特点。
回答:
(i) Uses mnemonic codes to represent machine instructions.
(ii) Low-level language.
(iii) Cannot run directly on hardware requires Assembler software that converts it to machine code first.
(iv) Varies from one processor to another, i.e, different assembly codes for different processors.
问题 3:讨论高级语言的特征。
回答:
(i) Use English like words.
(ii) Cannot run directly on computer hardware require a translator software to translate high-level instruction code to machine language code.
(ii) Easier to read and understand for us humans (near to humans hence High Level).
(iv) Require coding for the detailed procedure of how the task is to be done.
问题4:什么是语言翻译?
回答:
A language translator is software that translates a programming languages code to machine language code.
问题 5:什么是编译器?
回答:
This is a language translator which converts the entire program into machine code in one go. If there are errors in the program code, it gives the list of errors along with line numbers. The programmer can then correct the program and re-compile the program.
问题 6:什么是口译员?
回答:
This is a language translator which converts a program into machine code line by line. It will first convert the first code line, run it and then move to the second code line. It does not advance if there is an error in any line. We need to correct the code in that line so that interpreter will convert and run the line, and then move to the next line of code.
问题 7:编译器和解释器的区别。
回答:
Compiler InterpreterConvert the entire program in one go. Convert single instruction at a time. Error list is generated with line numbers after the full program is checked. Errors are generated for one instruction at a time. After compilation, full program runs. Code run line by line. The compiler no longer needs after compilation is done.
An interpreter is always needed.