Page 14 - Open Soource Technologies 304.indd
P. 14
Unit 1: Introduction to Visual Basic
application loading and execution, the CLR provides services that will benefit component Notes
developers:
Invocation and termination of threads and processes
Object lifetime and memory management
Cross-language integration
Code access and role-based security
Exception handling (even across languages)
Deployment and versioning
Interoperation between managed and unmanaged code
Debugging and profiling support (even across languages)
Runtimes are nothing new. Visual Basic has always had some form of a runtime. Visual C++ has
a runtime called MSVCRT.DLL. Perl, Python, and SmallTalk also use runtimes. The difference
between these runtimes and the CLR is that the CLR is designed to work with multiple
programming languages. Every language whose compiler targets the .NET Framework benefits
from the services of the CLR as much as any other language..NET is also similar to Java. Java
uses a runtime called the Java Virtual Machine. It can run only with Java code, so it has the same
limitations as the other languages. Another distinction is that the JVM is an interpreter. Although
all languages in the .NET environment are initially compiled to a CPU independent language
called Intermediate Language (which is analogous to Java byte code), IL is not interpreted at
runtime like Java. When code is initially executed, one of several just-in-time (JIT) compilers
translate the IL to native code on a method-by-method basis. Cross-language integration is one
of the major benefits provided by the CLR. If a colleague has written a base class in C#, you can
define a class in VB.NET that derives from it. This is known as cross-language inheritance. Also,
objects written in different languages can easily interoperate. The two parts of the CLR that
make this interoperation possible are the Common Type System and the Common Language
Specification. The Common Language Runtime (CLR) is the virtual machine component of
Microsoft’s .NET framework and is responsible for managing the execution of .NET programs.
In a process known as Just-in-time compilation, the compiled code is converted into machine
instructions that, in turn, are executed by the computer’s CPU. The CLR provides additional
services including memory management, type safety and exception handling. All programs
written for the .NET framework, regardless of programming language, are executed by the
CLR. It provides exception handling, garbage collection and thread management. CLR is common
to all versions of the .NET framework. The CLR is Microsoft’s implementation of the Common
Language Infrastructure (CLI) standard.
The Common Type System (CTS) defines rules that a language must adhere to in order to
participate in the .NET Framework. It also defines a set of common types and operations that
exist across most programming languages and specifies how these types are used and managed
within the CLR, how objects expose their functionality and how they interoperate. The CTS
forms the foundation that enables cross-language integration within .NET.
The Common Language Specification (CLS) is a subset of the CTS that describes the basic qualities
used by a wide variety of languages. Components that use only the features of the CLS are said
to be CLS-compliant. As a result, these components are guaranteed to be accessible from any
other programming language that targets .NET. Because VB.NET is a CLS-compliant language,
any class, object, or component that you build will be available from any other CLS-compliant
programming language in .NET.
LOVELY PROFESSIONAL UNIVERSITY 7