Flylib.com

Books Software

 
 
 

Intermediate Language

Intermediate Language

The Java language introduced the concept of byte code. The evolution of programming languages dictates that some things survive and some don't. Hopefully, the good ideas are propagated and the bad ones are not.

Intermediate Language , or IL, is similar to the idea of Java byte code. If the compiled form of a programming language is general enough, the compiled code can be separated from the platform on which it runs. The idea behind Java is that the compiler creates byte code, and some other tool converts the byte code to a platform-specific version of the code that runs on that specific platform. These other tools are often referred to as JITters , from the abbreviation for JIT compilers. (JIT is an acronym for just-in-time, as in just-in-time compilation.)

There is a good chance that someone, right now, is creating a JITter to convert VB .NET IL code to run on a Linux or UNIX platform.

One of the things we can do with IL is snoop around and look at what the VB compiler does with our source code. More than just being curious , it is possible to emit IL dynamically in VB .NET. This means we can define new types after our VB .NET source code is compiled, at runtime. (I wonder if the ability to emit IL and define new types dynamically will have applications in artificial intelligence, too.) Chapter 4 demonstrates how to emit IL at runtime.

A program that ships with .NET is the ildasm.exe utility, whose name derives from what the tool does: ildasm is an IL disassembler. This utility allows you to open an assembly ”a compiled .NET application ”and look at the IL code written by the compiler. Figure 1.3 (page 12) shows the box instruction automatically emitted by the compiler.

A good learning aid is to discover or explore what our precursors have done or are doing. You can find the ildasm utility in the C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ folder of the Visual Studio .NET application.

Summary

Chapter 1 provided you with an object-oriented overview. By now you know that many things are familiar in .NET because they are similar to VB6, and you likely have discovered those things that trip you up.

The purpose of this book is to go beyond teaching you basic syntax, to demonstrating the most advanced features of the VB .NET. In that regard it is important to realize that everything about .NET is a class. When you have mastered object-oriented concepts, what is left is to discover the available classes and what problems they solve.

Because VB .NET diverges from VB6 regarding classes and interfaces, Chapter 2 explores this divergence . Understanding these vital differences is critical in optimizing your experience with VB .NET.

Chapter 2. Inheritance and Interfaces

If you cannot be strong and you cannot be weak then you will be defeated.

The Art of War , Sun Tzu

Introduction

Inheritance, aggregation, and interfaces are three of your strongest allies in object-oriented programming. What has been missing from Visual Basic until now is inheritance. Visual Basic supported aggregation and interfaces; Visual Basic .NET supports inheritance, aggregation, and interfaces.

With the incorporation of inheritance into VB .NET some new capabilities are now available. Also, the way interfaces are used has changed. Chapter 2 demonstrates how to make the most of inheritance, aggregation, and interfaces.