与原生code,该机code和汇编code的区别是什么?该机、区别、code

2023-09-02 11:49:54 作者:蓦然回首,那二逼还没走

我感到困惑机code和本土code。它们之间的区别是什么? 这些是相同或不好吗?

I'm confused about machine code and native code. What is the difference between these? Are these the same or not please?

推荐答案

该条款确实有点混乱,因为它们有时不一致使用。

The terms are indeed a bit confusing, because they are sometimes used inconsistently.

机code:这是最明确定义的。这是使用它的处理器(金属,做实际工作的物理块)理解和执行直接针对字节code说明code。所有其他code必须转化或转化成的机code 的在你的机器可以执行它。

Machine code: This is the most well-defined one. It is code that uses the byte-code instructions which your processor (the physical piece of metal that does the actual work) understands and executes directly. All other code must be translated or transformed into machine code before your machine can execute it.

本机code::此术语有时用在机code 的(见上图)是指地方。然而,它有时也被用来指的非托管code 的(见下文)。

Native code: This term is sometimes used in places where machine code (see above) is meant. However, it is also sometimes used to mean unmanaged code (see below).

未管理code 和管理code: 未管理的code指的是code写的编程语言如C或C ++,它直接编译成的机code 的。它与对比的管理code 的,它是用C#,VB.NET,Java或相似的,在虚拟环境中运行(如.NET或JavaVM的),这样​​的模拟在软件的处理器。的主要区别在于,管理code 的管理的资源(主要的存储器分配)为您通过采用垃圾收集和通过保持对对象的引用不透明。 未管理code 的是需要你手动分配和取消分配内存,有时会造成内存泄漏(当你忘记取消分配),有时段错误的那种code(当你去分配太快)。 未管理的也通常意味着没有运行时检查常见的错误,如空指针引用或数组边界溢出。

Unmanaged code and managed code: Unmanaged code refers to code written in a programming language such as C or C++, which is compiled directly into machine code. It contrasts with managed code, which is written in C#, VB.NET, Java, or similar, and executed in a virtual environment (such as .NET or the JavaVM) which kind of "simulates" a processor in software. The main difference is that managed code "manages" the resources (mostly the memory allocation) for you by employing garbage collection and by keeping references to objects opaque. Unmanaged code is the kind of code that requires you to manually allocate and de-allocate memory, sometimes causing memory leaks (when you forget to de-allocate) and sometimes segmentation faults (when you de-allocate too soon). Unmanaged also usually implies there are no run-time checks for common errors such as null-pointer dereferencing or array bounds overflow.

从严格意义上讲,大部分动态类型语言 - 例如Perl,Python和PHP和Ruby - 也的管理code 的。但是,他们没有通常被描述为这样的,这表明的管理code 的是有些一个营销术语的真正的大,严重的,商业编程环境(.NET和Java)实际。

Strictly speaking, most dynamically-typed languages — such as Perl, Python, PHP and Ruby — are also managed code. However, they are not commonly described as such, which shows that managed code is actually somewhat of a marketing term for the really big, serious, commercial programming environments (.NET and Java).

大会code::该术语通常指的是那种源$ C ​​$ C的人写的,当他们真正想要写字节级code。一个的组装的是一个程序,打开该源$ C ​​$ C到真正的字节级code。它不是一个的编译的,因为变换是1比1。然而,长期是不明确的,以什么用一种针对字节code:它可以被托管或非托管。如果它是不受管理的,所产生的字节级code是的机code 的。如果是管理,这会导致使用背后的场景通过一个虚拟的环境,如.NET中的字节级code。管理code(例如C#,Java的)被编译成这个特殊的字节级code语言,它在.NET的情况下,被称为的公共中间语言(CIL)的和Java是所谓的的Java字节级code 的。通常有没有必要为了共同的程序员访问此code或用这种语言直接写,但是当人们这样做,他们往往把它称为的组装code 的,因为它们使用一个的组装的把它变成针对字节code。

Assembly code: This term generally refers to the kind of source code people write when they really want to write byte-code. An assembler is a program that turns this source code into real byte-code. It is not a compiler because the transformation is 1-to-1. However, the term is ambiguous as to what kind of byte-code is used: it could be managed or unmanaged. If it is unmanaged, the resulting byte-code is machine code. If it is managed, it results in the byte-code used behind-the-scenes by a virtual environment such as .NET. Managed code (e.g. C#, Java) is compiled into this special byte-code language, which in the case of .NET is called Common Intermediate Language (CIL) and in Java is called Java byte-code. There is usually little need for the common programmer to access this code or to write in this language directly, but when people do, they often refer to it as assembly code because they use an assembler to turn it into byte-code.