Computer Languages A to Z:

by Gary L. Ratliff Sr. (eronstuc)

This is the third in my series on computer languages. It seems that due to a mix up in a previous changing of "the guard," my promised follow up to show information on the commercial version of APL was never published. However, I did post a video of the install of APLX 4.1 on YouTube. Just search for eronstuc and you will see a list of the items I've uploaded.

With the magazine back on a monthly publication schedule, the plan is to discuss, in alphabetical order, the various programming languages that are available. In case you missed the previous articles, you can view the first, on APL, in the July, 2008 issue of the PCLinuxOS Magazine. You can view the second article, on Basic, in the October, 2008 issue.

This article will concentrate on C and C++. C is the language which was used to port the original Unix operating system from the assembly language for the PDP computers it was originally written with. Due to its wide acceptance, it was responsible for the growth of Unix and was used to write most of Linux. This can easily be learned by anyone who choses to pursue the reading of the source code of the operating system.

KDE, on the other hand, uses C++ for its applications. C++ is a superset of C and the current version of C++ supports all the features of the C89 standard for the C language. However, some new features for C were introduced by the C99 standard, and these new features are not incorporated into the current C++ standard. However, a recent email to me from Herbert Schildt who was a member of the C++ standardization committee let me know that many of the features which are not included in the current version of the C++ language, which are part of standard C99, will be incorporated into the next standardization of the C++ language.

Preparing your computer to program in the C/C++ languages

As I have upgraded from PCLinuxOS 2007 to PCLinuxOS 2009.1, I believe that the gcc compiler is a part of the tools on the default install. At first gcc meant the GNU C compiler. Now it refers to the GNU Compiler Collection and, at present, this contains front ends for C, C++, Objective-C, Fortran, Java, and Ada. You may easily verify if you presently have this compiler installed by entering "gcc -v"in a terminal window.

If you receive a file not found message, then you will need to also install the gcc package. That the g++ front end for the gcc suite is not installed by default may be learned by entering "g++ -v" instead of the gcc line as above. This should generate the file not found message. Now, to install the g++ compiler, you will need to become root:

su
<enter the root password>
apt-get install gcc-c++

Here the system will analyze your currently installed software and list all the dependencies required to upgrade your system to be able to compile C++ code. This will almost always include the libstdc++ libraries. While you are at it you might as well install the debugger program gdb by issuing the command:

apt-get install gdb

This operation may also be performed using synaptic. Just use the search feature to find c++ and then later gdb. Here you will learn that gdb is a source level debugger for the C, C++, and Fortran languages.

Here synaptic reveals that the c++ front end for the GNU Compiler Collection has been installed.

Next we will list all the books which were used as a reference for this article. The following books are reliable reference materials to help you learn to learn to write and compile applications in these languages:

  • Reference Materials to Aid in Learning C/C++
    The Complete Reference C Fourth Edition
    by: Herbert Schildt
    Copyright © 2000 by The McGraw-Hill Companies
  • C++ ALL-IN-ONE DESK REFERENCE for DUMMIES
    by: Jeff Cogswell
    Copyright © 2003 by Wiley Publishing, Inc., Indianapolis, Indiana
  • Beginning Linux Programming 4th Edition
    by: Niel Matthew, and Richard Stones
    Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
  • The Beginners Guide to C++
    by: Oleg Yaroshenko
    Published by Wrox Press Ltd. Birmingham, UK

Practice Practice Practice

This last mentioned book is out of print. And, as a result, all the example programs were typed into my system and saved to an area named mycpp on the C:partition of my Windows system.

There are several advantages to getting these books. The Jeff Cogswell volume comes with a CD which contains all the source code, as well as some very useful development systems for use with Windows. (Yes, I realize that this is on PCLinuxOS, but there is also a chance may dual boot your computer with some Windows Operating system.) You may as well develop programs from the tools supplied with these books, as they are free with the purchase of the book. The source code for the texts by Schildt and the Matthew/Stone may be obtained from the web sites of the respective publishers. In each case, once you arrive at the site, enter the name of the volume into the search engine, and soon you will receive a message which will have a download tab. When the item is downloaded, it will be in either zip format or tar.gz. So if you have the GNU version of the tar utility (which is the case with Linux) you can unzip and untar in one simple step:

tar -zxvf 780.........tar.gz (or tar -zxvf 780......tgz)

The volume in zip format will be extracted with just the gunzip command. Now some of the volumes will have each chapter, also in a tarred and gzipped format. Once the source file is displayed, you will move it into an area from which it may be compiled and setup to run on your system. In my case, the archive was stored on the desktop and I created a bin and csource directory to the /home/gary area. Also by copying or moving them, you will acquire the necessary permissions to operate upon the files.

The Cogswell volume contains a Dev-C++ IDE, which will allow compiling all the examples in his text. The Dev-C++ is also available in a Linux version. Its main advantage is allowing compiling multi-source systems, without the need to create a makefile. This CD is obtained from them and also contains many other files, including a system for compiling Pascal. Also in the compiler area are versions for a command line Borland C/C++ compiler, and Windows versions based on the gcc compiler for MinGw and Cygwin. Cygwin gives your Windows system a system which runs most familiar Linux commands.

The text is available in bookstores. However, the comment to contact the author of the book, either at his website or via email, will not yield any reply other than to learn that these are not available. Writing to the publisher directly will resolve most problems. This will even give a pointer which will allow you to acquire the very powerful Borland 2006 Builder Software Development System. Once you get setup with a password to download and install the package, you learn that this expires in 37,750 days. Don't worry that translates into more than 97 years and if you are old enough to be reading this article you are very likely not going to have the software expire before you.

The C and C++ languages are both classified as simple because they have very few built in commands. What gives them their power is the vast number of libraries which have been developed, which allow you to easily harness systems developed by many skilled programmers who have gone before you. You can learn either language by just reading the books. That comes from reading and entering in the programs and compiling them. Most errors will soon be found to be key in errors if you manually enter the text of the programs. Having the source code readily available as zip files for you to download will greatly reduce this problem.

When reaching the end of the Beginning Linux text, the last two chapters deal with developing GUI applications for GNOME and KDE. Here you will need to install the libraries for these systems. PCLinuxOS has a version which is based upon KDE and another version which is based upon GNOME. For the GNOME desktop environment, you will need to install the GTK+ development libraries. For the KDE desktop environment, you will need to install the KDE development libraries. Working through the text, it was amazing just how easily the GUI systems were created. The GTK+ libraries add GObject, which adds object orientated features to the C language.

The Cogswell text will also introduce you to the very powerful SciTE editor. This editor has highlighting for very many different computer languages. It also will automatically indent the text as required for the various levels of the code. Proper indentation would be ignored by the compiler but makes the text much more easily understood by you or a fellow programmer who is attempting to track down an elusive bug. The SciTE text editor is available in the PCLinuxOS repository.

These volumes also cover using the debuggers in some detail. The Cogswell text comes with the Insight Debugger, which is useful for finding errors on items developed on Windows. The Matthew/Stones text covers the use of the gdb product.

So if you have ever wanted to learn to program or to learn how your computer functions in some detail, learning C and C++ is the required first step to being able to understand the source code of the system. The Beginning Linux Programming text is not really for beginners, but gives the person a comprehensive understanding of how the features of Linux are used in the development of computer applications. Such a deep understanding will make your perusal of the source code productive.

Other Sources for Learning C++

The text books suggested are not the only methods of learning the C++ language. By performing a search in Google for C++ tutorials, you will learn that there are several. Microsoft will even allow you to download an older version of their Visual Studio C++ development package. Included is a video by one of the software engineers from Microsoft which illustrates how to use their product. However, my experience with the free Visual Studio C++ was that all programs entered failed to function because a cmd file could not be be found. I verified that I had downloaded the version for the XP, as cmd files are used in NT. However, this same site suggested that if you were just learning C++, you should visit a tutorial site where you could download twelve lessons in PDF format, which teach the C++ language.

Here you can see that if you select the free Borland builder product that once you register you will have plenty of time to use the system. 354975 / 365 shows that your registration will still be good for over 97 years. If you saved this to CD for backup the CD is only known to be safe for 30 years!! By this time Microsoft will have thrown in the towel and gone open source so that it too can have the best software developers in the world fixing its code.