Summary of Language Changes - Page 13
April 27, 2001
Each of the major languages in Visual Studio is also in for
changes. Here is a quick overview.
Visual Basic
VB gets the most extensive changes of any existing language in
the Visual Studio suite. These changes pull VB in line with other
languages in terms of data types, calling conventions, error
handling and, most importantly, object orientation.
We don't yet know for certain what the new Visual Basic will be
called, but the current favorite is Visual Basic.NET. This label
will be used in the discussion below.
Most new features in VB, especially the object-oriented ones such
as inheritance, are courtesy of the CLR. Visual Basic.NET
basically piggybacks on the stuff that was going to be
implemented anyway for C++, C# and third party .NET languages.
Chapter 4 covers the changes to Visual Basic, especially the
syntax changes, in detail. It also includes recommendations for
coding practices that will make eventual migration to .NET
easier. Here are a couple of highlights:
Lots of Possible Incompatibilities
These are the biggest changes ever in VB bigger even than
the jump from VB3 to VB4. This introduces significant potential
for incompatibilities.
Here's one example. In the current implementation of .NET, all
arrays are zero-based. There is no provision for explicit array
bounds, so any code that uses them could require manual changes.
There are quite a few other examples covered in Chapter 4.
Microsoft intends to supply a conversion tool, which will assist
in porting VB6 projects to .NET, but it will not do everything
required. There will be some areas where the conversion tool
merely places a note that indicates something needs to be done.
And there are likely to be areas where it fails to realize a
change is needed at all.
Object Features
Many of us have been clamoring for Visual Basic
to support full object-oriented development since classes were
introduced in version 4. With Visual Studio.NET our wish comes
true. VB now includes full inheritance, parameterized
constructors, and control over property and method overriding.
C++
The most significant changes in C++ revolve around the concept of
"managed code". A C++ developer has the option of marking a
section of the code to be managed by the CLR. The language then
provides:
- Metadata describing the modules into which the code is compiled
- Location of object references (no
CoCreateInstance needed just use New to declare an object)
- Exception handling tables
Managed code then allows the runtime to handle the following:
- Exception handling
- Security
- Lifetime management
- Debugging
- Profiling
- Memory management, including garbage collection
C++ developers have the option do everything the old way
("unmanaged code"), and this is, in fact, the default allowing
extensive backward compatibility.
This book does not include a specific chapter on C++, but the
concept of managed code is discussed in more detail in Chapter 2
on the Common Language Runtime.
All C# code is managed by the CLR. That makes C# leaner and safer
than C++. C# also dispenses with bug-prone idioms such as
multiple inheritance and pre-processor macros. To guard against
the kinds of memory errors that are difficult to debug, the C#
compiler issues warnings for variables that are referenced before
being initialized. Recent, valuable C++ additions such as
namespaces, the intrinsic string type, and structured error
handling have been included in C#. Tricky C++ "gotchas" like
fall-through switch...case have been eliminated.
Using the built-in capabilities of the CLR, C# makes implementing
components easy. Doing COM objects in C++ meant generating
interface GUIDS, implementing IUnknown and
IClassFactory, and providing self-registration code.
C# component development is like Visual Basic component
development in that you simply implement a class and compile it,
letting the C# compiler and the CLR provide the messy plumbing
invisibly.
C++ has been described as a language that gives the programmer
"enough rope to shoot himself in the foot." With C#, the
developer has just as much rope, but he has to explicitly ask for
it. For example, a programmer can short-circuit the CLR's
automatic garbage collection, but only by explicitly prefixing
object references with the fixed keyword.
C# is particularly well suited to .NET development. In many
respects, it is just a version of the .NET object model that can
be read by people. There is a large degree of correspondence
between C# constructs and Microsoft Intermediate Language.
With its unique combination of power and simplicity, C# may well
become the tool-of-choice for developing business objects, data
access objects, and controls, thus pushing Visual Basic upward to
Web Form-based user interfaces and C++ downward to hardcore
middleware and other system level functions. On the other hand,
since Visual Basic receives almost all of the functionality of C#
in .NET, it may continue to be the dominant application
development language by inertia. After all, there are literally
millions of developers who know Visual Basic. Only time will tell
what the acceptance level of C# will be.
However, there is one place that's jumping into C# with both feet
Microsoft itself. C# is the dominant language being used
to develop the .NET framework, and it is quickly growing to be
the most-used language at Microsoft. An introduction to C# is
included in Chapter 3, and is also covered in the Wrox book,
C# Programming with the Public Beta, ISBN 1-861004-87-7.
The First Step Visual Studio.NET - Page 12
Introducing .NET
Language Changes Affecting ASP.NET - Page 14
|