What does DIM stand for in Visual Basic and BASIC?

208,509

Solution 1

Dim originally (in BASIC) stood for Dimension, as it was used to define the dimensions of an array.

(The original implementation of BASIC was Dartmouth BASIC, which descended from FORTRAN, where DIMENSION is spelled out.)

Nowadays, Dim is used to define any variable, not just arrays, so its meaning is not intuitive anymore.

Solution 2

Dim have had different meanings attributed to it.

I've found references about Dim meaning "Declare In Memory", the more relevant reference is a document on Dim Statement published Oracle as part of the Siebel VB Language Reference. Of course, you may argue that if you do not declare the variables in memory where do you do it? Maybe "Declare in Module" is a good alternative considering how Dim is used.

In my opinion, "Declare In Memory" is actually a mnemonic, created to make easier to learn how to use Dim. I see "Declare in Memory" as a better meaning as it describes what it does in current versions of the language, but it is not the proper meaning.

In fact, at the origins of Basic Dim was only used to declare arrays. For regular variables no keyword was used, instead their type was inferred from their name. For instance, if the name of the variable ends with $ then it is a string (this is something that you could see even in method names up to VB6, for example Mid$). And so, you used Dim only to give dimension to the arrays (notice that ReDim resizes arrays).


Really, Does It Matter? I mean, it is a keyword it has its meaning inside an artificial language. It doesn't have to be a word in English or any other natural language. So it could just mean whatever you want, all that matters is that it works.

Anyhow, that is not completely true. As BASIC is part of our culture, and understanding why it came to be as it is - I hope - will help improve our vision of the world.


I sit in from of my computer with a desire to help preserve this little piece of our culture that seems lost, replaced by our guessing of what it was. And so, I have dug MSDN both current and the old CDs from the 1998 version. I have also searched the documention for the old QBasic [Had to use DOSBox] and managed to get some Darthmouth manual, all to find how they talk about Dim. For my disappointment, they don't say what does Dim stand for, and only say how it is used.

But before my hope was dim, I managed to find this BBC Microcomputer System Used Guide (that claims to be from 1984, and I don't want to doubt it). The BBC Microcomputer used a variant of BASIC called BBC BASIC and it is described in the document. Even though, it doesn't say what does Dim stand for, it says (on page 104):

... you can dimension N$ to have as many entries as you want. For example, DIM N$(1000) would create a string array with space for 1000 different names.

As I said, it doesn't say that Dim stands for dimension, but serves as proof to show that associating Dim with Dimension was a common thing at the time of writing that document.

Now, I got a rewarding surprise later on (at page 208), the title for the section that describes the DIM keyword (note: that is not listed in the contents) says:

DIM dimension of an array

So, I didn't get the quote "Dim stands for..." but I guess it is clear that any decent human being that is able to read those document will consider that Dim means dimension.


With renewed hope, I decided to search about how Dim was chosen. Again, I didn't find an account on the subject, still I was able to find a definitive quote:

Before you can use an array, you must define it in a DIM (dimension) statement.

You can find this as part of the True BASIC Online User's Guides at the web page of True BASIC inc, a company founded by Thomas Eugene Kurtz, co-author of BASIC.


So, In reallity, Dim is a shorthand for DIMENSION, and yes. That existed in FORTRAN before, so it is likely that it was picked by influence of FORTRAN as Patrick McDonald said in his answer.


Dim sum as string = "this is not a chinese meal" REM example usage in VB.NET ;)

Solution 3

It's short for Dimension, as it was originally used in BASIC to specify the size of arrays.

DIM — (short for dimension) define the size of arrays

Ref: http://en.wikipedia.org/wiki/Dartmouth_BASIC

A part of the original BASIC compiler source code, where it would jump when finding a DIM command, in which you can clearly see the original intention for the keyword:

DIM    LDA XR01             BACK OFF OBJECT POINTER
       SUB N3
       STA RX01
       LDA L        2       GET VARIABLE TO BE DIMENSIONED
       STA 3
       LDA S        3
       CAB N36              CHECK FOR $ ARRAY
       BRU *+7              NOT $
       ...

Ref: http://dtss.dartmouth.edu/scans/BASIC/BASIC%20Compiler.pdf

Later on it came to be used to declare all kinds of variables, when the possibility to specify the type for variables was added in more recent implementations.

Solution 4

Dimension a variable, basically you are telling the compiler that you are going to need a variable of this type at some point.

Solution 5

It stands for Dimension, but is generally read as "Create Variable," or "Allocate Space for This."

Share:
208,509

Related videos on Youtube

Nick Katsivelos
Author by

Nick Katsivelos

New Media Old Timer @FamilyCTO Family CTO Site On LinkedIn

Updated on May 17, 2021

Comments

  • Nick Katsivelos
    Nick Katsivelos almost 3 years

    What does Dim stand for in Visual Basic?

  • Chris Simpson
    Chris Simpson almost 15 years
    a little background might help. In early releases of basic the only variables that needed to be declared were arrays. The "Dim" keyword was used to set the dimensions of this array.
  • jocull
    jocull about 12 years
    I've heard "declare in memory" also.
  • RandyMorris
    RandyMorris over 11 years
    I remember reading a gw-basic programming guide in the early 80's and I explicitly remember it explaining DIM meaning Declare In Memory. Reading the Darthmouth Basic guide from '64 has LET and READ statements assign variables and their values and later in '68 DIM is included and in fact is used for arrays. bitsavers.org/pdf/dartmouth/BASIC_4th_Edition_Jan68.pdf
  • zumalifeguard
    zumalifeguard over 9 years
    One thing to keep in mind is that, in early language development, it was common to overload a keyword to have multiple meanings. Since, in the original Basic, "Dim" was already a keyword used to declare array variables, the keyword was extended to include declaring all variables. Introducing a new keyword was avoided for multiple reasons, one of which is they didn't want to break existing programs who already used the new keyword as a variable name. Today we have more sophisticated parsing technologies and faster computers, we don't see those types of limitations.
  • zumalifeguard
    zumalifeguard over 9 years
    For instance, in later Basic, such as Visual Basic, a type and a variable could be the same name. A great example of a keyword that was overloaded too much is "static" in C++. It means different things in different contexts.
  • Deanna
    Deanna almost 9 years
    Welcome to StackOverflow and thank you for this answer, but it doesn't really expand on the numerous other answers that all give the same answer.
  • John Cummings
    John Cummings over 6 years
    For those looking at the great BASIC manual @RandyMorris linked to, the first reference to DIM is on page numbered 21 or it is page 26 in the PDF itself. The more formal definition is on page numbered 37 or 41 in the PDF itself.
  • Jacob Stamm
    Jacob Stamm almost 4 years
    "Really, Does It Matter?" Underappreciated joke. Also I am now going to insist to people that this is what Dim actually stands for