Which Compiler Should I Choose for my PC?

Several C++ compilers are available to you. We are making Turbo C++ 4.5 available to the class because it is compatible with typical PC hardware and it is reasonably priced. It may be accessed from the network in the computer lab. Turbo C++ has limitations, so you might consider buying a different compiler to suit better your needs. There is also one copy of Symantec C++ 7.0 available on a computer in the lab if you would like to try it. Symantec's compiler has more features which are useful to us, but it is more expensive and requires more memory than you may have.

In general, there is no easy answer to which compiler is best because each has its advantages and disadvantages. This document describes several compilers, each of which is suitable for this class. (My advice for Macintosh and Windows NT compilers is limited since I have not tried using C++ on machines using these operating systems.) I will do my best to help you no matter which C++ compiler or operating system you use.

Things to Consider

32-bit vs. 16-bit compilers

Turbo C++ creates 16-bit programs only. If you have an Intel 80386, 80486, Pentium, or equivalent clone processor, your computer is capable of handling 32-bit instructions. Therefore, 16-bit applications created by Turbo C++ (and other 16-bit compilers) are unlikely to utilize optimally your processor. Memory allocation problems arise with 16-bit applications because only 64 kilobytes of memory are addressable without advanced memory management techniques. By comparison, at least 4 gigabytes of memory are addressable in a 32-bit application. Our class-time is better spent learning C++ rather than how to deal with these problems since the trend is toward 32-bit and 64-bit operating systems. (Windows 95 represents Microsoft's move to a 32-bit operating system from the 16-bit MS-DOS/Windows 3.x operating system.) Unfortunately, commercial 32-bit compilers are more expensive and tend to have ``bells and whistles'' which can confuse novices. Turbo C++ is fine for learning C++, but please be aware that some of its limitations are not features of C++. If cost is not an issue for you or you are certain that you will use C++ in the future, you should consider buying a compiler which compiles 32-bit programs. We have listed several such compilers below.

Optimization

Advances in computer chips often involve advances in the way that they handle instructions. The Intel line of chips (and its clones) is backwards-compatible, meaning that programs written for the 80386 or 80486 are compatible with the Pentium. However, the Pentium has features which the earlier chips do not, and likewise the 80486 has features which the 80386 does not. Many compilers optimize code with regard to a particular processor. (An optimizer may recognize that you have written inefficient code or it may organize the generated machine code differently depending on the processor.) Turbo C++ does not, so executables created by Turbo C++ are compatible with the 80386 or above. Symantec C++ and Borland C++ do have code optimization. Optimizers can make compilers more expensive. For example, Microway's NDP C/C++ compiler for a Pentium/486 costs $995 while the 386 version costs only $695 (from an advertisement in the Linux Journal, December 1995).

Libraries

Libraries can be a substantial part of the ``bells and whistles of a compiler. Compilers which meet the ANSI-C standard and the still-evolving ANSI-C++ standard are required to have certain basic libraries (like the iostream and math libraries we use), but they are allowed to have more. Turbo C++ has a proprietary library called ``Object Windows Library,'' or OWL. This library is designed to be a simplification of the Microsoft Foundation Classes (MFC), a library for generating Windows applications. Symantec C++ and Microsoft Visual C++ use MFC. C++ programs using features of OWL may not compile under Symantec C++ unless you purchase these libraries. Likewise, programs using either OWL or MFC may not compile on UNIX platforms. Compilers for UNIX may have libraries for things like X-Windows or Motif that are not portable to other platforms. Many compilers have user interfaces to simplify code generation for building other user interfaces. (This is what AppExpert does in Turbo C++ 4.5.) To further confuse things, even required libraries may be more efficient under one compiler than another. Better and more extensive libraries tend to cost more.

The upshot is that what you plan do with C++ outside of this class may influence the libraries, and hence the compiler, you need.

COMMERCIAL COMPILERS

Symantec C++ 7.0 or 7.2

I have version 7.0 of Symantec C++. It seems to work better with Windows than does Turbo C++, and I like its Integrated Development Environment (IDE). Version 7.0 is touted as being designed for heavy-duty software developers; however, it requires 16MB of RAM. It has the ability to compile and link from a command line, which will make things simpler for first-time programmers. A copy of this compiler is available in the computer lab if you want to use it to create 32-bit executables.

Symantec 7.0 is available for the Mac.

Borland C++

Borland C++ also supports applications for DOS, Windows 3.x, Windows NT, and Windows 95. The IDE should be quite similar to Turbo C++ 4.5; however, Borland C++ has a much higher price tag. Borland C++ is available for OS/2. Borland's compiler seems to have more books written than does the Symantec C++ compiler.

Others

There are many commercial compilers. Microsoft Visual C++ is popular among Windows program developers and is in the same price range as the Borland and Symantec compilers. There are several compilers which cost several hundred dollars or more. Check out industry magazines for Windows developers and C++ users for more information. (Library Ltd. and some magazine stores in the Central West End carry these.)

FREE COMPILERS

GNU C++

The GNU Project -- which stands for GNU's Not Unix -- was started by the Free Software Foundation and maintains ports of a surprisingly large amount of software, including a good C++ compiler. A drawback is that documentation on the compiler (as well as other GNU software) is often hard to find. However, GNU has a cult-like following that seems to be very supportive of new users.

The Free Software Foundation requires that the source code for any application created under its license be freely available. This means that the C++ code used to create the GNU C++ compiler is available. The MS-DOS version of the GNU C++ compiler is called DJGPP (after the person who ported it to DOS) and is available on the Internet. Here is a description of the compiler given there.

   This package contains a 32-bit DOS extender with symbolic debugger,
   a C/C++ compiler with utilities, development libraries, and source
   code.  It generates full 32-bit programs and supports full virtual
   memory with paging to disk.
You can ftp this compiler and its source code from
ftp://wuarchive.wustl.edu/SimTel/vendors/djgpp/
or any other mirror of the SimTel site.

Instructions are located in the files readme.1st and readme.dj. DJGPP supports 32-bit applications, but the installation procedure requires you to have some knowledge of basic unarchiving and decompressing techniques. I have hard copies of some of the documentation if that is more convenient for you. I am considering whether to install this compiler on my computer. I will let you know the results if I do. (If you are interested in this compiler, let me know and maybe we can do the installation together.)

I have seen references to a new GNU C++ compiler for Windows 95 and NT. Here is a potential location:

ftp://ftp.cygnus.com/pub/sac/win32
The GNU C++ compiler is also available for other platforms, including the PowerPC, Sun, and Alpha platforms.

Linux

This provides an alternative to the MS-DOS/Windows operating system entirely. Linux originated as a graduate project for a student at the University of Helsinki, and has since turned into a full-featured UNIX-like operating system supported by volunteers around the world. The GNU C and C++ compilers form the backbone of Linux and are included in its distribution. It is a 32-bit multiuser/multitasking operating system, so several people can simultaneously use your computer. Linux is licensed under the Free Software Foundation, so its C++ source code is freely available. In fact, upgrades to Linux are distributed as source code which you compile on your own computer. On a PC running MS-DOS, Linux may be installed with no changes to MS-DOS or Windows. Linux is soon to be available for several platforms, including the PowerPC, Alpha (DEC), and Sun workstations.

If you are interested in Linux, see me or check out the WEB page

http://www.ssc.com/linux/linux.html

I find that even programs without significant memory requirements compiled under Linux with the GNU C++ compiler often require 20% or less of the CPU time required by the same program under DOS. Programs with substantial memory requirements will probably run even faster under Linux.