In defense of Visual Basic (was Re: Why Python does *SLICING* the way it does??)

beliavsky at aol.com beliavsky at aol.com
Fri Apr 22 11:12:56 EDT 2005


Peter Hansen wrote:

<snip>

> > But I agree, having "the easiest thing for newbies" as your sole
> > criterion for language design is a road to madness, for no other
reason
> > than that newbies don't stay newbies forever.
>
> If Visual BASIC is the example of "easiest thing for newbies",
> then it disproves your theory already.  I think VB newbies
> *do* stay newbies forever (or as long as they are using just VB).

Much snobbery is directed at Visual Basic and other dialects of Basic
(they even have "basic" in their name), but I think VBA is better
designed than the prestigious C in some important ways.

Suppose you want to allocate a 2-D array at run-time and pass it to a
procedure. The VBA code is just

Option Explicit
Option Base 1

Sub make_matrix()
Dim x() As Double
Dim n1 As Integer, n2 As Integer
n1 = 2
n2 = 3
ReDim x(n1, n2)
Call print_matrix(x)
End Sub

Sub print_matrix(xmat() As Double)
Debug.Print UBound(xmat, 1), UBound(xmat, 2)
'do stuff with xmat
End Sub

It is trivial to allocate and pass multidimensional arrays in VBA, but
C requires expertise with pointers. The subroutine print_matrix can
query the dimensions of xmat, so they don't need to be passed as
separate arguments, as in C. The fact that is tricky to do simple
things is a sign of the poor design of C and similar languages, at
least for non-systems programming.

People bash VB as a language the corrupts a programmer and prevents him
from ever becoming a "real" programmer. Maybe VB programmers quickly
get so productive with it that they don't need to fuss with trickier
languages.




More information about the Python-list mailing list