home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / WHICH_C.TXT < prev    next >
Text File  |  1997-07-05  |  23KB  |  457 lines

  1. +++Date last modified: 05-Jul-1997
  2.  
  3. Q:  Which PC C/C++ compiler is best and what should I buy?
  4.  
  5. A:  This is perhaps the commonest of Frequently Asked Questions (FAQ's),
  6. especially by beginning C'er. The honest answer is that there is no "best"
  7. compiler and what may be best for you depends to a large degree on what
  8. you'll be using it for. The PC C/C++ compiler market is quite brutal and the
  9. companies that have survived have done so because some number of people think
  10. each of them makes the "best" compiler.
  11.  
  12.     With the preceding caveat in mind, following are some summaries of the
  13. current crop of C/C++ compilers with some of their strengths and weaknesses.
  14. Additional recommended reading are the C/C++ compiler reviews appearing in PC
  15. Magazine. PC Mag's reviews for many years were highly slanted and suspect,
  16. but, in recent years, have become commendably objective and even-handed.
  17.  
  18.  
  19. MIX POWER C
  20. -----------
  21.  
  22. Power C is the least expensive PC C compiler on the market. The compiler
  23. itself is $20, and an additional $30 will buy their source-level debugger
  24. along with the complete library source code with an assembler.
  25.  
  26. So, what's the catch?
  27.  
  28. None, actually. Power C is a quite decent and ANSI-conforming compiler which
  29. compiles relatively tight, fast code relatively quickly. It's biggest
  30. drawback is its use of a non-standard object file format which obviates
  31. object-level compatibility with any other compiler using Microsoft/Intel
  32. standard object file formats. Another problem is lack of support from 3rd
  33. party library vendors. Although Mix sells a wide range of libraries
  34. themselves, it's difficult to convince a vendor to produce a $100 add-on
  35. library for a $20 compiler.
  36.  
  37. On the plus side, Power C comes with the best user's manual for students in
  38. the business. The beginner's tutorial section has enabled many beginning C
  39. programmers to get up to speed without spending another dime on any other
  40. textbooks. Should you want more instruction, Mix sells a package including
  41. Power C with the library source and debugger along with the book "Master C"
  42. for only $60.
  43.  
  44. Power C's primary technical claim to fame is its floating point which
  45. challenges the industry leader, Watcom, in many cases. It's also the only
  46. remaining C compiler which can run effectively on small or older machines
  47. without extended memory (SC++ can also, but is limited to *very* small
  48. programs).
  49.  
  50.  
  51.  
  52. MICROSOFT VISUAL C++ (VC++)
  53. ---------------------------
  54.  
  55. Microsoft's professional compiler now comes in two versions with the same
  56. name but different version numbers.  Version 1.52 is the current 16 bit
  57. compiler, and supports DOS and Windows.  With some care (and libraries from
  58. MS C 6.0) people have gotten it to produce programs for OS/2 as well, but
  59. this proposition is not for the faint of heart.
  60.  
  61. Visual C++ 2.x supports only Win32 targets.  (Windows NT and Windows 95)
  62. It bears a reasonable similarity to the 16 bit compiler, but many of the
  63. ancillary tools have changed, particularly those that deal directly with
  64. executables, which isn't surprising since the executables themselves have
  65. changed considerably.
  66.  
  67. On the plus side, VC++ is an excellent C++ compiler and generates executables
  68. which may not always be smaller than Borland, but usually execute faster.
  69. Microsoft's C compilers are still the standard for PC C compilers and it
  70. shows in the ready availability of 3rd party libraries supporting it. Support
  71. for Windows programming is excellent with tools only rivaled by SC++ (which is
  72. shipped with licensed copies of the MFC class library).
  73.  
  74. Compile times with full optimization are still quite sluggish, but using the
  75. quick compile option can be provide acceptable results.  The 32 bit compiler
  76. has no explicit quick compile option, but compile times with optimization
  77. turned off are fairly reasonable.
  78.  
  79.  
  80.  
  81. BORLAND C++ (BC++)
  82. ------------------
  83.  
  84. BC++ carries on Borland's tradition of providing excellent bang for the buck.
  85. The latest release (4.5) of their professional compiler is an attractive
  86. alternative to shops also considering VC++. BC++ isn't as demanding as VC++
  87. but still requires considerable resources.  However, the 32 bit compiler is
  88. one of the few 32 bit versions to still run under DOS, reducing its hunger for
  89. memory considerably compared to VC++ and SC++, which both require 16 Megs for
  90. 32 bit compilation.  The present Windows development tools are roughly on a
  91. par with those from Microsoft and Symantec.  For unknown reasons, the 32 bit
  92. compiler is roughly twice as fast as the 16 bit compiler, given sufficient
  93. memory.
  94.  
  95. Borland's tools are uniformly excellent, but the compiler still suffers a bit
  96. in comparison to the industry's technological leaders, Microsoft, Watcom, and
  97. Symantec - although the gap is closing. As with VC++, it's an excellent C++
  98. compiler and enjoys widespread support among 3rd party library vendors. Like
  99. all Borland compilers, ease of use was a design priority, all oriented to the
  100. excellent IDE.
  101.  
  102. BC 4.5 followed fairly closely after the (disastrous) release of BC 4.0.
  103. While Borland loyalists still miss the DOS IDE, in most other areas, the
  104. major problems with BC 4.0 have been ironed out and Turbo Profiler, which was
  105. left out of BC 4.0, has been added back in.  The single greatest lack at this
  106. point is likely the DOS based IDE.  At this point, a Win32 and/or OS/2 text
  107. mode IDE might be a better choice.  OTOH, there are many excellent text
  108. editors capable of far more than the DOS IDE ever dreamt of.
  109.  
  110. The final consideration in choosing Borland's tools is the financial soundness
  111. of the company.  Around the beginning of 1995, Borland seemed almost certain
  112. to be gone by the end of the year.  However, the recent release of Delphi has
  113. apparently been almost as good as BC 4.0 was bad, and their finances seem less
  114. a worry at the moment.
  115.  
  116.  
  117.  
  118. TURBO C++ (TC++)
  119. ----------------
  120.  
  121. TC++ is to Borland's C++ compiler targeted at the hobbyist market. The latest
  122. version (TC++ 3.1) raised quite a stir when Borland released it requiring at
  123. least a 286 processor and 1 Mb of *available* extended memory above the
  124. normal 640K DOS limit.  Many hobbyists running on older XT's, or machines
  125. without the excess memory capacity have therefore failed to upgrade to the
  126. new release.
  127.  
  128. If you have the machine to support it, TC++ has the usual Borland attributes
  129. of extreme ease-of-use, attractive Integrated Development Environment (IDE),
  130. and good supporting tools. Based on the facts of BC++ 4.0 cited above, it has
  131. become the compiler of choice for many Borland loyalists.
  132.  
  133.  
  134. SYMANTEC C++ (SC++)
  135. -------------------
  136.  
  137. Symantec C++ (nee Zortech C++) was the industry's first C++ compiler, but fell
  138. behind in tracking the C++ language spec. Bought out by Symantec in 1991, the
  139. C compiler was always excellent and now its C++ compiler rates among the best.
  140.  
  141. SC++ supports DOS, Mac, Unix, Win32s, and NT (OS/2 was supported in previous
  142. Zortech releases and may be again) using an extremely powerful new object-
  143. oriented Windows-hosted IDE. It includes excellent libraries and add-ons
  144. including a TSR library, swapping spawn functions, a royalty-free 32-bit DOS
  145. extender, and an excellent set of ancillary C and C++ tools libraries
  146. including MFC 2.0 as previously noted. SC++ can generate true 32-bit code and
  147. has a switch for generating Pentium code. At the same time that Symantec
  148. bought Zortech, they also bought Multiscope, whose debuggers are included in
  149. the package. As with VC++, SC++ includes excellent tools for quickly
  150. developing Windows applications.
  151.  
  152. SC++ has always been in the forefront of optimizer technology along with
  153. Microsoft and Watcom. A major feature is full IEEE-754 and NCEG (Numerical C
  154. Extensions Group (an ANSI working committee trying to make C a suitable
  155. replacement for FORTRAN) compatibility.
  156.  
  157. The only negative for the current release is a poor reputation which arose
  158. largely during the period following the Symantec acquisition of Zortech. As
  159. of version 6.1, the bugs were mostly fixed. Support of DOS graphics was also
  160. dropped, but an updated version of the excellent Flash Graphics package
  161. shipped with the Zortech versions is available from FlashTek, which also
  162. supplies improved versions of the 32-bit DOS extender and the pre-Symantec
  163. debugger. The current 7.0 release fixes almost all residual bugs and is
  164. significantly enhanced in the area of portability, supporting features of
  165. other DOS compilers such as the _interrupt keyword.
  166.  
  167. One caveat - if you have any version prior to the 6.1 release, be sure to
  168. upgrade!
  169.  
  170.  
  171. WATCOM C/C++ (WC++)
  172. -------------------
  173.  
  174. Watcom has traditionally been the technological industry leader, performing
  175. feats of optimization and floating point speed other vendors only dreamt of.
  176. The cost has been compile speed, which has been described (somewhat unfairly)
  177. as glacial. For all its technical excellence, WC++ is still a niche market
  178. compiler like SC++. As such, it's 3rd party support is poor, but many have
  179. found that Microsoft C libraries can be made to work with WC++, often with
  180. nothing more than recompilation. As other compilers (most notably VC++ and
  181. SC++) have advanced, WC++'s technological lead has diminished and even been
  182. reversed for some applications. Like SC++, and unlike BC++ and VC++, WC++
  183. provides documented support for embedded systems work, although not to nearly
  184. the same degree as Metaware (see below).
  185.  
  186. Also, like SC++, WC++ supports 32-bit code generation. WC++ is the compiler
  187. of choice for many OEMs, such as Novell, who want only the best supporting
  188. code for their products. MSC/VC++ compatibility is excellent, but watch out
  189. for Watcom's sensitivity to proper _cdecl declarations, implemented in Watcom
  190. via a pragma rather than as a built-in language feature. Watcom sells both
  191. 16- and 32-bit versions of its C/C++ compiler. The best deal is to buy the
  192. 32-bit compiler and then purchase the 16-bit upgrade pack.
  193.  
  194. Where Watcom really shines is its support for a multitude of environments
  195. with the same compiler(s). Supported are DOS, Win3.1, Win32s, NT, OS/2 (1.x &
  196. 2.x), Netware 386, AutoCAD ADS, QNX, Phar Lap and Rational DOS extenders.
  197. With such a bewildering array of targets, compilation is relatively
  198. straightforward but the linker has a steep learning curve.
  199.  
  200. Watcom remains the only one of the "big name" compilers to not offer an IDE,
  201. if that's important to you or you don't own a "real" programmer's editor.
  202.  
  203.  
  204. METAWARE HIGH-C/C++ (HC++)
  205. --------------------------
  206.  
  207. HC++ is the darling of some segments of the embedded systems market. As such,
  208. it's a lot like WC++, only not quite as good and a lot weirder since it
  209. offers detailed control over every aspect of the executable. Most WC++
  210. comments apply, except for the ones relating to quality of generated code.
  211. HC++'s code is quite good, but seems to be showing its niche market
  212. orientation (any one remember Manx Aztec C?)
  213.  
  214.  
  215. TOPSPEED C/C++ (TSC++)
  216. ----------------------
  217.  
  218. TSC++ has had a rocky life, getting off to a late start in the market and
  219. never having really quite caught on. Originally, TSC++ was a Turbo C clone
  220. which shared tools and environments with its sister Modula-2 compiler. More
  221. recent versions have extended this by using a modular approach with an
  222. environment supporting "plug-in" compilers for various languages which can
  223. all be used together. The company was recently acquired by Clarion.
  224.  
  225. TSC++'s undisputed biggest strength is its smart linker and various features
  226. added to facilitate mixed-language programming (Modula-2, for example,
  227. supports multi-threaded code). Using this technology, you can count on TSC++
  228. to almost always produce the smallest executables for a given piece of source
  229. code. The library, written almost exclusively in assembly, is also excellent
  230. and contributes to the frugal use of run-time memory. Unfortunately, the code
  231. generated by the compiler - even with full optimization - is typically not
  232. of the same quality as the library modules.
  233.  
  234. Drawbacks include almost non-existent 3rd party support and the pervasive IDE
  235. which feels more at home to Modula-2 programmers than C programmers.
  236.  
  237.  
  238. GNU C/C++ (GCC, G++; also DJGPP, EMX)
  239. -------------------------------------
  240.  
  241. Available from the Free Software Foundation (FSF), GCC and G++ are two of
  242. only three compilers listed here available for free (the other is Micro-C).
  243. Originally written for Unix systems, there are several DOS and OS/2 ports
  244. available. All of the DOS ports require some sort of DOS extender technology
  245. built-in in order to work in DOS's limited memory. The most popular of the
  246. DOS ports is DJGPP. OS/2 ports obviously don't share this limitation. The EMX
  247. port for OS/2 is among the best and is quite popular among OS/2 programmers.
  248. Along with SC++, WC++, and HC++, the gnu compilers round out the list of full
  249. ISO/ANSI/ARM compilers with explicit support for embedded systems.
  250.  
  251. Performance is decent, but not earth-shattering, and executables - especially
  252. small utilities - tend to exhibit some bloat. This may be overcome by using
  253. some non-standard compiler features unique to FSF compilers at the expense of
  254. portability.
  255.  
  256. All GNU software carries the FSF's "GNU General Public License". This is
  257. their infamous "copyleft" license that guarantees their software tools remain
  258. free, yet imposes restrictions on redistribution and commercial distribution
  259. of the GNU tools and software developed with them. If you plan to use one of
  260. these to write commercial code, be sure and read the license agreement *very*
  261. closely.  Note that simply producing an executable with the compiler does not
  262. subject the resulting program to copyleft, but use of GNU's run time library
  263. code subjects the program to their special library license, which is separate
  264. from the standard GNU license.  Be *sure* to get the correct license and read
  265. it carefully before deciding on GCC/G++ for commercial use.  In the case of
  266. DJGCC, the DOS extender used is subject to another license of its own.
  267.  
  268.  
  269. DUNFIELD MICRO-C
  270. ----------------
  271.  
  272. There have been many "small" or "tiny" C's over the years, some useful for
  273. teaching the rudiments of compiler construction, others not much use for
  274. anything. Small C's typically lack structs, unions, bit fields, and even long
  275. integers.
  276.  
  277. Why bother listing this one then?
  278.  
  279. First of all, Micro-C is an evolving product which, as of version 3, now
  280. includes many features such as structs and unions not normally associated
  281. with small C's.
  282.  
  283. Secondly, Dave Dunfield recently made the DOS version of Micro-C freeware.
  284. You can use it without restriction or licensing fees to create DOS programs.
  285.  
  286. Third, the source code (available when you register the shareware version) is
  287. quite decent and really can teach you something about compiler internals. But
  288. Micro-C is genuinely useful for a lot more reasons.
  289.  
  290. Finally, the PC library includes support for writing TSR's, interrupt-driven
  291. serial I/O, and screen windowing. Amazingly, it also sports an optimizer, but
  292. requires MASM or equivalent for compiling PC applications.
  293.  
  294. How does Dave provide such a nifty tool for free? Simple - he makes his money
  295. off of Micro-C by producing cross-assemblers for a variety of microprocessors
  296. and provides plug-in code generators for his C compiler to use with those
  297. chips as well. The 80x86 version comes ready to compile either PC or embedded
  298. code.
  299.  
  300. Supporting small and tiny model only, Micro-C executables are phenomenally
  301. small. "Hello world" programs that run 5-6K on other compilers run under 600
  302. bytes when compiled with Micro-C.
  303.  
  304. One other point needs to be mentioned with respect to Micro-C...  Although it
  305. is *a* small C, it has no code commonality with *the* Small C from the book
  306. of the same name. This is important since there are a number of variants of
  307. Small C available, all not much better than the original.  Micro-C, OTOH, was
  308. written by Dave Dunfield completely from scratch and is a *much* better
  309. designed piece of code and certainly much more instructive to fledgling
  310. compiler writers. His better design is evinced in code quality and execution
  311. speed.
  312.  
  313.  
  314. PCC
  315. ---
  316.  
  317. The Personal C Compiler is available as shareware. It used to be marketed as
  318. the deSmet C compiler and had a generally good reputation for quick compile
  319. times and tight code. Unfortunately, the product hasn't been seriously
  320. upgraded in quite a while and can't stand too much comparison. It's horribly
  321. non-ANSI compliant, has a weaker set of library functions than Micro-C,
  322. features non-standard file formats, and is generally incompatible with most
  323. published C code.  Even Micro-C, which makes no claim to ANSI compliance, is
  324. still considerably closer to it than PCC.  The current version of Micro-C
  325. accepts function prototypes, likely the single most important addition made
  326. to C in the ANSI standard.
  327.  
  328. If price is your concern, Mix Power C costs less to buy than PCC does to
  329. register and offers better performance along with the ANSI compliance that
  330. PCC lacks.  If you plan on using an unregistered copy, Gnu C/C++ is vastly
  331. superior and is legally free. If you're attracted to its tight, fast code and
  332. can live with quirks and without ANSI compliance, go with Dunfield Micro-C.
  333.  
  334.  
  335. Q.  Do have any samples?
  336.  
  337. A:  The following program was compiled using several DOS compilers with the
  338.     results as noted below. The compilers tested are noted in the executable
  339.     program's name as follows:
  340.  
  341.       Suffix      Compiler                Notes
  342.       ------      --------                -----
  343.       _b45        Borland C 4.5
  344.       _b31        Borland C 3.1
  345.       _g32        gnu C (DJGPP 1.12M2)          GO32 32-bit DOS extender
  346.       _mc         Dunfield Micro-C 3.13
  347.       _ms         Microsoft C 8.0               Part of Visual C++ 1.5
  348.       _pc         Mix Power C 2.2
  349.       _sc         Symantec C 7.0
  350.       _s32        Symantec C 7.0                DOSX 32-bit DOS extender
  351.       _wc         Watcom C 10.0
  352.       _w32        Watcom C 10.0                 DOS/4GW 32-bit DOS extender
  353.       _zc         Zortech C 3.0r4
  354.       _z32        Zortech C 3.0r4               DOSX 32-bit DOS extender
  355.  
  356.     All executables were compiled with maximum optimization and with other
  357.     options (e.g. no exception handling for Borland 4.5) to assure minimum
  358.     size of the executables. The results for Zortech and Borland are for
  359.     comarison since both are several revision obsolete (however they do
  360.     highlight the fact that if all you want to do is compile straight C code,
  361.     sometimes the latest isn't always the greatest). The test file was
  362.     selected as an example of a minimally useful standard C program. Some
  363.     coding peculiarities were introduced to accomodate some non-standard
  364.     features of the Micro-C library.
  365.  
  366.     The program listing is followed by execution and compile times. The
  367.     machine used for the test was a 486/DX50 using Golden Bow's Vcache. Due
  368.     to the presense of the cache and the small size of the program, the
  369.     execution timings are probably only grossly representative. The timings
  370.     for the DJGPP-compiled test includes timings for both the compilation and
  371.     COFF-to-.EXE conversion required to produce a stand-alone executable. The
  372.     compilation time listing for WCL386 is for the Watcom-compiled version
  373.     using the DOS/4GW 32-bit DOS extender.
  374.   
  375. ----[ Size.C ]----------------------------------------------------------------
  376.  
  377. #include <stdio.h>
  378.  
  379. #ifndef __MICROC__
  380.  #include <string.h>
  381. #endif
  382.  
  383. main(int argc, char *argv[])
  384. {
  385.       char buf[80], *ptr;
  386.       FILE *me;
  387.  
  388.       if (NULL == (me = fopen("size.c", "r")))
  389.       {
  390.             fputs("Can't open SIZE.C\n", stderr);
  391.             return -1;
  392.       }
  393.       while (1)
  394.       {
  395.             if (NULL == fgets(buf, 80, me))
  396.                   break;
  397.             for (ptr = buf + strlen(buf) - 1;
  398.                   ptr >= buf && *ptr == '\n'; --ptr)
  399.             {
  400.                   *ptr = '\0';
  401.             }
  402.             printf("%s\n", buf);
  403.       }
  404.       return 0;
  405. }
  406.  
  407. ----[ Dr.Out ]----------------------------------------------------------------
  408.  
  409.  DR 3.00ß 
  410. Disk vol "STACVOL_DSK"
  411. Directory of D:\BINK\CODE\WIP
  412. 12 Files totalling 192,477 bytes
  413. 602,865,664 Bytes free
  414.  
  415. Size_mc  Com       2,105  ..a.rwx  20 Nov 95   9:59:42  < Micro-C 3.13
  416. Size_zc  Com       8,035  ..a.rwx  20 Nov 95   9:59:00  < ZTC 3.0r4
  417. Size_ms  Com       8,049  ..a.rwx  20 Nov 95  10:09:50  < MSC 8.0
  418. Size_b31 Com       8,776  ..a.rwx  20 Nov 95  10:11:24  < BC++ 3.1
  419. Size_wc  Com       9,318  ..a.rwx  20 Nov 95  10:03:46  < WC 10.0
  420. Size_sc  Com      10,528  ..a.rwx  20 Nov 95  10:04:48  < SC++ 7.0
  421. Size_b45 Com      11,216  ..a.rwx  20 Nov 95  10:07:20  < BC++ 4.5
  422. Size_pc  Exe      13,312  ..a.rwx  20 Nov 95  10:12:40  < Mix Power C 2.2
  423. Size_w32 Exe      25,994  ..a.rwx  20 Nov 95  10:21:44  < WC/DOS 4G/W
  424. Size_z32 Exe      27,941  ..a.rwx  20 Nov 95  10:17:44  < ZTC/DOSX
  425. Size_s32 Exe      29,149  ..a.rwx  20 Nov 95  10:18:42  < SC++/DOSX
  426. Size_g32 Exe      38,054  ..a.rwx  20 Nov 95  10:23:44  < DJGPP 1.12M2
  427.  
  428. ----[ Execution times ]-------------------------------------------------------
  429.  
  430. SIZE_WC     Elapsed time = 0.116001 Seconds     < WC 10.0
  431. SIZE_MS     Elapsed time = 0.116579 Seconds     < MSC 8.0
  432. SIZE_B31    Elapsed time = 0.121079 Seconds     < BC++ 3.1
  433. SIZE_PC     Elapsed time = 0.127011 Seconds     < Mix Power C 2.2
  434. SIZE_ZC     Elapsed time = 0.218889 Seconds     < ZTC 3.0r4
  435. SIZE_SC     Elapsed time = 0.221269 Seconds     < SC++ 7.0
  436. SIZE_MC     Elapsed time = 0.226919 Seconds     < Micro-C 3.13
  437. SIZE_B45    Elapsed time = 0.232461 Seconds     < BC++ 4.5
  438. SIZE_Z32    Elapsed time = 0.233987 Seconds     < ZTC/DOSX
  439. SIZE_G32    Elapsed time = 0.406291 Seconds     < DJGPP 1.12M2
  440. SIZE_S32    Elapsed time = 0.461156 Seconds     < SC++/DOSX
  441. SIZE_W32    Elapsed time = 1.299404 Seconds     < WC/DOS 4GW
  442.  
  443. ----[ Compile times ]---------------------------------------------------------
  444.  
  445. PC (Mix Power C) 2.2    1.505081 Seconds
  446. CC (Micro-C) 3.13       1.843561 Seconds
  447. ZTC 3.0r4               1.948132 Seconds
  448. SC 7.0                  3.002091 Seconds
  449. BCC 4.5                 4.108201 Seconds
  450. BCC 3.1                 4.586260 Seconds
  451. WCL 10.0                5.669630 Seconds
  452. WCL386 10.0             6.342555 Seconds
  453. CL (MSC) 8.0            6.697373 Seconds
  454. GCC (djgpp) 1.12M2      8.287935 Seconds
  455.  
  456. ----[ finis ]-----------------------------------------------------------------
  457.