以微软为基础创建
其 .NET 技术的 Common
语言基础设施 (CLI) 是一个
ECMA 标准 (ECMA-335) 允许
应用程序要写在
各种高级编程
语言并以不同的方式执行
系统环境。符合 CLI 的编程语言有
访问相同的基类库
并且能够被编译成
相同的中间语言(IL)
和元数据。 IL 进一步
编译为本机代码特定
到特定的架构。
由于这个中间步骤,
应用程序不必是
从头开始重写。他们只有IL
需要进一步编译成
系统的本机代码。
系统环境到底是什么意思?
此外,在研究 Ivor Horton 的开始 Visual C++ 2008 时,我注意到他指出可以使用 Visual C++ 2008 开发根本不同类型的 C++ 应用程序。这些是:
-
本地执行的应用程序他将其称为本机 C++ 程序。本机 C++ 程序是用 ISO/ANSI 语言标准定义的 C++ 版本编写的。
-
应用程序还可以编写为在 C++ 扩展版本(称为 C++/CLI)中的 CLR 控制下运行。这些程序被称为CLR 程序或C++/CLI 程序。
那么原生C++程序和CLR程序是什么意思呢?他们之间有什么区别?感谢任何专家的帮助。
Created by Microsoft as the foundation
of its .NET technology, the Common
Language Infrastructure (CLI) is an
ECMA standard (ECMA-335) that allows
applications to be written in a
variety of high-level programming
languages and executed in different
system environments. Programming languages that conform to the CLI have
access to the same base class library
and are capable of being compiled into
the same intermediate language (IL)
and metadata. IL is then further
compiled into native code particular
to a specific architecture.
Because of this intermediate step,
applications do not have to be
rewritten from scratch. Their IL only
needs to be further compiled into a
system's native code.
What exactly is meant by the system environments?
Additionally, while studying Ivor Horton's Beginning Visual C++ 2008, I noticed that he stated that there are fundamentally different kinds of C++ applications can be developed with Visual C++ 2008. These are:
-
Applications which execute natively on one's computer, which he referred to as native C++ programs. Native C++ programs are written in the version of C++ that is defined by the ISO/ANSI language standard.
-
Application can also be written to run under the control of the CLR in an extended version of C++, called C++/CLI. These programs were referred to as CLR programs, or C++/CLI programs.
So what is meant by native C++ programs and CLR programs? What's the difference between them? Thanks for any expert's help.
发布评论
评论(2)
“系统环境”指的是 Linux、Windows x86、Windows x64 等。请注意它们在段落末尾如何互换使用术语“体系结构”。
本机 C++ 程序是一种采用标准 (ANSI/ISO) C++ 并将其编译为 .exe 的程序。通常,您将针对特定环境(例如 Windows x86)编译此文件,在这种情况下,它无法在 Linux 下运行,而是在 WoW64 模拟层。值得注意的是,该代码直接在机器上运行。
C++/CLI 是一种与标准 C++ 不同的编程语言。它与 C# 或 VB.NET 一样,运行在 Microsoft 的C通用语言I界面之上。这意味着它可以访问您引用的段落中的所有好东西,例如基类库和 IL 编译,这允许它在不同的体系结构上运行。但是,就像 C# 和 VB.NET 一样,它不能在计算机上本机运行。需要安装.NET Framework; .NET Framework 的部分工作是将 C++/CLI 程序翻译为本机程序,这意味着它们对机器的直接访问要少得多。
"System environments" means things like Linux, Windows x86, Windows x64, etc. Notice how they use the term "architecture" interchangeably at the end of the paragraph.
A native C++ program is one where you take standard (ANSI/ISO) C++ and you compile it into a .exe. Usually you will be compiling this for a specific environment, e.g. Windows x86, in which case it could not run under Linux and would run under the WoW64 emulation layer on Windows x64. Notably, this code runs directly on the machine.
C++/CLI is a different programming language than standard C++. It, just like C# or VB.NET, runs on top of Microsoft's Common Language Interface. This means it has access to all those nice things in the paragraph you quoted, like the base class library and compilation to IL which allows it to be run on different architectures. But, just like C# and VB.NET, it does not run natively on the machine. It requires the installation of the .NET Framework; part of the .NET Framework's job is translating C++/CLI programs into native programs, which means they have much less direct access to the machine.
我有点生疏了,记不起“本土”这个词到底是什么时候出现在常用语中的。我相信它被设计者大量使用,旨在简化在其他环境之上运行的编程,这些环境旨在提供对系统资源的最佳访问,而对编程风格的关注有限。这可能会随着时间而改变,因为本机也可以称为从用于对嵌入式系统进行编程的高级语言调用的一些汇编代码。这就是为什么我避免使用诸如 CLI/CLR 之类的操作系统概念,尽管常见的时尚可能是在 Linux(Mono)或没有操作系统支持的裸芯片(.NET Micro)上实现的。
在这种情况下,标准 C++ 遵循本机方法,并且对运行的硬件或操作系统(或没有操作系统)相当宽容,只要可以为此提供编译器和标准库即可。只要存在适用于任何此类平台的 C++ 编译器,就可以轻松地为任何此类平台重新编译标准 C++ 代码。
要称为 C++/CLI,C++ 方言实现需要 CLI/CLR 支持,当然还需要存在 CLI 平台,但可以在不使用 CIL 重新编译的情况下移植代码,并使用标准、复杂的库和实用程序。然而,初始要求比标准 C++ 的情况要高,标准 C++ 在这种情况下可以发挥本机环境的作用。
I am getting a bit rusty and cannot recall when exactly the word "native" popped up into the common parlance. I believe it was massively used by designers of environments destined to simplify programming running on the top of other ones designed to offer optimal access to system resources with limited focus on the programming style. Which is one may change with the time, as native also may be referred some assembler code invoked from a high level language used to program an embedded system. This is why I avoid using such concepts as operating system as even CLI/CLR despite the common fad may be implemented on Linux (Mono) or on bare silicon with no OS support (.NET Micro).
In such a context the standard C++ follows the native approach and is quite tolerant on which hardware or OS (or no OS) it runs as long as it is possible to provide a compiler and the standard library for that. The standard C++ code may be easily recompiled for any such platform as far a C++ compiler exists for it.
To be referred as C++/CLI the C++ dialect implementation needs CLI/CLR support and of course a CLI platform being present but the code may be ported without recompilation using CIL and use a standard, sophisticated library and utilities. However the initial requirements are higher than in the case of the standard C++ which can play in this case the role of the native environment.