![](https://csdnimg.cn/release/download_crawler_static/87463275/bg14.jpg)
2 Part I CLR Basics
management, assembly loading, security, exception handling, and thread synchronization)
are available to any and all programming languages that target it—period. For example, the
runtime uses exceptions to report errors, so all languages that target the runtime also get
errors reported via exceptions. Another example is that the runtime also allows you to create
a thread, so any language that targets the runtime can create a thread.
In fact, at runtime, the CLR has no idea which programming language the developer used for
the source code. This means that you should choose whatever programming language allows
you to express your intentions most easily. You can develop your code in any programming
language you desire as long as the compiler you use to compile your code targets the CLR.
So, if what I say is true, what is the advantage of using one programming language over
another? Well, I think of compilers as syntax checkers and “correct code” analyzers. They
examine your source code, ensure that whatever you’ve written makes some sense, and then
output code that describes your intention. Different programming languages allow you to
develop using different syntax. Don’t underestimate the value of this choice. For mathemati-
cal or financial applications, expressing your intentions by using APL syntax can save many
days of development time when compared to expressing the same intention by using Perl
syntax, for example.
Microsoft has created several language compilers that target the runtime: C++/CLI, C# (pro-
nounced “C sharp”), Visual Basic, F# (pronounced “F sharp”), Iron Python, Iron Ruby, and an
Intermediate Language (IL) Assembler. In addition to Microsoft, several other companies, col-
leges, and universities have created compilers that produce code to target the CLR. I’m aware
of compilers for Ada, APL, Caml, COBOL, Eiffel, Forth, Fortran, Haskell, Lexico, LISP, LOGO,
Lua, Mercury, ML, Mondrian, Oberon, Pascal, Perl, Php, Prolog, RPG, Scheme, Smalltalk, and
Tcl/Tk.
Figure 1-1 shows the process of compiling source code files. As the figure shows, you can cre-
ate source code files written in any programming language that supports the CLR. Then you
use the corresponding compiler to check the syntax and analyze the source code. Regardless
of which compiler you use, the result is a managed module. A managed module is a standard
32-bit Microsoft Windows portable executable (PE32) file or a standard 64-bit Windows
portable executable (PE32+) file that requires the CLR to execute. By the way, managed
assemblies always take advantage of Data Execution Prevention (DEP) and Address Space
Layout Randomization (ASLR) in Windows; these two features improve the security of your
whole system.