Wiley Expert One-on-One Visual Basic 2005 Design and Development 978-0-470-05341-6 Benutzerhandbuch

Produktcode
978-0-470-05341-6
Seite von 12
Language Selection
The chapters in this part of the book cover activities that occur before programming begins. They
describe development and design approaches, and some useful design techniques. Many pro-
grammers skimp on these phases, and later pay a huge price when their initial assumptions prove
inappropriate for the application.
This chapter describes some of the issues that you should consider when picking a development
language. The book assumes you will use Visual Basic, but this chapter describes some of the lan-
guage’s shortcomings. While you may stick with Visual Basic, it’s worth understanding some of
the language’s weak spots and what you can do about them. If you know where trouble may arise,
you can more easily cope with it. In extreme cases, you may be able to move some of the more
troublesome modules into a library written in another language such as C# or C++, and call the
library from your Visual Basic code. For example, C++ and C# handle pointers more transparently
than Visual Basic does. If you need to use a library to control special-purpose hardware, it may be
easier to call that library’s routines from C++ or C#, particularly if the library was written in one of
those languages.
One of the other times I’ve found this sort of thing useful is with “unsafe” array manipulation
for graphics processing. A program can obtain a pointer to the memory containing an image’s
pixel data. A C# program can treat the pointer as a reference to an array, whereas a Visual Basic
program must use API functions to copy the pointer’s memory into a new array and, after the
program has finished manipulating the array, it must copy the result back to the pointer’s loca-
tion. If you place the graphics-processing code in a C# module and call it from Visual Basic, you
can avoid these two memory copies and save some time.
Language Addiction
If you surf the Web looking for reviews of languages, you’ll find a very strong correlation between
the programming language a person uses and the language he or she thinks is best. You can 
find lots of C# and C++ programmers who can tell you all about the bad points of Visual Basic, 
05_053416 ch01.qxd  1/2/07  6:28 PM  Page 3
COPYRIGHTED MATERIAL