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.
“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.