低级、中级和高级语言之间有什么区别?

发布于 2024-09-14 17:23:58 字数 140 浏览 1 评论 0原文

我以前听说过这些描述语言的术语,比如 C 不完全是低级语言,C++ 是中级语言,Python 是高级语言。

我知道它必须与代码的编译方式以及编写方式有关。但是什么将语言定义为这三个类别之一呢?这些是绝对的类别,还是只是程序员用来相互描述语言的一般概念?

I've heard these terms thrown around describing languages before, like C is not quite a low-level language, C++ is a midlevel, and Python is a high-level language.

I understand that it has to do something with the way the code is compiled, and how it is written. But what defines a language into one of those three categories? Are these absolute categories, or just a general idea programmers use to describe languages to each other?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

↙厌世 2024-09-21 17:23:58

是的,它们只是一般术语。这与抽象有关,以及你与计算机实际执行的操作的接近程度有关。

以下是从非常低级到非常高级的编程语言列表:

  • 机器代码 可以可能被认为是最低级的编程语言。

  • 汇编语言处于告诉处理器要做什么的级别。仍然有一个到机器代码的转换步骤。

  • C 是汇编程序的一个步骤,因为你可以指定你想要做什么用稍微更抽象的术语来说,但你仍然相当接近金属。

  • C++ 可以完成 C 可以完成的所有操作,但增加了抽象事物的功能

  • Java/C# 在某种程度上与 C++ 做类似的事情,但没有机会做你在 C 中可以做的所有事情(比如 Java 中的指针操作 [谢谢乔!])。不过,它们具有垃圾收集功能,您必须在 C++ 中手动执行此操作。

  • Python/Ruby 甚至更高级别,让您忘记在 Java 或 C# 等内容中需要指定的许多细节。

  • SQL 甚至更高级别(它是声明性的)。只需说“给我表格中按年龄排序的所有项目”,它就会为您找出最有效的方法来执行此操作。

Yes, they're just general terms. It's to do with abstraction, and how close you are to what the computer's actually doing.

Here's a list of programming languages ranging from very low to very high level:

  • Machine Code could probably be considered the lowest level programming language.

  • Assembly language is at the level of telling the processor what to do. There is still a conversion step towards machine code.

  • C is a step up from assembler, because you get to specify what you want to do in slightly more abstract terms, but you're still fairly close to the metal.

  • C++ does everything that C can do but adds the capability to abstract things away into classes.

  • Java/C# do similar things to C++ in a way, but without the opportunity to do everything you can do in C (like pointer manipulation in Java's case [thanks Joe!]). They have garbage collection though, which you have to do manually in C++.

  • Python/Ruby are even higher level, and let you forget about a lot of the details that you would need to specify in something like Java or C#.

  • SQL is even higher level (it's declarative). Just say "Give me all the items in the table sorted by age" and it will work out the most efficient way to carry this out for you.

小猫一只 2024-09-21 17:23:58

低级别 = 较长的开发时间 + 非常快的可执行文件

高级别 = 较短的开发时间 + 较慢的可执行文件

中级别介于两者之间

low level = long development time + very fast executable file

high level = shorter development time + slower executable file

mid level is between the two

╰沐子 2024-09-21 17:23:58

极低级:机器代码

低级:汇编器、Forth

中级:C、C++、大多数系统编程语言

中/高级:D、Go、垃圾收集系统编程语言

高级:Java、C#、大多数解释性语言

甚至更高级别:Lisp 方言

最高级别:SQL、声明性编程语言

如果还有什么需要添加的,请告诉我。

Very low-level: Machine Code

Low level: Assembler, Forth

Mid level: C, C++, most system programming languages

Mid/High level: D, Go, garbage collected system programming languages

High level: Java, C#, most interpreted languages

Even Higher level: Lisp dialects

Highest level: SQL, declarative programming languages

If there is anything else to be added, tell me.

猛虎独行 2024-09-21 17:23:58

它们并不是绝对的。它们都与当时工业中使用的其他语言相关。例如,曾经有一段时间,装配被认为是中级。

“级别”本质上是衡量程序员对实际基于硬件的操作的抽象程度的衡量标准。在低级语言中,您可能必须关心实际的内存位置,而在高级语言中,您只需创建变量并让操作系统处理内存。

普通 CPU 处理 32 位或 64 位指令。以最简单的形式,将其视为连续的 32 个 1 和 0 - 这就是处理器实际解释和执行的内容。直接编写(机器代码)将是“最低级别”。

They aren't absolute. They are all relative to what other languages are being used in industry at the time. For example, there was a time when assembly was considered mid-level.

The 'level' is essentially a measure of how abstracted the programmer is from the actual hardware-based operations. In a low level language you might have to care about actual memory locations, whereas in a high-level you just create variables and let the OS handle memory.

A normal CPU processes either 32 or 64-bit instructions. In the simplest form, think of this as an 32 1's and 0's in a row - that's what the processor actually interprets and executes. Writing this directly (machine code) would be the 'lowest-level'.

魔法唧唧 2024-09-21 17:23:58

低等级意味着更接近机器,因此难度更大,威力也更强。你获得的级别越高,你与机器的距离就越远,你就越“像英语”,但你会失去很多控制机器细节的能力和功能。高级语言通常也倾向于为您提供更多保护,并采取更多预防措施和检查,而低级语言则信任您,可以这么说,让您自行承担风险。

Low level means closer to the machine, and therefore more difficult and more powerful. The higher level you get, the more removed from the machine and "English-like" you get, but you lose a lot of the power and functionality that comes with being able to control the minute details of the machine. Higher level languages also generally tend to protect you more and have much more precautions and checks in place, while lower level languages trust you, so to speak, and let you play around at your own risk.

木槿暧夏七纪年 2024-09-21 17:23:58

中级语言这个词我从未听说过。

“低”和“高”是指您在编程中与机器的“接近”程度。最低级别是机器(二进制)代码。接下来(仍然被认为是低级)是汇编程序。高级语言涉及更多的象征意义和结构,应该更接近人类通常的思维方式。 C(以及某种程度上的 C++)被誉为低级/高级混合体,因为它具有许多高级语言中的结构,但也具有低级语言但通常不在高级语言中的指令(例如移位) 。

The term mid-level language is one I've never heard.

"Low" and "High" refer to how "close" to the machine you are in your programming. The lowest level would be machine (binary) code. Next (and still considered low) is assembler. The higher level languages involve more symbolism and constructs that are supposed to be closer to how humans normally think. C (and somewhat C++) has a reputation as being somewhat a hybrid low/high level because it has many constructs that are in high level languages, but also has instructions (e.g. shifts) that are low level languages but often not in higher level languages.

荒人说梦 2024-09-21 17:23:58

从低到高,您可以对语言进行如下分类。

机器码 -->汇编语言 -->编译语言-->解释语言

请记住,这些定义并不是绝对的黑白定义,而是灰色阴影。这与其说是规则,不如说是指南。

将机器代码视为本机平台可以理解的一长串 1 和 0。将此视为您的基线...您可以拥有的最低“级别”。

汇编语言可以被认为是这一点的符号表示。我相信汇编代码指令和机器代码指令之间存在一对一的映射。这是你的低级语言。

例如,Java 和 C++ 都是编译语言,但许多人会认为 C++ 是比 Java 更低级的语言,因为它公开低级系统访问,而 Java 运行在受保护的环境(虚拟机)中。请记住,编译语言在执行之前会被编译(如果愿意的话,会转换为机器代码)。 C 也是一种编译语言,但被认为比 Java 和 C++ 级别低。

为了我们的利益,我们会说 C 和 C++ 是低级语言,因为它们提供(相对)很少的硬件抽象和直接内存管理。事实上,它们介于低端和中端之间,您很快就会看到。

我们将 Java 和 C# (.NET) 称为中级语言,因为它们具有自动内存管理(垃圾收集)、大量高级抽象(IE 对象...但 C++ 支持对象。您明白为什么规模被认为是松散定义?)

对于解释性语言,解释器驻留在内存中并直接读取源代码。这些是高级语言。 Python、Perl、Javascript 和 PHP 都是高级语言的示例。

From low to high, you can categorize the languages as follows.

Machine Code --> Assembly Language --> Compiled Language --> Interpreted Language

Remember that these aren't absolute black and white definitions, but rather shades of gray. This is more of a guideline than a rule.

Think of machine code as a long string of 1s and 0s understood by the native platform. Consider this your baseline... the lowest "level" you can have.

Assembly language could be considered a symbolic representation of this. I believe there is a 1 to 1 mapping between assembly code instructions and machine code instructions. This is your low level language.

Java and C++, for example, are both compiled languages, but many would consider C++ to be a lower level language than Java because it exposes low level system access, while Java runs in a protected environment (the virtual machine). Remember that a compiled language is compiled (converted, if you will) to machine code before execution. C is also a compiled language, but would be considered lower level than both Java and C++.

For our sake, we will say that C and C++ are low level languages because they offer (relatively) little abstraction from the hardware and direct memory management. In actuality, they fall somewhere between low and mid, as you will see soon enough.

We will call Java and C# (.NET) mid level languages because they have automatic memory management (garbage collection), plenty of high-level abstractions (IE objects... yet C++ supports objects. Do you see why the scale is considered to be loosely defined?)

With an interpreted language, the interpreter resides in memory and reads the source code directly. These are high level languages. Python, Perl, Javascript, and PHP are all examples of high level languages.

三生路 2024-09-21 17:23:58

高级语言:易于阅读,注重生产力,易于使用,并提供计算机/硬件细节的抽象。
例如 – 除汇编语言和其他语言之外的所有编程语言机器代码)

低级语言:不可读/不可理解,对系统提供更直接的控制,更难使用,并且很少或根本不提供对计算机的抽象。
例如 – 汇编语言、机器代码(最低级别)。

中级语言:将 MLL 视为在上述两者之间提供桥梁的语言,并且通常 C\C++ 被标记为中级语言,因为它们提供以下功能: HLL 和 LLL。

  • 高级功能:相对容易理解的语法、函数、数据结构。
  • 低级功能 - 通过指针和直接操作内存地址提供对内存管理的控制。

High Level Language: Easily readable, focus on productivity, easy to work with and offers abstraction from the details of computer/hardware.
e.g. – Every programming language except Assembly language & Machine code)

Low Level Language: Non-readable/understandable, provide more direct control over the system, harder to work with, and offer little or no abstraction from the computer.
e.g. – Assembly language, Machine code (lowest level).

Middle Level Language: Consider MLL, as the language which provides a bridge between above two, and often C\C++ tagged as a middle level language it is because they offer features of HLL and LLL.

  • High level feature: Relatively understandable syntax, function, data structures.
  • Low level feature – provide control over memory management through pointers and direct manipulation of memory address.
—━☆沉默づ 2024-09-21 17:23:58

C 是一种中级语言,因为我们可以使用汇编语言中的代码。

唯一的细微差别是指针使其功能强大(如果在 C 中删除指针,那么它将被视为低级语言)。它的可移植特性使其成为中级语言,因此我们可以说它是一种中级语言。

C is a midlevel language, because we can use code in assembly language.

The only slight difference is pointers make it powerful (if pointer remove in C then it be will considered a low-level language). Its portable features makes it midlevel, so we can say it is a midlevel language.

美人骨 2024-09-21 17:23:58

这都是相对的......“级别”反映了抽象的程度。

It is all relative... The "level" reflect the amount of abstraction.

菩提树下叶撕阳。 2024-09-21 17:23:58

一旦添加了编程语言的一系列级别,您就可以在定义中添加细微差别。

显然,机器代码和汇编是依赖于机器的。 C 和 C++ 理论上是独立于机器的,但实际上并不通用。在 C 中,需要考虑之类的事情,并且您始终可以通过指针和单个初始化变量来管理 C 和 C++ 的 C 子集中的堆栈 - 如果您足够疯狂的话——这样(x86)RSP寄存器(堆栈指针)永远不会被使用。所以C,是的,它是中级。其他的都是高级的,有些是超高级的。

Once you add a spectrum of levels of a programming language you add nuance to the definition.

Clearly machine code and assembly are machine-dependent. C and C++ in theory are machine-independent, but in truth that is not universal. In C, things like alignment need to be taken into account and you can always manage the stack in C and in the C subset of C++) via a pointer and a single initialised variable—if you are crazy enough—so that (x86) the RSP register (stack pointer) is never used. So C, yes it is midlevel. Everything else is high-level and some super high-level.

各自安好 2024-09-21 17:23:58

低级语言非常接近机器语言,可能是二进制或 RTL。它很难编写并且执行起来非常快。它可以与硬件交互,高级编程语言非常容易编写,而且可以在编译后执行。

Low-level languages are very close to machine language that may be binary or RTL. It is hard to write and very quick to execute. It can interact with the hardware and a high-level programming language is very easy to write, but it can be executed after compilation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文