C/C++ Programming Language
The C and C++ language is used for most major programs and operating
systems, including Windows, Linux, and Unix. Years ago, many programs were
developed in assembly language for speed and size. But improvements in
compilers and hardware have all but eliminated the need for assembly
language programming.
Anyone, who has moved from DOS to Windows based programming, can tell
you that a Windows based program is many times more complex. While many
people use some variation of BASIC, you should give serious consideration
to leaving the limitations of BASIC behind and moving to C/C++. The
Windows operating system is written in C/C++ and when creating a Windows
based program, it is easier to program in the same language.
The BASIC programming language was originally developed as a teaching
tool and not as a program development language. BASIC was included with
the DOS operating system and as such many people starting writing programs
in BASIC. But what was quickly discovered is that memory and other
limitations made it difficult to create large programs.
The C language was originally developed as a portable language which
could be easily deployed on most types of computers. C is actually written
in C with a minimum amount of programming that is dependent on a machine's
CPU and hardware. It was possible for a version to be created for a new
computer is weeks instead of months and years. As each version worked the
same and had the same commands, it was simple to convert a program from
one computer to another. This helped propel C to the premier language it
is today.
C++ is an extension of C that adds additional capability while
retaining the original C language commands. In my mind, objects and
inheritance are the some of the most valuable features of C++. Objects and
inheritance are often difficult for the non-C/C++ programmer to grasp. The
following brief example should be helpful.
After you have programmed for a while, you realize that much of your
code is the same over and over. So you open an old project and copy/paste
the code into your new program. Then when you find a mistake, you may have
to go back and correct the code in many programs. Every time you correct a
program, you have to test that program to insure that it works as
expected. Think how much better it would be if you only had to do the code
once.
Well this is where an object comes in. An "object" can be
data, programming code, or both. Consider a hypothetical object, called
ZipCode. ZipCode will be used to store and format a postal Zip Code.
ZipCode will also have the ability to check Zip Codes for errors. The
actual source for this object will not be developed here and is not
necessary for this example.
Now when we write a new program that requires a Zip Code, the ZipCode
object is used to create one or more variables to hold Zip Codes. For
example, in an invoicing program we could create a ZipCode object called
BillToZipCode and ShipToZipCode. These two new objects are ineffect clones
of the original ZipCode object and inherit all of the capabilities of the
base object.
No additional programming is necessary beyond the code to create the
object, typically one line of code. Now when we assign a Zip Code to one
of the objects, it is automatically formatted and checked for errors. Each
program that uses the ZipCode object has the same capability without
additional programming.
Now lets assume that we discover a mistake with the ZipCode object. In
convential programming, it would be necessary to check each program
individually and correct the code. Each program would have to be tested to
insure the changes worked properly. This adds up to a lot of work.
Contrast that with our object method. All of the source code is in the
parent or base object. Therefore we only have to change the source code at
one spot. Then simply recompiling all objects that use the ZipCode object
will fix the problem without requiring each program to be tested. Control
programs, called MAKE programs, can determine if the programs needs to be
recompiled or not. This further simplifies the process.
Hopefully, this makes sense to you. I realize that this is a very
simplistic example. But applying the concepts to more complex applications
makes program generation easier. Now lets take our example one step
further.
Lets assume that we want to use the Zip Code and look up the city and
state names to lessen the workload of the user. In conventional
programming, it would be necessary to modify every program to add this
capability. This would obviously require a lot of work to accomplish.
Using our C++ object, the job is much simpler. Just load the base
object, add in the new code, recompile and all programs which use this
object now have the ability to lookup the city and state name after the
Zip Code is entered.
This should give you a little head start in understanding how the C++
language can simplify your life.