Comments on Thirteen Ways to Loathe VB by Verity Stob
In her article, Thirteen Ways to Loathe VB (published in Dr. Dobb’s Journal, August 12, 2001), Verity Stob attempts to portray Visual Basic as a programming language for non-professionals, whom she disparagingly calls “babies”. The purpose of this article is to point out factual errors in Stob’s article and to clarify some of the points she raises from a technical perspective. In some cases, background information is provided and additional code samples are shown for illustration purposes.
1. The author claims that calling a function with the signature FuncName(Param1, Param2) as FuncName(Param1, Param2) forces the arguments to be passed by value. This allegedly happens despite them being implicitly declared as reference parameters, which can alternatively be denoted using the ByRef keyword. This claim is invalid because the code sample it relies on does not compile. Specifically, the compiler detects a syntax error and rejects the function call FuncName(Param1, Param2).
However, the author is not entirely wrong; the code sample simply fails to demonstrate the intended behavior. The compiler accepts parentheses around an argument list only when calling a procedure with a single argument, such as FuncName(Param1). In this scenario, the parentheses do not enclose the argument list. Instead, they surround the argument value itself, forcing it to be passed by value. The procedure call FuncName (Param1) (note the space character immediately following the function name) is semantically equivalent to Call FuncName((Param1)).
2. The behavior described by the author is fully documented and intentional. For example, writing Dim i As Integer, o, j As Integer defines i and j as Integer, while o defaults to the Variant type. Omitting the explicit type specification in a variable declaration automatically defaults that variable to a Variant.
3. This point holds only theoretical significance, as array variables and functions rarely share the same name in practice.
4. Although Option Base 1 is rarely used, Visual Basic actually supports arbitrary lower bounds for arrays, such as Dim Items(10 To 20) As Item.
5. Collections are not simply modern, object-oriented versions of arrays. In Visual Basic, a collection differs fundamentally from an array regarding memory management, runtime characteristics, and supported operations.
6. No comment, as no technical issue is raised.
7. It is unclear what specific issue the author is pointing out here. While Visual Basic lacks a shorthand syntax for initializing array data directly, arrays can easily be populated from a file using the Get statement in binary mode. Alternatively, Variant arrays can be initialized using the Array function, for example: Fruits = Array("Apple", "Pear", "Banana").
8. The Const keyword in Visual Basic serves a different purpose than const correctness in C++. In Visual Basic, constants are simply immutable named values.
9. The Integer data type in Visual Basic is 16-bit due to the programming language’s history as a development environment for 16-bit hardware and operating systems. This differs from C, where the bit width of the int type matches the machine’s native word size. While an adaptive data type size may seem appealing, this design introduces significant drawbacks. For instance, it makes it much harder to detect bugs caused by varying bit widths across different architectures.
Furthermore, Visual Basic provides a 32-bit signed integer type called Long. There is no rule stating that Integer must be a universal synonym for a 32-bit signed integer. In fact, changing the width of the Integer data type to 32-bit in Visual Basic .NET caused widespread confusion and made migrating source code from Visual Basic 6.0 to Visual Basic .NET unnecessarily complicated.
10. The point raised by the author does not present a practical issue. Moreover, requiring a visual distinction between value and reference assignments can be viewed as an advantage, as it makes the semantic difference between the two operations more obvious to the reader.
11. Several of Visual Basic’s intrinsic controls feature a Value property used to retrieve or modify the control’s state. Valid values for various control types—such as command buttons, option buttons, and checkboxes—are defined in the documentation for the Value property. For checkboxes, the valid options for the Value property belong to the CheckBoxConstants enumeration: vbChecked, vbUnchecked, and vbGrayed. If the Value property were intended to return a boolean value, its data type would have been explicitly set to Boolean.
12. No comment, as no technical issue is raised.
12.5 The behavior of the development environment can easily be modified via Tools → Options… → General → Error Trapping by selecting the Break on Unhandled Errors option.
12.7 To ensure that a missing End If is detected when running the project within the development environment, developers should run the project using Run → Start, Full Compile. This action can also be triggered via the Ctrl+F5 keyboard shortcut.
12.8 First, Static is not an access modifier like Private or Public in Visual Basic. While scenarios requiring static procedures are rare, they are highly effective in specific high-performance use cases, such as this pure Visual Basic implementation of a fast Replace function. Additionally, the author overlooks the fact that functions can also be declared using the Friend access modifier.
13. No comment, as no technical concern is raised.