[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: About Visual Basic



the VB language is a mess, but indeed the IDE is addictive because of the
GUI and the debugger.  another nice feature of the VB environment is the way
you can combine user-defined types and the "intellisense" facility in order
to have quick keyboard access to many of your variables.  here's a made-up
example to illustrate the technique:

======================

' in the declarations section

Type udtOfficials  'user-defined type
  a_President As String
  b_VicePresident As String
  c_SpeakerOfTheHouse As String
  d_SecretaryOfState As String
  e_SecretaryOfDefense As String
  f_SecretaryOfTheTreasury As String
End Type

Dim us As udtOfficials  'an instance of the udt

Public Sub Officials()

  us.a_President = "Bush"
  us.b_VicePresident = "Cheney"
  us.c_SpeakerOfTheHouse = "Hastert"
  us.d_SecretaryOfState = "Powell"
  us.e_SecretaryOfDefense = "Rumsfeld"
  us.f_SecretaryOfTheTreasury = "Snow"

End Sub

======================

after you define udtOfficials and us, when you start typing the subroutine
Officials, all you have to type is "us." and the system shows you a list of
the members of the type, in this case from a_President through
f_SecretaryOfTheTreasury.  then you only have to type the first letter of
your selection and hit the tab key and it completes the variable name
automatically.  this way you can use long, descriptive variable names
without having to remember them or type them out each time.  [if memory
serves, i learned this trick from francesco balena's book.]


-----Original Message-----
From: Guillaume Marceau [mailto:gmarceau@cs.brown.edu]
Sent: Tuesday, March 11, 2003 10:02 AM
To: ll1-discuss@ai.mit.edu
Subject: About Visual Basic [Was: Industry versus academia]


On Fri, 2003-02-21 at 17:33, Lauri Alanko wrote:
> On Fri, Feb 21, 2003 at 05:11:48PM +0000, DLWeinreb@attbi.com wrote:
> > The big world out there has a WHOLE LOT more people who are really
> > not qualified to go near C++, Java, C#, and so on, but can get
> > by in Visual Basic.
> 
> Exactly what is it in Visual Basic, then, that makes it more suitable
> for these people? Clearly this property, whatever it is, is something
> that a lightweight language should have. Or is it something that's
> inherently incompatible with the features we want for "serious
> programming"?


Good question.

The short answer is : best-of-the-show debuger and GUIs as a code
abstraction mecanism. The long answer follows.




The idea of a monopolistic language strong-handedly controlled by a
single company is distasteful to the community here. As a result, we
know very little about Visual Basic.

Beside, there are many good reason to be unimpressed with Vb. First, its
syntax is wildly irregular, marked by Vb's long history of short-sighted
evolutionary steps ("Open "MyFile.txt" For Input As #1"). Many of its
features appear to have been designed by a marketing department and are
often unorthogonal with each other (for the longest time, libraries
classes could have subtyping relationships, but not the user-defined
classes). Plus, Microsoft takes as little care in the correctness of the
implementation as for its other office products. That means Visual Basic
and its libraries crash as often as Excel or Word does. Nasty.


There are good reasons for its success though. By far the most important
is Vb's debugger. Vb wins beginner programmers with its debugger, the
best by far, for miles around.

Upon opening Vb, its interface present a full featured REPL. It can do
everything a lisp-style REPL can do: it can evaluate expression using
precisely the same syntax as the compiled language. It can also define
new variables, new functions and new classes on the fly. More
importantly, it works in pair with the debugger. When stopped on a
breakpoint, the REPL can access and modify the any local variables on
the stack frame (gdb-style), move the execution point around to another
line and call functions and object methods (something gdb cannot do
consistently).

It gets better. The Vb interface can incorporate code changes on the
fly. It does it quickly, consistently and is very permissive of the kind
of changes it can handle. There are merely two constraints: is it not
allowed to remove or change a function's signature, and it is not
allowed to remove a variable currently on the stack frame (removing any
other variable is fine). Even changes to the current function are
accepted. It is as flexible as it could be.


Other, lesser reasons why Vb is doing well:  it keyword completion and
its context sensitive library documentation search takes advantage of
type label on the variables to restrict the list of matches to what is
relevant. It is simple but it works - works really well in fact.

Its window and dialog box editor is also conviniently comingled with the
language. Dialog element can be bound directly to names, and functions
can be bound directly to events, which saves having to write insipid
code or the form :

     Button button = new Button("Button", 50, 100);
     button.addActionListener(new ActionListener() { 
        public void actionPerformed(ActionEvent e) { ... }
     });

or of the form :

    (make-object button%
              (drscheme:unit:make-bitmap
                  (string-constant check-syntax)
                  (build-path (collection-path "icons") "syncheck.bmp"))
              (get-button-panel)
              (lambda (button evt) (syncheck:button-callback)))


I am aware of one other feature unique to Vb. Vb has a notion of
coding-time execution, called "custom controls". This allows the (rather
rare) competent Vb programmer to write convenient GUIs for the
non-professional Vb programmer. These GUI are typically used to
pre-select some of the constant argument to class constructors. For
instance, in the example above, the bitmap argument the button% class
constructor is a constant. In Vb, a competent Vb programmer could code a
bitmapped button control, which would then let the beginner coder select
its bitmap file using a file-open dialog box. It is at the same time
convenient and a simple way to ensure that "syncheck.bmp" is not
misspelled.

I have participated in the construction of a multimedia database
browser. The application was to be entertaining and visually appealing.
The coders created a spreadsheet control which was then given to
artists. The artists could selected the fonts and the colors using
non-threatening GUIs prepared for them. The more adventurous artists
also wrote some simple Vb code to animate highlights and such.

This is the realization of Vb : with a solid debugger and the
possibility to abstract monkey code into GUIs, Vb made small-time
coding - the coding which does not require any knowledge of algorithms
and design - accessible to people with no or little programming
training.


If somebody is aware of a project to bring these features into a
professional language (mainstream or not), I would love to know.


Disclaimer: I used to sell my Vb programs in highschool. However, I have
not touched any Vb code since at least 1996. I switched to C, then to
C++, Java, Ocaml and then to Plt Scheme, and never went back.


-- 
  "In Google non est, ergo non est." 

- Guillaume