Visual Basic is Microsoft's implementation of the BASIC programming language (point is: it's not a language, it's a language implementation). BASIC was originally designed as beginner's language, it is designed so ordinary people can write programs (this is important in the past, when software distribution wasn't as developed as now). This is how a typical VB program looks like:
' note: This is VB.NET syntax
' comment starts with '
REM an older style comment uses the REM keyword
REM the function finds the highest number in an array
Private Function max(ByRef arr() As Integer)
Dim currentMax = arr(0)
For Each number In arr
If number > currentMax Then
currentMax = number
Next number
Return currentMax
End Function
BASIC's has type inference, notice that in "Dim currentMax = arr(0)" line I did not declare currentMax's type. BASIC does not require type declaration and this is often convenient for newbies, but this also often leads to subtle bugs (e.g. if you mistyped a name).
BASIC is verbose and uses very little symbols apart from mathematical symbol, instead it uses keywords (Then, Next, End Function). In BASIC, array is accessed using parentheses, it's the same syntax as function call which might be confusing sometimes
Visual Basic is Microsoft's implementation of the language, have a tight integration with the Window's GUI-builder. Building GUI in VB is among the easiest among the languages I know of.
C is originally developed for UNIX system programming language. The language was simple and minimalistic since it is designed to be fairly easy to write a C compilers for a new platform. Due to this, there are C compilers for even a very exotic platforms. The language was designed to write OS kernel, hardware drivers, and various other low-level jobs. This is how a typical C program looks like:
#include
// the program finds the highest number in an array
int max(int[] arr, int arr_length) {
int i;
int currentmax = arr[0];
for (i = 0; i < arr_length; i++) {
if (arr[i] > currentmax) {
currentmax = arr[i];
}
}
}
int main(void) {
int i;
int[] arr = {2,3,6,2,7};
for (i = 0; i < 5; i++) {
print("%i\n", max(arr, 5));
}
return 0;
}
C uses braces instead of keywords to delimit blocks, and every statement ends with a semicolon ";". Unlike VB, C is case-sensitive, that means max and MAX and mAX and MaX is four completely different names in C. C is strictly-typed language, every variable must be declared and its type must be explicitly specified (unlike Basic where you can sometimes omit them). This makes for a more robust code (mistyping will generate a compile-time error).
C++ is C with support for object-orientation. As you go along with programming, you'll learn about Object-oriented programming. A C++ programs looks like C program, though there are differences in what the two languages considers as best practices due to the lack of object-orientation in C. This is how a typical C++ code looks like:
#include
using namespace std;
// the program finds the highest number in an array
int max(int[] arr, int arr_length) {
int i;
int currentmax = arr[0];
for (i = 0; i < arr_length; i++) {
if (arr[i] > currentmax) {
currentmax = arr[i];
}
}
}
int main(void) {
int[] arr = {2,3,6,2,7};
for (int i = 0; i < 5; i++) {
cout << arr[i] << endl;
}
return 0;
}
The short program does not showcase the difference between C and C++ enough. Indeed object oriented is only useful on a mid-sized to large program. Unlike Java, C++ does not force you to use object orientation (you can write your program in procedural way if you wish in C++).
Python is my personal favorite language. Python's strength is a very clean syntax and a very large standard library, and the REPL (Read-eval-print-loop, will describe later). This is how a typical python code looks like:
# actually, there is a max() built-in function that does this
# but if I used that we're kinda missing the point...
def max(arr):
currentmax = arr[0]
for number in arr:
if number > currentmax:
currentmax = number
a_list = [2, 3, 6, 2, 7]
print max(a_list)
Python uses indentation (whitespace) to delimit blocks of code, the indent is part of the syntax. This is unlike C/C++ which uses braces {} or BASIC which uses keywords (Next, End If). This reliance on indentation makes for a clean syntax, you don't need to worry about unmatched braces/keywords and forces programmer to indent their program properly.
The other strength of python is the huge standard library. Often you'll find that you won't need to write any code (or you can cut down the lines of code you write) because you'll find that the standard library already contains what you want to do. The standard library contains lots of thing you'll ever need like HTML/XML, GUI, string processing, regular expression, email/MIME, urllib, zip/bz2/gzip compression, cookie, ftp, cryptographic hashing, diff, url manipulation, OS-agnostic path manipulation, XMLRPC, profiling, unittesting framework, data structures, datetime manipulation, and others.
A unique feature of python is the python shell, you can start the python shell and *interactively* write programs while the interpreter prints the result of computation (this is called Read-Eval-Print loop http://en.wikipedia.org/wiki/Read-eval-print_loop). This is a typical REPL session:
C:\>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> arr = [2, 3, 4, 2]
>>> max(arr)
4
>>> def foo(n):
... print n + 20
...
>>> foo(10)
30
>>> 10 + 20
30
>>> 'hello world'
'hello world'
>>> import math
>>> help(math.sin)
Help on built-in function sin in module math:
sin(...)
sin(x)
Return the sine of x (measured in radians).
>>>
The REPL is useful while learning language as it makes experimenting easy, you don't need to go through the length compile, execute step. The REPL is also useful as a very powerful programmable desktop calculator. Python has infinite precision integers built into the language, which means your numbers can be as large as your computer's memory allows. This is unlike BASIC and C/C++ which has a maximum size on their integers (typically 2**32 or about 4 millions on 32-bit machine, though it varies by the compiler). On other languages you *can* use an external library for infinite precision integers, but a built-in language support offers seamless integration with the rest of your code.
My suggestion is to start with Python. Python is very easy to learn, it is as easy as BASIC but is much more better designed. Many people complained that BASIC teaches bad practices and programmers that only ever uses BASIC would never be a good programmer. I don't personally believe that as I start with BASIC. C/C++ is a good language, but they're difficult to learn since you have to manage low-level stuffs yourself. I would only recommend C/C++ after you've got a good grasps of the fundamentals of programming. Avoid C# at all costs, it's a cheap Java-clone; and Java bests out C# at all aspects, and C# cannot be used for systems programming unlike C/C++.