Visual Basic
| My Choice |
C / C++
|
| Structured Language | ||
| _vbc |
|
| Low Level Operations Possible (Apparently this is regarded highly ???) | ||
Binary Operations: ![]() Address Operator: ![]() Visual Basic never requires the use of an address operator for variables, however there is the AddressOf operator used to pass functions to external procedures as function-pointers. | _vbc |
Binary Operations: ![]() Address Operatior:
|
| Portability (Sadly, I'm trying to be unbiased) | ||
| I don't know the history, but for some unreasonable reason, Basic is only developed by Microsoft, which naturally means that only Windows can run it. Although as far as I know, some Windows emulators do work for VB programs on other platforms. I have also heard rumours about Microsoft making a Basic compiler for Linux. |
| Very portable. |
| Structured English | ||
|
And Or Not Xor Mod ByRef End [Block] Seems like English to me. |
|
&&, & ||, | ! ^ % * (pointerise) } !! Rubbish Rubbish Rubbish !! |
| Pointers | ||
|
References: References cannot be made to raw data-types, but who needs that; only to objects(from classes). Passing By Reference: Any data-type can be passed to a function by-reference using the keyword ByRef in the function's declaration. No other code need be written in the called function or calling function; the reference is treated like any other variable. Linked Lists: This is the only other sane use for pointers. Visual Basic provides dynamic arrays (variable length arrays) and "collections" for any purpose where a C programmer would use a linked-list. Besides, you could still make a linked-list using true references. Function Pointers? See Low Level Operations. |
|
References: Declare a pointer of the same type, and copy the address of another variable to it. (Rubbish!) Then, dereference it using the same notation used to declare the pointer (which is also the same operator as multiplication) (OMG!) Passing By Reference: Same notation as local pointers. Linked Lists: These are the only other use for pointers I can think of, yet you could still make a linked-list in Basic using true references, but why would you? (See other side) Function Pointers? Yup. |
| Statement Termination | ||
|
One statement per line, no terminating character, unless: - You want to put multiple statements on one line. Use the colon (:) to separate these statements. - You want to spread one statement over multiple lines. Use the underscore (_). Everything is so clear. |
|
Always use a semi-colon to separate statements, no matter what. (Rubbish!) |
| Array Lower Bound | ||
|
Zero, by default, or change the default to 1, or personally specify explicitly. Option Base 1Dim oneTofour(4) Dim myArr(4 To 9) |
|
Always zero. int zeroToThree[4];int myArr[6]; |
| Booleans | ||
|
True = -1 or non-zero, False = 0 Visual Basic does not have separate 'gate' operator for booleans and bitwise-ops. 'And', 'Or', 'Xor' and 'Not' all apply the bitwise operation on integers, and the boolean operation on booleans. Simple. |
|
True = non-zero, False = 0 Logic-gate operations are separate between booleans and bitwise-ops. Boolean: && (and), || (or), ! (not). Bitwise: & (and), | (or), ^ (xor), ! (not). Or the designers could have just made booleans separate to regular integers. And what's wrong with using words, as long as they're small? |
| Strings | ||
|
Basic offers the built-in data-type, "String", where the memory used is #BytesInString+2. ie. it dynamically allocates memory based on the size of the string. Data within the strings is treated as though the data belongs in the variable, ie. there are no pointers/references about it (they're internal). You can still use character-arrays if you want (but that would be pointless), or have fixed-length strings. |
|
Create a fixed length char-array, in which you must leave room for a terminating character (chr(0), '/0'). Or you can include the string.h file and use strings as in Basic. |
| Object Orientation | ||
|
Structures: Classes: Polymorphism: element1 As Integer element2 As Boolean element3 As String End Type [Too hard to show a class definition] |
|
Structures: Classes: Polymorphism: int element1 int element2 char * element3 } #typedef struct someStruct myStruct [Too hard to show a class definition] |
| Compilation | ||
|
Always Interpreted when run through the editor, but when creating the .exe file, you have the choice of compiling to p-code (interpreted) or to native code. | _vbc |
Fully compiles to native code, even when you're not finished. |
| Testing / Debugging / Errors | ||
|
Syntax: Checks the syntax of each line when you 'lose focus' of that line, marks it red (default) if there is a syntax error and MsgBoxes you about it (optional). Semantic: Built-in use of break-points, step, step-out, step-over, run-to-cursor, etc. Run-Time Editing: You can pause the program, make changes to the code, then continue without recompiling. Why? It's an interpreted language. Restrictions apply of course, like you can't add a new function - that certainly needs to be recompiled. Immediate Window: You can pause the program, then type any statement in the immediate window to run that statement without it being in the program. Great for testing new functions and viewing variable details. Watch Window: Yup. |
|
Syntax: You don't know you have a problem until you try to compile it, then tells you there are 38 errors, 90% of which, the accused error is on a different line to where the error actually is. Semantic: Depends on your editor. Some good editors have the same features as Basic, but aren't always implemented very well. Some require you to compile first, then use a separate program to debug. Run-Time Editing: You must be joking. Immediate Window: Nope. To print your variables, you have to actually modify your program to print them every iteration! (And you should already know how painstaking it is to have to recompile.) To test your functions, you must type up a main() function, then later, after putting in a real main() function, you decide to change one of your first functions, and have to go stuff up your main() function again to fix it. Watch Window: Depends. |