MSIL和Java字节码的区别?

时间:2022-12-22 17:21:15

I'm new to .Net and I'm trying to understand the basics first. What is the difference between MSIL and Java bytecode?

我是。net的新手,我想先了解一下基础知识。MSIL和Java字节码的区别是什么?

8 个解决方案

#1


67  

First off let me say that I don't think that the subtle differences between Java bytecode and MSIL is something that should bother a novice .NET developer. They both serve the same purpose of defining an abstract target machine which is a layer above the physical machine being used in the end.

首先,我要说的是,我不认为Java字节码和MSIL之间的细微差别会让新手。net开发人员感到困扰。它们都具有定义抽象目标机器的相同目的,抽象目标机器是在最终使用的物理机器之上的一层。

MSIL and Java bytecode are very similar, in fact there is a tool called Grasshopper which translates MSIL to Java bytecode, I was part of the development team for Grasshopper so I can share a bit of my (faded) knowledge. Please note that I stopped working on this around when .NET framework 2.0 came out so some of these things may not be true any more (if so please leave a comment and I'll correct it).

MSIL和Java字节码非常相似,事实上有一个工具叫做Grasshopper,它可以将MSIL转换为Java字节码,我是Grasshopper开发团队的一员,所以我可以分享我的一些(褪色的)知识。请注意,当. net framework 2.0出现时,我已经停止了这方面的工作,因此有些事情可能不再是真的了(如果是的话,请留下评论,我将予以更正)。

  • .NET allows user defined types that have value semantics as apposed to the regular reference semantics (struct).
  • . net允许用户定义的类型具有与常规引用语义相适应的值语义。
  • .NET supports unsigned types, this makes the instruction set a bit richer.
  • . net支持无符号类型,这使得指令集更加丰富。
  • Java includes the exception specification of methods in the bytecode. Although exception specification is usually only enforced by the compiler, it may be enforced by the JVM if a class loader other than the default one is used.
  • Java在字节码中包含方法的异常规范。尽管异常规范通常只由编译器强制执行,但如果使用的是非默认类装入器,则可能由JVM强制执行。
  • .NET generics are expressed in IL while Java generics only use type erasure.
  • net泛型在IL中表达,而Java泛型只使用类型消除。
  • .NET attributes have no equivalent in Java (is this still true?).
  • . net属性在Java中没有对应的属性(这仍然是真的吗?)
  • .NET enums are not much more than wrappers around integer types while Java enums are pretty much fully fledged classes (thanks to Internet Friend for commenting).
  • . net enums只不过是整数类型的包装器,而Java enums则是完全成熟的类(感谢Internet Friend的评论)。
  • .NET has out and ref parameters.
  • . net有out和ref参数。

There are other language differences but most of them are not expressed at the byte code level, for example if memory serves Java's non-static inner classes (which do not exist in .NET) are not a bytecode feature, the compiler generates an additional argument to the inner class's constructor and passes the outer object. The same is true for .NET lambda expressions.

还有其他语言差异但他们中的大多数并不表示在字节码级别,例如,如果没记错Java的非静态内部类(不存在在。net)不是一个字节码功能,编译器生成一个额外的参数内部类的构造函数,并将外部对象。. net lambda表达式也是如此。

#2


20  

They are essentially doing the same thing, MSIL is Microsoft's version of Java bytecode.

他们基本上是在做同样的事情,MSIL是微软版本的Java字节码。

The main differences internally are:

内部的主要差异是:

  1. Bytecode was developed for both compilation and interpretation, while MSIL was developed explicitly for JIT compilation
  2. 字节码是为编译和解释而开发的,而MSIL是为JIT编译而开发的。
  3. MSIL was developed to support multiple languages (C# and VB.NET, etc.) versus Bytecode being written for just Java, resulting in Bytecode being more similar to Java syntactically than IL is to any specific .NET language
  4. MSIL的开发是为了支持多种语言(c#和VB)。与专为Java编写的字节码相比,导致字节码在语法上比任何特定的.NET语言的IL更类似于Java
  5. MSIL has more explicit delineation between value and reference types
  6. MSIL在值和引用类型之间有更明确的描述

A lot more information and a detailed comparison can be found in this article by K John Gough (postscript document)

K John Gough (postscript文档)在本文中提供了更多的信息和详细的比较。

#3


19  

CIL (the proper name for MSIL) and Java bytecode are more the same than they are different. There are some important differences though:

CIL (MSIL的正确名称)和Java字节码与它们的不同有更多的相同之处。尽管有一些重要的区别:

1) CIL was designed from the beginning to serve as a target for multiple languages. As such, it supports a much richer type system including signed and unsigned types, value types, pointers, properties, delegates, events, generics, an object-system with a single root, and more. CIL supports features not required for the initial CLR languages (C# and VB.NET) such as global functions and tail-call optimizations. In comparision, Java bytecode was designed as a target for the Java language and reflects many of the constraints found in Java itself. It would be a lot harder to write C or Scheme using Java bytecode.

1) CIL代码从一开始就被设计为多种语言的目标。因此,它支持更丰富的类型系统,包括签名和无符号类型、值类型、指针、属性、委托、事件、泛型、具有单个根的对象系统等等。CIL支持初始CLR语言(c#和VB.NET)不需要的特性,例如全局函数和尾部调用优化。在comparision中,Java字节码被设计为Java语言的目标,它反映了Java本身的许多约束。使用Java字节码编写C或Scheme要困难得多。

2) CIL was designed to integrate easily into native libraries and unmanaged code

2) CIL代码可以很容易地集成到本地库和非托管代码中

3) Java bytecode was designed to be either interpreted or compiled while CIL was designed assuming JIT compilation only. That said, the initial implementation of Mono used an interpreter instead of a JIT.

3) Java字节码设计为解释或编译,而CIL设计为仅假设JIT编译。也就是说,Mono的初始实现使用了解释器而不是JIT。

4) CIL was designed (and specified) to have a human readable and writable assembly language form that maps directly to the bytecode form. I believe that Java bytecode was (as the name implies) meant to be only machine readable. Of course, Java bytecode is relatively easily decompiled back to the original Java and, as shown below, it can also be "disassembled".

4) CIL代码被设计(并指定)为具有可读和可写的汇编语言形式,直接映射到字节码形式。我认为Java字节码(顾名思义)的意义是仅允许机器可读。当然,Java字节码相对容易地反编译回原始Java,并且,如下所示,它也可以“分解”。

I should note that the JVM (most of them) is more highly optimized than the CLR (any of them). So, raw performance might be a reason to prefer targeting Java bytecode. This is an implementation detail though.

我应该注意到JVM(大多数)比CLR(它们中的任何一个)优化得都要高。因此,原始性能可能是首选Java字节码的原因。这是实现细节。

Some people say that the Java bytecode was designed to be multi-platform while CIL was designed to be Windows only. This is not the case. There are some "Windows"isms in the .NET framework but there are none in CIL.

有人说,Java字节码被设计成多平台,而CIL被设计成仅为Windows。事实并非如此。net框架中有一些“Windows”主义,但是在CIL中没有。

As an example of point number 4) above, I wrote a toy Java to CIL compiler a while back. If you feed this compiler the following Java program:

作为上面第4点的一个例子,我不久前写了一个玩具Java给CIL编译器。如果您向该编译器提供以下Java程序:

class Factorial{
    public static void main(String[] a){
    System.out.println(new Fac().ComputeFac(10));
    }
}

class Fac {
    public int ComputeFac(int num){
    int num_aux ;
    if (num < 1)
        num_aux = 1 ;
    else 
        num_aux = num * (this.ComputeFac(num-1)) ;
    return num_aux ;
    }
}

my compiler will spit out the following CIL:

我的编译器会吐出以下信息:

.assembly extern mscorlib { }
.assembly 'Factorial' { .ver  0:0:0:0 }
.class private auto ansi beforefieldinit Factorial extends [mscorlib]System.Object
{
   .method public static default void main (string[] a) cil managed
   {
      .entrypoint
      .maxstack 16
      newobj instance void class Fac::'.ctor'()
      ldc.i4 3
      callvirt instance int32 class Fac::ComputeFac (int32)
      call void class [mscorlib]System.Console::WriteLine(int32)
      ret
   }
}

.class private Fac extends [mscorlib]System.Object
{
   .method public instance default void '.ctor' () cil managed
   {
      ldarg.0
      call instance void object::'.ctor'()
      ret
   }

   .method public int32 ComputeFac(int32 num) cil managed
   {
      .locals init ( int32 num_aux )
      ldarg num
      ldc.i4 1
      clt
      brfalse L1
      ldc.i4 1
      stloc num_aux
      br L2
   L1:
      ldarg num
      ldarg.0
      ldarg num
      ldc.i4 1
      sub
      callvirt instance int32 class Fac::ComputeFac (int32)
      mul
      stloc num_aux
   L2:
      ldloc num_aux
      ret
   }
}

This is a valid CIL program that can be fed into a CIL assembler like ilasm.exe to create an executable. As you can see, CIL is a fully human readable and writable language. You can easily create valid CIL programs in any text editor.

这是一个有效的CIL程序,可以被输入到像ilasm这样的CIL汇编程序中。创建可执行文件的exe。如您所见,CIL是一种完全可读和可写的语言。您可以在任何文本编辑器中轻松创建有效的CIL程序。

You can also compile the Java program above with the javac compiler and then run the resulting class files through the javap "disassembler" to get the following:

您还可以使用javac编译器编译上面的Java程序,然后通过javap“反汇编器”运行生成的类文件,以获得以下内容:

class Factorial extends java.lang.Object{
Factorial();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public static void main(java.lang.String[]);
  Code:
   0:   getstatic   #2; //Field java/lang/System.out:Ljava/io/PrintStream;
   3:   new #3; //class Fac
   6:   dup
   7:   invokespecial   #4; //Method Fac."<init>":()V
   10:  bipush  10
   12:  invokevirtual   #5; //Method Fac.ComputeFac:(I)I
   15:  invokevirtual   #6; //Method java/io/PrintStream.println:(I)V
   18:  return

}

class Fac extends java.lang.Object{
Fac();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public int ComputeFac(int);
  Code:
   0:   iload_1
   1:   iconst_1
   2:   if_icmpge   10
   5:   iconst_1
   6:   istore_2
   7:   goto    20
   10:  iload_1
   11:  aload_0
   12:  iload_1
   13:  iconst_1
   14:  isub
   15:  invokevirtual   #2; //Method ComputeFac:(I)I
   18:  imul
   19:  istore_2
   20:  iload_2
   21:  ireturn
}

The javap output is not compilable (to my knowledge) but if you compare it to the CIL output above you can see that the two are very similar.

javap输出是不可编译的(据我所知),但是如果您将它与上面的CIL输出进行比较,您就会发现这两者非常相似。

#4


2  

CIL aka MSIL is intended to be human-readable. Java bytecode is not.

CIL (CIL) MSIL旨在为人类可读的。Java字节码。

Think of Java bytecode as being machine code for hardware that does not exist (but which JVMs emulate).

可以将Java字节码看作是不存在的硬件的机器码(但它模拟的是哪个jvm)。

CIL is more like assembly language - one step from machine code, while still being human-readable.

CIL更像是汇编语言——离机器代码一步之遥,但仍然是人类可读的。

#5


2  

There are not that much differences. Both are intermediate formats of the code you wrote. When executed, the Virtual machines will execute the intermediate language managed that means that the Virtual Machine controls the variables and calls. There is even a language which I don't remeber right now that can run at .Net and Java the same way.

差别不大。这两种格式都是编写的代码的中间格式。当执行时,虚拟机将执行中间语言,这意味着虚拟机控制变量和调用。甚至有一种我现在不记得的语言可以在。net和Java中以同样的方式运行。

Basicly, it's just another format for the same thing

基本上,这是同一件事的另一种形式

Edit: Found the language (besides Scala): It's FAN (http://www.fandev.org/), looks very interesting, but no time yet to evaluate

编辑:找到语言(除了Scala):它是FAN (http://www.fandev.org/),看起来很有趣,但还没时间评估

#6


1  

Agreed, the differences are minute enough to ingore as a beginner. If you want to learn .Net starting from the basics, I'd recommend looking at the Common Language Infrastructure, and the Common Type System.

同意,这些差异对于一个初学者来说是非常微小的。如果您想从基础开始学习。net,我建议您学习公共语言基础设施和公共类型系统。

#7


1  

Serge Lidin authored a decent book on the details of MSIL: Expert .NET 2.0 IL Assembler. I also was able to pick up MSIL quickly by looking at simple methods using .NET Reflector and Ildasm (Tutorial).

Serge Lidin写了一本关于MSIL细节的好书:专家。net 2.0 IL汇编程序。通过使用。net Reflector和Ildasm(教程),我还能够快速地查看MSIL。

The concepts between MSIL and Java bytecode are very similar.

MSIL和Java字节码之间的概念非常相似。

#8


1  

I think MSIL should not compare to Java bytecode, but "the instruction that comprise the Java bytecodes".

我认为MSIL不应该与Java字节码相比,而应该与“包含Java字节码的指令”相比。

There is no name of disassembled java bytecode. "Java Bytecode" should be an unofficial alias, as I cannot find its name in official document. The Java Class File Disassembler say

没有分解的java字节码的名称。“Java字节码”应该是一个非官方的别名,因为我在官方文档中找不到它的名字。Java类文件反汇编器说。

Prints out disassembled code, i.e., the instructions that comprise the Java bytecodes, for each of the methods in the class. These are documented in the Java Virtual Machine Specification.

打印分解后的代码,例如。,为类中的每个方法组成Java字节码的指令。这些都在Java虚拟机规范中进行了记录。

Both "Java VM instructions" and "MSIL" are assembled into .NET bytecode and Java code, which are not human readable.

“Java VM指令”和“MSIL”都被组装成。net字节码和Java代码,这些代码不是人类可读的。

#1


67  

First off let me say that I don't think that the subtle differences between Java bytecode and MSIL is something that should bother a novice .NET developer. They both serve the same purpose of defining an abstract target machine which is a layer above the physical machine being used in the end.

首先,我要说的是,我不认为Java字节码和MSIL之间的细微差别会让新手。net开发人员感到困扰。它们都具有定义抽象目标机器的相同目的,抽象目标机器是在最终使用的物理机器之上的一层。

MSIL and Java bytecode are very similar, in fact there is a tool called Grasshopper which translates MSIL to Java bytecode, I was part of the development team for Grasshopper so I can share a bit of my (faded) knowledge. Please note that I stopped working on this around when .NET framework 2.0 came out so some of these things may not be true any more (if so please leave a comment and I'll correct it).

MSIL和Java字节码非常相似,事实上有一个工具叫做Grasshopper,它可以将MSIL转换为Java字节码,我是Grasshopper开发团队的一员,所以我可以分享我的一些(褪色的)知识。请注意,当. net framework 2.0出现时,我已经停止了这方面的工作,因此有些事情可能不再是真的了(如果是的话,请留下评论,我将予以更正)。

  • .NET allows user defined types that have value semantics as apposed to the regular reference semantics (struct).
  • . net允许用户定义的类型具有与常规引用语义相适应的值语义。
  • .NET supports unsigned types, this makes the instruction set a bit richer.
  • . net支持无符号类型,这使得指令集更加丰富。
  • Java includes the exception specification of methods in the bytecode. Although exception specification is usually only enforced by the compiler, it may be enforced by the JVM if a class loader other than the default one is used.
  • Java在字节码中包含方法的异常规范。尽管异常规范通常只由编译器强制执行,但如果使用的是非默认类装入器,则可能由JVM强制执行。
  • .NET generics are expressed in IL while Java generics only use type erasure.
  • net泛型在IL中表达,而Java泛型只使用类型消除。
  • .NET attributes have no equivalent in Java (is this still true?).
  • . net属性在Java中没有对应的属性(这仍然是真的吗?)
  • .NET enums are not much more than wrappers around integer types while Java enums are pretty much fully fledged classes (thanks to Internet Friend for commenting).
  • . net enums只不过是整数类型的包装器,而Java enums则是完全成熟的类(感谢Internet Friend的评论)。
  • .NET has out and ref parameters.
  • . net有out和ref参数。

There are other language differences but most of them are not expressed at the byte code level, for example if memory serves Java's non-static inner classes (which do not exist in .NET) are not a bytecode feature, the compiler generates an additional argument to the inner class's constructor and passes the outer object. The same is true for .NET lambda expressions.

还有其他语言差异但他们中的大多数并不表示在字节码级别,例如,如果没记错Java的非静态内部类(不存在在。net)不是一个字节码功能,编译器生成一个额外的参数内部类的构造函数,并将外部对象。. net lambda表达式也是如此。

#2


20  

They are essentially doing the same thing, MSIL is Microsoft's version of Java bytecode.

他们基本上是在做同样的事情,MSIL是微软版本的Java字节码。

The main differences internally are:

内部的主要差异是:

  1. Bytecode was developed for both compilation and interpretation, while MSIL was developed explicitly for JIT compilation
  2. 字节码是为编译和解释而开发的,而MSIL是为JIT编译而开发的。
  3. MSIL was developed to support multiple languages (C# and VB.NET, etc.) versus Bytecode being written for just Java, resulting in Bytecode being more similar to Java syntactically than IL is to any specific .NET language
  4. MSIL的开发是为了支持多种语言(c#和VB)。与专为Java编写的字节码相比,导致字节码在语法上比任何特定的.NET语言的IL更类似于Java
  5. MSIL has more explicit delineation between value and reference types
  6. MSIL在值和引用类型之间有更明确的描述

A lot more information and a detailed comparison can be found in this article by K John Gough (postscript document)

K John Gough (postscript文档)在本文中提供了更多的信息和详细的比较。

#3


19  

CIL (the proper name for MSIL) and Java bytecode are more the same than they are different. There are some important differences though:

CIL (MSIL的正确名称)和Java字节码与它们的不同有更多的相同之处。尽管有一些重要的区别:

1) CIL was designed from the beginning to serve as a target for multiple languages. As such, it supports a much richer type system including signed and unsigned types, value types, pointers, properties, delegates, events, generics, an object-system with a single root, and more. CIL supports features not required for the initial CLR languages (C# and VB.NET) such as global functions and tail-call optimizations. In comparision, Java bytecode was designed as a target for the Java language and reflects many of the constraints found in Java itself. It would be a lot harder to write C or Scheme using Java bytecode.

1) CIL代码从一开始就被设计为多种语言的目标。因此,它支持更丰富的类型系统,包括签名和无符号类型、值类型、指针、属性、委托、事件、泛型、具有单个根的对象系统等等。CIL支持初始CLR语言(c#和VB.NET)不需要的特性,例如全局函数和尾部调用优化。在comparision中,Java字节码被设计为Java语言的目标,它反映了Java本身的许多约束。使用Java字节码编写C或Scheme要困难得多。

2) CIL was designed to integrate easily into native libraries and unmanaged code

2) CIL代码可以很容易地集成到本地库和非托管代码中

3) Java bytecode was designed to be either interpreted or compiled while CIL was designed assuming JIT compilation only. That said, the initial implementation of Mono used an interpreter instead of a JIT.

3) Java字节码设计为解释或编译,而CIL设计为仅假设JIT编译。也就是说,Mono的初始实现使用了解释器而不是JIT。

4) CIL was designed (and specified) to have a human readable and writable assembly language form that maps directly to the bytecode form. I believe that Java bytecode was (as the name implies) meant to be only machine readable. Of course, Java bytecode is relatively easily decompiled back to the original Java and, as shown below, it can also be "disassembled".

4) CIL代码被设计(并指定)为具有可读和可写的汇编语言形式,直接映射到字节码形式。我认为Java字节码(顾名思义)的意义是仅允许机器可读。当然,Java字节码相对容易地反编译回原始Java,并且,如下所示,它也可以“分解”。

I should note that the JVM (most of them) is more highly optimized than the CLR (any of them). So, raw performance might be a reason to prefer targeting Java bytecode. This is an implementation detail though.

我应该注意到JVM(大多数)比CLR(它们中的任何一个)优化得都要高。因此,原始性能可能是首选Java字节码的原因。这是实现细节。

Some people say that the Java bytecode was designed to be multi-platform while CIL was designed to be Windows only. This is not the case. There are some "Windows"isms in the .NET framework but there are none in CIL.

有人说,Java字节码被设计成多平台,而CIL被设计成仅为Windows。事实并非如此。net框架中有一些“Windows”主义,但是在CIL中没有。

As an example of point number 4) above, I wrote a toy Java to CIL compiler a while back. If you feed this compiler the following Java program:

作为上面第4点的一个例子,我不久前写了一个玩具Java给CIL编译器。如果您向该编译器提供以下Java程序:

class Factorial{
    public static void main(String[] a){
    System.out.println(new Fac().ComputeFac(10));
    }
}

class Fac {
    public int ComputeFac(int num){
    int num_aux ;
    if (num < 1)
        num_aux = 1 ;
    else 
        num_aux = num * (this.ComputeFac(num-1)) ;
    return num_aux ;
    }
}

my compiler will spit out the following CIL:

我的编译器会吐出以下信息:

.assembly extern mscorlib { }
.assembly 'Factorial' { .ver  0:0:0:0 }
.class private auto ansi beforefieldinit Factorial extends [mscorlib]System.Object
{
   .method public static default void main (string[] a) cil managed
   {
      .entrypoint
      .maxstack 16
      newobj instance void class Fac::'.ctor'()
      ldc.i4 3
      callvirt instance int32 class Fac::ComputeFac (int32)
      call void class [mscorlib]System.Console::WriteLine(int32)
      ret
   }
}

.class private Fac extends [mscorlib]System.Object
{
   .method public instance default void '.ctor' () cil managed
   {
      ldarg.0
      call instance void object::'.ctor'()
      ret
   }

   .method public int32 ComputeFac(int32 num) cil managed
   {
      .locals init ( int32 num_aux )
      ldarg num
      ldc.i4 1
      clt
      brfalse L1
      ldc.i4 1
      stloc num_aux
      br L2
   L1:
      ldarg num
      ldarg.0
      ldarg num
      ldc.i4 1
      sub
      callvirt instance int32 class Fac::ComputeFac (int32)
      mul
      stloc num_aux
   L2:
      ldloc num_aux
      ret
   }
}

This is a valid CIL program that can be fed into a CIL assembler like ilasm.exe to create an executable. As you can see, CIL is a fully human readable and writable language. You can easily create valid CIL programs in any text editor.

这是一个有效的CIL程序,可以被输入到像ilasm这样的CIL汇编程序中。创建可执行文件的exe。如您所见,CIL是一种完全可读和可写的语言。您可以在任何文本编辑器中轻松创建有效的CIL程序。

You can also compile the Java program above with the javac compiler and then run the resulting class files through the javap "disassembler" to get the following:

您还可以使用javac编译器编译上面的Java程序,然后通过javap“反汇编器”运行生成的类文件,以获得以下内容:

class Factorial extends java.lang.Object{
Factorial();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public static void main(java.lang.String[]);
  Code:
   0:   getstatic   #2; //Field java/lang/System.out:Ljava/io/PrintStream;
   3:   new #3; //class Fac
   6:   dup
   7:   invokespecial   #4; //Method Fac."<init>":()V
   10:  bipush  10
   12:  invokevirtual   #5; //Method Fac.ComputeFac:(I)I
   15:  invokevirtual   #6; //Method java/io/PrintStream.println:(I)V
   18:  return

}

class Fac extends java.lang.Object{
Fac();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public int ComputeFac(int);
  Code:
   0:   iload_1
   1:   iconst_1
   2:   if_icmpge   10
   5:   iconst_1
   6:   istore_2
   7:   goto    20
   10:  iload_1
   11:  aload_0
   12:  iload_1
   13:  iconst_1
   14:  isub
   15:  invokevirtual   #2; //Method ComputeFac:(I)I
   18:  imul
   19:  istore_2
   20:  iload_2
   21:  ireturn
}

The javap output is not compilable (to my knowledge) but if you compare it to the CIL output above you can see that the two are very similar.

javap输出是不可编译的(据我所知),但是如果您将它与上面的CIL输出进行比较,您就会发现这两者非常相似。

#4


2  

CIL aka MSIL is intended to be human-readable. Java bytecode is not.

CIL (CIL) MSIL旨在为人类可读的。Java字节码。

Think of Java bytecode as being machine code for hardware that does not exist (but which JVMs emulate).

可以将Java字节码看作是不存在的硬件的机器码(但它模拟的是哪个jvm)。

CIL is more like assembly language - one step from machine code, while still being human-readable.

CIL更像是汇编语言——离机器代码一步之遥,但仍然是人类可读的。

#5


2  

There are not that much differences. Both are intermediate formats of the code you wrote. When executed, the Virtual machines will execute the intermediate language managed that means that the Virtual Machine controls the variables and calls. There is even a language which I don't remeber right now that can run at .Net and Java the same way.

差别不大。这两种格式都是编写的代码的中间格式。当执行时,虚拟机将执行中间语言,这意味着虚拟机控制变量和调用。甚至有一种我现在不记得的语言可以在。net和Java中以同样的方式运行。

Basicly, it's just another format for the same thing

基本上,这是同一件事的另一种形式

Edit: Found the language (besides Scala): It's FAN (http://www.fandev.org/), looks very interesting, but no time yet to evaluate

编辑:找到语言(除了Scala):它是FAN (http://www.fandev.org/),看起来很有趣,但还没时间评估

#6


1  

Agreed, the differences are minute enough to ingore as a beginner. If you want to learn .Net starting from the basics, I'd recommend looking at the Common Language Infrastructure, and the Common Type System.

同意,这些差异对于一个初学者来说是非常微小的。如果您想从基础开始学习。net,我建议您学习公共语言基础设施和公共类型系统。

#7


1  

Serge Lidin authored a decent book on the details of MSIL: Expert .NET 2.0 IL Assembler. I also was able to pick up MSIL quickly by looking at simple methods using .NET Reflector and Ildasm (Tutorial).

Serge Lidin写了一本关于MSIL细节的好书:专家。net 2.0 IL汇编程序。通过使用。net Reflector和Ildasm(教程),我还能够快速地查看MSIL。

The concepts between MSIL and Java bytecode are very similar.

MSIL和Java字节码之间的概念非常相似。

#8


1  

I think MSIL should not compare to Java bytecode, but "the instruction that comprise the Java bytecodes".

我认为MSIL不应该与Java字节码相比,而应该与“包含Java字节码的指令”相比。

There is no name of disassembled java bytecode. "Java Bytecode" should be an unofficial alias, as I cannot find its name in official document. The Java Class File Disassembler say

没有分解的java字节码的名称。“Java字节码”应该是一个非官方的别名,因为我在官方文档中找不到它的名字。Java类文件反汇编器说。

Prints out disassembled code, i.e., the instructions that comprise the Java bytecodes, for each of the methods in the class. These are documented in the Java Virtual Machine Specification.

打印分解后的代码,例如。,为类中的每个方法组成Java字节码的指令。这些都在Java虚拟机规范中进行了记录。

Both "Java VM instructions" and "MSIL" are assembled into .NET bytecode and Java code, which are not human readable.

“Java VM指令”和“MSIL”都被组装成。net字节码和Java代码,这些代码不是人类可读的。