Quirks of VBScript
or More reasons VBScript is the work of the Devil
These are some of the annoying
which made me scream
at the computer
while learning VBScript. I've now been using VBScript for 3 years, and use it currently for my job. It's not a bad scripting language once you learn the quirks, but if you're coming from a real
programming language background
etc...) you'll hate it at first (and maybe forever).
If ... Then ... Else ... End If
a. Why Then? Four extra characters you have to type every time you write an If statement.
b. Logically, if the code is If ... End If, then wouldn't you expect an Else If statement to take the same form as the End If? It doesn't. It's one word - Elseif.
The While statement
Nearly every control statement in VBScript takes the form Command ... End Command. For example:
- If ... End If
- With ... End With
- Select Case ... End Select
- Function ... End Function
So logically, wouldn't it be While ... End While
? Yes it would. But it isn't. It's While ... Wend
. Why? Maybe they were trying to make up for having you type 4 extra characters in every If statement.
No ++ operator (or +=, -=, etc...)
Why leave out these easy to use and learn operators? Instead, you have to write variable = variable + 1 every damn time.
= is for equality AND assignment
This is just plain confusing.
'variable = 5' is an assignment, but 'If variable = 5 Then' is boolean logic and DOES NOT assign anything to variable.
In computer science, one of the first things you learn is that you count from 0, not from 1. For example, an array in Java declared so,
int myArray = new int;
would be indexed from 0 to 9 (ex. myArray
gives you the 6th element of the array) for a total of 10 elements.
obviously assumed that no one using VBScript would be able to figure this out, and so in VBScript when you declare an array so,
the 10 specifies the upper index of the array, not the size. So the VBScript myArray
is actually an array of 11 elements, indexed 0 to 10. This might make sense if they indexed starting with 1, so that it was still an array of 10 elements, but as it is this just cries out
for people to write bad code
. Witness the quote below, from my professor
in a Business Computing Technology
"The 0 index confuses me when I'm programming, so I don't use it and I recommend you don't either."
So here we have an entire class being encouraged to write code which eats
, for convenience
Stuff like this makes baby jesus cry