Evolution Guide

BASIC and it's many similar incarnations are probably the widest experienced programming language in the world and has done a lot to introduce people to computer programming and get them hooked. However, it was never designed or intended to be used for much more than teaching programming, and certainly not for writing large, practical programs; because of this fact it is missing a number of vital abilities required to write these large projects satisfactorly. This leaves the programmer with 2 options:
  1. Give up programming. This is unacceptable to the majority of people who wish to progress into the industry.
  2. Move to a new language.
For people exercising the second choice the language they move to is often C. It has experienced huge popularity explosions several times in the past and is probably the widest used language for commercial products, especially among non-time-critical applications. Now, BASIC teaches the programmer bad habits(if they were to be used straight in C) and it is often difficult to find books that teach C from the total C beginner level. The purpose of this guide is to help you take that first step beyond into a whole new world of possibilities and opportunities(I should be in PR).

Far be it for me to ignore a long time computer tradition therfore the first program I will use to explain C is the immortal "Hello World!".

/* Hello World */

#include <stdio.h>

main()
{
   printf("Hello World!\n");
}

Right, we'll go through this 1 line at a time. The first line is a comment. In C comments start with /* and end with */. Everything inside these is ignored and they can be put just about anywhere in your code. The next line is a bit more interesting. Any line which starts with # is interpreted by the pre-processor before the program is compiled. This one, #include, is probably the most important of it's commands; it looks for the file with the name that is enclosed in the angled brackets and inserts it in that position in your source file. This file,stdio.h, is the file that contains all the descriptions of the console and file I/O functions. You must include the header files(those ending in .h) which contain the functions you are using in that program or it won't compile correctly.
The next part of the program main() defines the start of a function. A function in C is much the same as a procedure in BASIC and is defined by the name of the function followed by brackets round any parameters it may have. The actual commands in the function are then enclosed in curly brackets({}). The main() function is the only one that every program must have. It is executed first and when the end of it is reached the program ends. This leaves only one line left printf("Hello World\n"); The printf function is one of C's most powerful output functions as you will see later. Here the text inside the quotes is printed on the screen. The \n pair is a special combination in C strings and it means take a new line. The semi-colon at the end of the line tells C that you are calling a function from here to be executed instead of defining one.
There, you can program C. Now we will slow things down a bit and I will go through all the common C constructs and their BASIC companions.

If

if(a == b)
{
   a++;
   if(a == 9)
      printf("a equals 9");
}
else
{
   a--;
   b = b * 2;
}
If a=b
   a=a+1
   If a=9
      print "a equals 9"
   End If
Else
   a=a-1
   b=b*2
End If
C versionBASIC version
These examples show illustrate day-to-day differences with BASIC as well as the if statement and I will explain them first. The formating of C source code makes no difference to the execution of the program so lay itout however you prefer. Semi-colons (;), these mark the end of a statement such as variable assignments and function calls.

This guide is still under construction and will be gradually updated as I write each part but it WILL be finished eventually.


Disclaimer