在编译过程中,Java运行时环境如何与.NET框架进行比较? [英] How does the Java Runtime Environment compare with the .NET framework in terms of compilation process?

查看:163
本文介绍了在编译过程中,Java运行时环境如何与.NET框架进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习通过 .NET JRE 框架将源代码转换为机器代码。首先,我做了一些比较两个过程的研究,并创建了此图表。我需要一些帮助批评其正确性,更重要的是添加任何严重的事情,我错过了更好地了解编译路径。

I am learning about the conversion of source code to machine code via the .NET and JRE Frameworks. To start off I did some research comparing the two processes and created this diagram. I need some help in criticizing its correctness, and more importantly adding any serious things I missed out to better understand the compilation pathway.

推荐答案

Java编译为字节码,这是一种包含虚拟机指令的中间语言。它不是机器代码,因为它不能直接在物理机器上运行。反而(至少今天,Java在这方面有一个更深的历史)是什么发生的是,在运行时,运行一个即时编译器,将VM指令转换为本机代码,然后直接运行。这有一个主要的性能有利于超过只解释它。

Both .NET and Java compile down to bytecode, that is an intermediate language which contains instructions for a virtual machine. It's not machine code because it cannot run directly on a physical machine. What happens instead (today at least; Java has a darker history in this regard) is that at runtime a just-in-time compiler is run which translates the VM instructions into native code that is then run directly. This has a major performance benefot over only interpreting it.

他们在这方面有一点不同。 Oracle的Java实现使用了一种巧妙的解释,测量和JIT编译,只是大量使用的部分,否则解释。这是为了减少JIT编译器的初始影响(它需要以其他方式运行,延长进程启动时间),同时仍然允许在需要的情况下良好的性能。 .NET另一方面总是JIT编译所有使用的代码(未使用的代码不编译,虽然)。

They differ in this regard a little. Su^H^HOracle's Java implementation uses a clever mix of interpretation, measuring and JIT compiling just the parts that are heavily used and interpreting otherwise. This is to reduce initial impact by the JIT compiler (which needs to run upfront otherwise, lengthening process startup time) while still allowing good performance where needed. .NET on the other hand always JIT-compiles all code that is used (unused code is not compiled, though).

至于你在你的评论中提到的问题:是的,CLR和JVM 这样的程序运行的平台。虚拟机也是一台机器,只是硬件更少。它们都与相应的框架,.NET的基类库和Java的Java类库紧密集成。那些是框架。

As for a question you mentioned in your comments: Yes, the CLR and the JVM are the platforms such programs are run on. A virtual machine is a machine too, just less hardware-y. They both are tightly integrated with a corresponding framework, the Base Class Library for .NET and the Java class library for Java. Those are frameworks.

这篇关于在编译过程中,Java运行时环境如何与.NET框架进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆