为什么编译成中间code? [英] Why compiling into intermediate code?

查看:255
本文介绍了为什么编译成中间code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么动作脚本,Java和C#等编译成中间code? 我所知道的使用中间code跨平台的好处。

Why do Actionscript, Java, C#, etc. compile into intermediate code? I'm aware of cross-platform benefits of using intermediate code.

现在的问题是:什么是编译成中间code的好处,相比脚本(JS,Python和PHP,Perl等),它们相互preTED

The question is: What is the benefit of compiling to intermediate code, compared to scripts (JS, Python, PHP, Perl, etc.) that are interpreted?

难道只为code混淆?还是什么?

Is it just for code obfuscation? Or what?

另外有什么好处相比,编译为本机code?

In addition what is the benefit compared to compiling to native code?

推荐答案

首先从历史的java是针对移动和嵌入式设备具有非常有限的CPU /内存和JVM在这些设备上不能做任何充分的优化,如现代的JIT们做了。所以Java engeneers决定搬到优化编译阶段。

First of all historically java was targeted to mobiles and embedded devices with very limited CPU/memory, and JVM on such devices can't do any intensive optimization, like modern JITs do for now. So java engeneers decided to move optimization to compile phase.

接着,字节code/ IL可以让你有不同语言的很多编译成字节等code - 且只有一个JVM / JIT。它是更有效的,然后,创建单独的VM + JIT每种语言。记住,你的Java,JRuby的,JPython的,Groovy中,等等...在JVM的世界,和C#,VB#,ASP.NET,F#等 - 在.NET世界中,只有一个运行时/ VM的每个

Next, having "byte code"/IL allows you to have many compilers from different languages into such byte code - and only one JVM/JIT. It is much more efficient then to create separate VM+JIT for each language. Remember, you have Java, JRuby, JPython, Groovy, etc... in JVM world, and C#, VB#, ASP.NET, F#, etc -- in .NET world, and only one runtime/VM for each.

这篇关于为什么编译成中间code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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