Advantages-of-Managed-Code托管代码的优点毕业论文外文文献翻译及原文
上传者:沈胜宏|上传时间:2017-06-03|密次下载
Advantages-of-Managed-Code托管代码的优点毕业论文外文文献翻译及原文
毕 业 设 计(论文) 外 文 文 献 翻 译
文献、资料中文题目:托管代码的优点
文献、资料英文题目:Advantages of Managed Code 文献、资料来源:
文献、资料发表(出版)日期:
院 (部):
专 业:
班 级:
姓 名:
学 号:
指导教师:
翻译日期: 2017.02.14
Advantages of Managed Code
Microsoft intermediate language shares with Java byte code the idea that it is a low-level language with a simple syntax , which can be very quickly translated into native machine code. Having this well-defined universal syntax for code has significant advantages.
Platform independence
First, it means that the same file containing byte code instructions can be placed on any platform; at runtime the final stage of compilation can then be easily accomplished so that the code will run on that particular platform. In other words, by compiling to IL we obtain platform independence for .NET, in much the same way as compiling to Java byte code gives Java platform independence.
Performance improvement
IL is actually a bit more ambitious than Java byte code. IL is always Just-In-Time compiled (known as JIT), whereas Java byte code was often interpreted. One of the disadvantages of Java was that, on execution, the process of translating from Java byte code to native executable resulted in a loss of performance.
Instead of compiling the entire application in one go (which could lead to a slow start-up time), the JIT compiler simply compiles each portion of code as it is called (just-in-time). When code has been compiled.once, the resultant native executable is stored until the application exits, so that it does not need to be recompiled the next time that portion of code is run. Microsoft argues that this process is more efficient than compiling the entire application code at the start, because of the likelihood that large portions of any application code will not actually be executed in any given run. Using the JIT compiler, such code will never be compiled.
This explains why we can expect that execution of managed IL code will be almost as fast as executing native machine code. What it doesn’t explain is why Microsoft expects that we will get a performance improvement. The reason given for this is that, since the final stage of compilation takes place at runtime, the JIT compiler will know exactly what processor type the program will run on. This means that it can optimize the final executable code to take advantage of any features or particular machine code instructions offered by that particular processor.
实际上,IL比Java字节代码的作用还要大。IL总是即时编译的(简称JIT),而Java字节代码常常是解释型的,Java的一个缺点是,在运行应用程序时,把Java字节代码转换为内部可执行代码的过程可可能导致性能的损失。 JIT编译器并不是把整个应用程序一次编译完(这样会有很长的启动时间),而是只编译它调用的那部分代码。代码编译过一次后,得到的内部可执行代码就存储起来,直到退出该应用程序为止,这样在下次运行这部分代码时,就不需要重新编译了。Microsoft认为这个过程要比一开始就编译整个应用程序代码的效率高得多,因为任何应用程序的大部分代码实际上并不是在每次运行过程中都执行。使用JIT编译器,从来都不会编译这种代码从来都不会被编译。
这解释了为什么托管IL代码的执行几乎和内部机器代码的执行速度一样快,但是并没有说明为什么Microsoft认为这会提高性能。其原因是编译过程的最后一部分是在运行时进行的,JIT编译器确切地知道程序运行在什么类型的处理器上,利用该处理器提供的任何特性或特定的机器代码指令来优化最后的可执行代码。 传统的编译器会优化代码,但它们的优化过程是独立于代码所运行的特定处理器的。这是因为传统的编译器是在发布软件之前编译为内部机器可执行的代码。即编译器不知道代码所运行的处理器类型,例如该处理器是x86兼容处理器或Alpha处理器,这超出了基本操作的范围。例如Visual Studio 6优化了一台一般的Pentium机器,所以它生成的代码就不能利用Pentium III处理器的硬件特性。相反,JIT编译器不仅可以进行Visual Studio
6所能完成的优化工作,还可以优化代码所运行的特定处理器。
Traditional compilers will optimize the code, but they can only perform optimizations that are
independent of the particular processor that the code will run on. This is because traditional compilers compile to native executable before the software is shipped. This means that the compiler doesn’t know what type of processor the code will run on beyond basic generalities, such as that it will be an
x86-compatible processor or an Alpha processor. Visual Studio 6, for example, optimizes for a generic Pentium machine,
so the code that it generates cannot take advantage of hardware features of Pentium III processors. On the other hand, the JIT compiler can do all the optimizations that Visual Studio 6 can, and in addition it will optimize for the particular processor the code is running on.
Language interoperability
The use of IL not only enables platform independence; it also facilitates language interoperability. Simply put, you can compile to IL from one language, and this compiled code should then be
interoperable with code that has been compiled to IL from another language.
You’re probably now wondering which languages aside from C# are interoperable with .NET, so let’s briefly discuss how some of the other common languages fit into .NET.
Visual Basic .NET
Visual Basic .NET has undergone a complete revamp from Visual Basic 6 to bring it up-to-date with .NET. The way that Visual Basic has evolved over the last few years means that in its previous version, Visual Basic 6, it was not a suitable language for running .NET programs. For example, it is heavily integrated into COM and works by exposing only event handlers as source code to the developer—most of the background code is not available as source code. Not only that, it does not support implementation inheritance, and the standard data types Visual Basic 6 uses are incompatible with .NET. Visual Basic 6 was upgraded to Visual Basic .NET, and the changes that were made to the language are so extensive you might as well regard Visual Basic .NET as a new language. Existing
Visual Basic 6 code does not compile as Visual Basic .NET code. Converting a Visual Basic 6 program to Visual Basic .NET requires extensive changes to the code. However, Visual Studio .NET (the
upgrade of VS for use with .NET) can do most of the changes for you. If you attempt to read a Visual Basic 6 project into Visual Studio .NET, it will upgrade the project for you, which means that it will
rewrite the Visual Basic 6 source code into Visual Basic .NET source code. Although this means that the work involved for you is heavily cut down, you will need to check through the new Visual Basic .NET code to make sure that the project still works as intended because the conversion might not be perfect. One side effect of this language upgrade is that it is no longer possible to compile Visual Basic .NET to native executable code. Visual Basic .NET compiles only to IL, just as C# does. If you need to continue coding in Visual Basic 6, you may do so, but the executable code produced will completely ignore
the .NET Framework, and you’ll need to keep Visual Studio 6 installed if you want to continue to work in this developer environment.
Visual C++ .NET
Visual C++ 6 already had a large number of Microsoft-specific extensions on Windows. With Visual C++ .NET, extensions have been added to support the .NET Framework. This means that existing C++ source code will continue to compile to native executable code without modification. It also means, however, that it will run independently of the .NET runtime. If you want your C++ code to run within
the .NET Framework, then you can simply add the following line to the beginning of your code: #using mscorlib.dll
You can also pass the flag /clr to the compiler, which then assumes that you want to compile to managed code, and will hence emit IL instead of native machine code. The interesting thing about C++ is that when you compile to managed code, the compiler can emit IL that contains an embedded native executable. This means that you can mix managed types and unmanaged types in your C++ code. Thus the managed C++ code:
class MyClass
{
defines a plain C++ class, whereas the code:
__gc class MyClass
{
will give you a managed class, just as if you’d written the class in C# or Visual Basic .NET. The advantage
of using managed C++ over C# code is that we can call unmanaged C++ classes from managed C++ code without having to resort to COM interop.
The compiler raises an error if you attempt to use features that are not supported by .NET on managed types (for example, templates or multiple inheritance of classes). You will also find that you will need to use nonstandard C++ features (such as the __gc keyword shown in the previous code) when using managed classes.
Because of the freedom that C++ allows in terms of low-level pointer manipulation and so on, the C++ compiler is not able to generate code that will pass the CLR’s memory type safety tests. If it’s important that your code is recognized by the CLR as memory type safe, then you’ll need to write your source code
in some other language (such as C# or Visual Basic .NET).
Visual J# .NET
The latest language to be added to the mix is Visual J# .NET. Prior to .NET Framework 1.1, users were able to use J# only after making a separate download. Now the J# language is built into the .NET
Framework. Because of this, J# users are able to take advantage of all the usual features of Visual Studio .NET. Microsoft expects that most J++ users will find it easiest to use J# if they want to work with .NET.
Instead of being targeted at the Java runtime libraries, J# uses the same base class libraries that the rest of the .NET compliant languages use. This means that you can use J# for building http://www.wendangwang.com Web applications,
Windows Forms, XMLWeb services, and everything else that is possible—just as C# and Visual Basic .NET can.
Scripting languages
Scripting languages are still around, although, in general, their importance is likely to decline with the advent of .NET. JScript, on the other hand, has been upgraded to JScript .NET. We can now write
pages in JScript .NET, run JScript .NET as a compiled rather than an interpreted language, and write strongly typed JScript .NET code. With http://www.wendangwang.com there is no reason to use scripting languages in serverside
Web pages. VBA is, however, still used as a language for Microsoft Office and Visual Studio macros.
COM and COM+
Technically speaking, COM and COM+ aren’t technologies targeted at .NET, because components based
on them cannot be compiled into IL (although it’s possible to do so to some degree using managed C++, if
the original COM component was written in C++). However, COM+ remains an important tool, because its features are not duplicated in .NET. Also, COM components will still work—and .NET incorporates COM interoperability features that make it possible for managed code to call up COM components and vice versa (this is discussed in Chapter 29). In general, however, you will probably find it more convenient
for most purposes to code new components as .NET components, so that you can take advantage of the .NET base classes as well as the other benefits of running as managed code.
托管代码的优点
Microsoft中间语言与Java字节代码共享一种理念:它们都是一种低级语言,语法很简单,可以非常快速地转换为机器码。对于代码来说,这种精心设计的通用语法,有很大的优点。
1. 平台无关性
首先,这意味着包含字节代码指令的同一个文件可以放在任一个平台中,运行时编译过程的最后阶段可以很容易完成,这样代码就可以运行在该特定的平台上。也就是说编译为中间语言就可以获得.NET平台无关性,这与编译为Java字节代码就会得到Java平台无关性是一样的。
2. 提高性能
实际上,IL比Java字节代码的作用还要大。IL总是即时编译的(简称JIT),而Java字节代码常常是解释型的,Java的一个缺点是,在运行应用程序时,把Java字节代码转换为内部可执行代码的过程可可能导致性能的损失。
JIT编译器并不是把整个应用程序一次编译完(这样会有很长的启动时间),而是只编译它调用的那部分代码(这是其名称由来)。代码编译过一次后,得到的内部可执行代码就存储起来,直到退出该应用程序为止,这样在下次运行这部分代码时,就不需要重新编译了。Microsoft认为这个过程要比一开始就编译整个应用程序代码的效率高得多,因为任何应用程序的大部分代码实际上并不是在每次运行过程中都执行。使用JIT编译器,从来都不会编译这种代码。
这解释了为什么托管IL代码的执行几乎和内部机器代码的执行速度一样快,但是并没有说明为什么Microsoft认为这会提高性能。其原因是编译过程的最后一部分是在运行时进行的,JIT编译器确切地知道程序运行在什么类型的处理器上,利用该处理器提供的任何特性或特定的机器代码指令来优化最后的可执行代码。
传统的编译器会优化代码,但它们的优化过程是独立于代码所运行的特定处理器的。这是因为传统的编译器是在发布软件之前编译为内部机器可执行的代码。即编译器不知道代码所运行的处理器类型,例如该处理器是x86兼容处理器或Alpha处理器,这超出了基本操作的范围。例如Visual Studio 6优化了一台一般的Pentium机器,所以它生成的代码就不能利用Pentium III处理器的硬件特性。相反,JIT编译器不仅可以进行Visual Studio 6所能完成的优化工作,还可以优化代码所运行的特定处理器。
3. 语言的互操作性
使用IL不仅支持平台无关性,还支持语言的互操作性。简言之,就是能将任何一种语言编译为中间代码,编译好的代码可以与从其他语言编译过来的代码进行交互操作。
那么除了C#之外,还有什么语言可以通过.NET进行交互操作呢?下面就简要讨论其他常见语言如何与.NET交互操作。
(1)
Visual Basic 6在升级到Visual Basic .NET时,经历了一番脱胎换骨的变化。Visual Basic是在最近的几年中演化的,其早期版本Visual Basic 6并不适合运行.NET程序。例如,它与COM的高度集成,且只把事件处理
下载文档
热门试卷
- 2016年四川省内江市中考化学试卷
- 广西钦州市高新区2017届高三11月月考政治试卷
- 浙江省湖州市2016-2017学年高一上学期期中考试政治试卷
- 浙江省湖州市2016-2017学年高二上学期期中考试政治试卷
- 辽宁省铁岭市协作体2017届高三上学期第三次联考政治试卷
- 广西钦州市钦州港区2016-2017学年高二11月月考政治试卷
- 广西钦州市钦州港区2017届高三11月月考政治试卷
- 广西钦州市钦州港区2016-2017学年高一11月月考政治试卷
- 广西钦州市高新区2016-2017学年高二11月月考政治试卷
- 广西钦州市高新区2016-2017学年高一11月月考政治试卷
- 山东省滨州市三校2017届第一学期阶段测试初三英语试题
- 四川省成都七中2017届高三一诊模拟考试文科综合试卷
- 2017届普通高等学校招生全国统一考试模拟试题(附答案)
- 重庆市永川中学高2017级上期12月月考语文试题
- 江西宜春三中2017届高三第一学期第二次月考文科综合试题
- 内蒙古赤峰二中2017届高三上学期第三次月考英语试题
- 2017年六年级(上)数学期末考试卷
- 2017人教版小学英语三年级上期末笔试题
- 江苏省常州西藏民族中学2016-2017学年九年级思想品德第一学期第二次阶段测试试卷
- 重庆市九龙坡区七校2016-2017学年上期八年级素质测查(二)语文学科试题卷
- 江苏省无锡市钱桥中学2016年12月八年级语文阶段性测试卷
- 江苏省无锡市钱桥中学2016-2017学年七年级英语12月阶段检测试卷
- 山东省邹城市第八中学2016-2017学年八年级12月物理第4章试题(无答案)
- 【人教版】河北省2015-2016学年度九年级上期末语文试题卷(附答案)
- 四川省简阳市阳安中学2016年12月高二月考英语试卷
- 四川省成都龙泉中学高三上学期2016年12月月考试题文科综合能力测试
- 安徽省滁州中学2016—2017学年度第一学期12月月考高三英语试卷
- 山东省武城县第二中学2016.12高一年级上学期第二次月考历史试题(必修一第四、五单元)
- 福建省四地六校联考2016-2017学年上学期第三次月考高三化学试卷
- 甘肃省武威第二十三中学2016—2017学年度八年级第一学期12月月考生物试卷
网友关注
- 采购业务流程及管理制度
- 湖南省2017年上半年资产评估师《机电设备》:金属切削机床模拟试题答案
- 2017美国普林斯顿大学校园环境
- 甘肃省2016年下半年注评《资产评估》:股票价值评估关系考试题答案
- 2017年度环境法律法规及其他要求清单
- 酒店管理地产 宗地收益测算模板——项目开发宗地收益还原法估价2017(叶予舜)
- 湖南省2016年下半年注册会计师考试《税法》:业务招待费扣除模拟试题答案
- 班前会制度
- 《晏子使楚》教学设计
- 苏俄经济体制的创新和调整
- 民族法第四讲少数民族习惯法Word
- 材料作文老僧与蝎子Word
- 湖南省2017年中级经济师人力资源笔记:社保争议处理试题答案
- 2017美国普林斯顿大学工程教授谈录取标准
- 甘肃省2015年下半年资产评估师《经济法》:国家出资企业考试题答案
- 人教版五年级下册语文期末模拟试卷(三)答案
- 月亮的味道Word
- 议论文开头段作用Word
- 2017新概念英语第二册Lesson31最新版Word
- 上市公司股利政策 外文翻译
- 雅思听力高分复习经验分享答案
- 第六章+++相似三角形单元练习卷答案
- 企业员工管理培训(新)Word
- 矿调度值班制度
- 食堂保洁管理细则
- ISO9001-14001-2015内审计划通知
- 2017年控制阀企业组织架构和部门职能
- 开启心智 管理人生——《把时间当朋友》读书笔记Word
- 农产品包装和标识管理办法
- ISO14001-2015组织环境内部因素分析表
网友关注视频
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 8
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 3.2 数学二年级下册第二单元 表内除法(一)整理和复习 李菲菲
- 8.对剪花样_第一课时(二等奖)(冀美版二年级上册)_T515402
- 8.练习八_第一课时(特等奖)(苏教版三年级上册)_T142692
- 苏科版数学 八年级下册 第八章第二节 可能性的大小
- 六年级英语下册上海牛津版教材讲解 U1单词
- 第4章 幂函数、指数函数和对数函数(下)_六 指数方程和对数方程_4.7 简单的指数方程_第一课时(沪教版高一下册)_T1566237
- 《空中课堂》二年级下册 数学第一单元第1课时
- 外研版英语七年级下册module3 unit1第二课时
- 外研版英语三起6年级下册(14版)Module3 Unit1
- 冀教版小学数学二年级下册第二单元《余数和除数的关系》
- 沪教版牛津小学英语(深圳用) 六年级下册 Unit 7
- 二年级下册数学第三课 搭一搭⚖⚖
- 【部编】人教版语文七年级下册《逢入京使》优质课教学视频+PPT课件+教案,安徽省
- 冀教版小学数学二年级下册第二单元《有余数除法的竖式计算》
- 北师大版小学数学四年级下册第15课小数乘小数一
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,天津市
- 第19课 我喜欢的鸟_第一课时(二等奖)(人美杨永善版二年级下册)_T644386
- 外研版八年级英语下学期 Module3
- 北师大版八年级物理下册 第六章 常见的光学仪器(二)探究凸透镜成像的规律
- 北师大版数学四年级下册3.4包装
- 冀教版小学数学二年级下册第二周第2课时《我们的测量》宝丰街小学庞志荣
- 冀教版英语三年级下册第二课
- 化学九年级下册全册同步 人教版 第18集 常见的酸和碱(二)
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,辽宁省
- 七年级英语下册 上海牛津版 Unit3
- 第五单元 民族艺术的瑰宝_16. 形形色色的民族乐器_第一课时(岭南版六年级上册)_T1406126
- 二次函数求实际问题中的最值_第一课时(特等奖)(冀教版九年级下册)_T144339
- 冀教版小学数学二年级下册第二单元《有余数除法的简单应用》
精品推荐
- 2016-2017学年高一语文人教版必修一+模块学业水平检测试题(含答案)
- 广西钦州市高新区2017届高三11月月考政治试卷
- 浙江省湖州市2016-2017学年高一上学期期中考试政治试卷
- 浙江省湖州市2016-2017学年高二上学期期中考试政治试卷
- 辽宁省铁岭市协作体2017届高三上学期第三次联考政治试卷
- 广西钦州市钦州港区2016-2017学年高二11月月考政治试卷
- 广西钦州市钦州港区2017届高三11月月考政治试卷
- 广西钦州市钦州港区2016-2017学年高一11月月考政治试卷
- 广西钦州市高新区2016-2017学年高二11月月考政治试卷
- 广西钦州市高新区2016-2017学年高一11月月考政治试卷
分类导航
- 互联网
- 电脑基础知识
- 计算机软件及应用
- 计算机硬件及网络
- 计算机应用/办公自动化
- .NET
- 数据结构与算法
- Java
- SEO
- C/C++资料
- linux/Unix相关
- 手机开发
- UML理论/建模
- 并行计算/云计算
- 嵌入式开发
- windows相关
- 软件工程
- 管理信息系统
- 开发文档
- 图形图像
- 网络与通信
- 网络信息安全
- 电子支付
- Labview
- matlab
- 网络资源
- Python
- Delphi/Perl
- 评测
- Flash/Flex
- CSS/Script
- 计算机原理
- PHP资料
- 数据挖掘与模式识别
- Web服务
- 数据库
- Visual Basic
- 电子商务
- 服务器
- 搜索引擎优化
- 存储
- 架构
- 行业软件
- 人工智能
- 计算机辅助设计
- 多媒体
- 软件测试
- 计算机硬件与维护
- 网站策划/UE
- 网页设计/UI
- 网吧管理