Symantec & Think
|Column Tag:||Tools of the Trade
Symantec C++ & Think C 6.0
What happens when you mix a little bit of MPW with a lot of Think?
By Ed Ruder, San Jose, California
About the author
Ed has been developing for the Mac since 1982 (yes, 1982), starting with MacWrite 1.0, all the way through MacWrite 4.6, as Encore Systems under contract to Apple. He then wrote Full Impact, what we called a presentation spreadsheet under contract to Ashton-Tate. He now works for Storm Technology and has lots of assembly language, C, and C++ experience.
Symantecs THINK C 6.0 is without question the most significant upgrade to the THINK C product line ever. Symantec C++ for Macintosh combines THINK C 6.0 with an integrated and powerful native C++ compiler. With all of its new features, THINK has graduated into a state-of-the-art development system equal to the demands of any project, from the smallest weekend hack to the largest industrial-strength application with a development team of dozens.
First of all, Symantec has announced and shipped not one, but three new products: THINK C 6.0, Symantec C++ 6.0 for Macintosh, and Symantec C++ 6.0 for Apples Macintosh Programmers Workshop (MPW). THINK C 6.0 is a new, open development system, centered around the THINK Project Manager application, that allows you to build any kind of executable code using the C programming language or THINKs C with Objects. Symantec C++ 6.0 for Macintosh contains all of THINK C 6.0, with the addition of a powerful and fast native C++ compiler supporting the latest C++ features, and lots of C++ libraries and sample code. Symantec C++ 6.0 for MPW is the same native C++ compiler in an MPW tool, providing 50% better compiler performance than MPWs CFront preprocessor/C compiler implementation.
A complete THINK C 6.0 installation takes up over 7 MB of disk space, while a complete installation of Symantec C++ for Macintosh fills up over 11.5 MB. You can customize your installation to take up less space. Both products can run on a Mac Plus or better with as little as 1 MB of RAM running System 6.0.5, although Symantec recommends 4 MB of RAM and System 7 or System 6.0.5 with MultiFinder, for the best results. (Unfortunately, I wasnt able to get a copy of Symantec C++ for MPW in time for this review.)
THINK Project Manager (TPM) looks and behaves a lot like previous versions of THINK C on the surface, so current users will have a very easy time starting to use it. However, looks can be deceiving. When you start using it, youll discover that TPM is much more powerful, sophisticated, and flexible than its predecessors.
One of the major new features of THINK 6 is its extensibility. THINK 6 introduces the concept of a translator, a piece of code that processes a file in a THINK project to add something (object code, resources, etc.) to the final product. You install translators into TPM just by dropping them into a special folder. The compiler that was baked into earlier versions of THINK C is now a translator, separate from TPM. Each translator thats installed has its own preferences dialog, accessed from the Options hierarchical menu in the Edit menu. THINK 6 comes with five translators: THINK C, .o Converter, THINK Rez, Resource Copier, and «none». C++ for Macintosh has one additional translator, Symantec C++. When TPM determines that a file needs to be compiled, it uses the files extension (.c, .r, .o, etc.) to determine which translator does the work. You can change these mappings, and add new ones, in the Extensions section of the TPM options dialog.
The .o Converter translator allows you to include an object file from MPW directly into your project (the OConv application is history). The Resource Copier allows you to include .rsrc files directly into your project-compiling a .rsrc file simply copies its resources into the <project name>.rsrc file associated with each project. The «none» translator allows you to add files to your project that wont get compiled. You can include documentation files, illustrations, and more directly into your project. When you double-click on a file in a project that TPM doesnt know how to open, it asks the Finder to open it (under System 7). The Finder will launch the application that created the file and tell it to open the file. Very slick.
[Aside: THINK 6 can run under System 6.0.5 or better, but many of the advanced features of THINK 6 depend upon the features of System 7. I think youll see that the power of these features more than justifies the move to System 7, if you havent already done so.]
The THINK Rez translator is a complete resource compiler, modelled after MPW Rez. It compiles .r text files into resources that TPM puts into the <project name>.rsrc file. THINK 6 ships with SADerez as well, a stand-alone resource decompiler that converts resources into Rez-able source files. This is an important piece of the development process. I find it much easier to tweak a dialog box by editing its source text in a .r file than by trying to move an item by a single pixel in ResEdit. (Also, am I the only one who never quite trusted ResEdit not to corrupt my resource files arbitrarily?)
THE PROJECT WINDOW
Youll notice when you open a project that the project window contains much more information (see figure 1). Each segment has a summary line at the top with the name of the segment, an optional segment number, and the totals of the files in the segment. Depending on how youve set your preferences, the totals displayed are any combination of the code, data, jump table, and string sizes. You can collapse an entire segment down to its summary line by clicking on the triangle on the left of the summary line, and expand it by clicking again (like the System 7 Finders list view windows). Hold the option key down while double-clicking and all segments collapse or expand. Very handy when you have lots of segments with many files. You edit the segments name and attributes (preload, purgeable, locked, etc.) by double-clicking on the summary line.
If you double-click on a THINK project document in the Finder and theres already a project open in TPM, TPM closes the open project and opens the new project-just what youd expect (but not what THINK 5 did). TPM also puts the name of the project it closed into a Switch to Project hierarchical menu-choosing a project from this menu opens it. You can place a project into this menu permanently by putting an alias of the project into TPMs Projects folder. Another cool feature: if you include another project as a library in your project, double-clicking on it closes the current project, opens the included project, and puts the name of the closed project into the Switch to Project menu. Other projects that youve opened recently are also automatically added to this menu. Last, but not least, you can now print the project window, which prints out all the segments, the files in the segments, and their totals. (Symantec has been listening!)
THINK 6 can open old project files, after asking to convert them to its new format, which forces a complete rebuild. If you open a project and build it, a few more features show themselves. If any errors occur during the build, a window will open, the error will be listed in the window, and the build will continue with the next file. At the end of the build, the error window will contain a few lines for each error that occurred; if you double-click on the lines for a particular error, the appropriate source file is opened, with the proper line selected. There are menu items with command keys that allow you to browse through the errors.
The THINK C translator is basically the same compiler that was in THINK C 5, with some bug fixes. I compared the build time for a couple of different projects using both the THINK C translator under TPM and THINK C 5. TPM was between 15% and 30% faster than THINK C 5. Symantecs Whats New appendix states that TPMs algorithm for locating source files has been improved and that project updates are up to 25% faster, which matches my measurements.
The compile status dialog has been improved. When you update or make the project, its now a movable modal dialog, so you can click into other applications during a compile, leaving TPM compiling in the background. (Thank you, THINKBack, you can retire with pride.) The dialog also shows how many files have been compiled out of the number that need to be compiled. See Figure two.
The Disassemble command in the Source menu has been improved to show global, local, structure member, trap, function, and parameter names in the disassembled output.
Searching has also been improved. In addition to all of the search options of previous versions of THINK C (case sensitive or not, entire word or not, full-featured grep), you can specify that a multi-file search be a batch search, where all of the matches found are accumulated into a window, rather than having the search stop each time a match is found. The window displays one line per match, listing the file in which the match occurred and the text on the line of the match. Double-clicking on a line opens the file and selects the line containing the match. Menu items with command keys allow you to quickly browse through the matches. You can also specify that system files (files in the THINK tree) be excluded from the search.
The THINK Debugger also has some improvements. You can enter a function call in the Data window, useful for calling functions like strcmp(). You can enter a Data window expression whose context floats (if you use the same variable name in several different functions, you can cause the expression to be evaluated in each function). There are also command keys for the data types, very useful since the default types are frequently wrong.
The THINK Class Library has been upgraded to version 1.1.3. Many bugs were fixed, but no new features were added.
Another way that THINK 6 is extensible is via the Tools folder. You can place specially-named applications (or aliases to them) in this folder, and THINK 6 will automatically direct certain tasks to the applications via Apple events, if you are running under System 7. THINK 6 will look for aliases called THINK Reference, Editor, SourceServer, and ToolServer, and if it finds them, it will use them to extend its features.
THINK 6 ships with THINK Reference 2.0.1 and a database describing the Standard C Libraries (eliminating one manual from their box). Put an alias of the THINK Reference application into the TPMs Tools folder and name it THINK Reference. When you option-double-click on the name of any Standard C function, TPM will automatically bring up the THINK Reference application with the documentation about the function visible in its window. If you already own THINK Reference, you have databases describing the Macintosh Toolbox functions-option-double-clicking on Toolbox functions will open up THINK Reference to their descriptions.
TPMs editor is essentially unchanged from the one in THINK C 5. In fact, several third-party editor extenders continue to work with it, such as CMaster and PopUpFuncs. However, you can install a third-party editor into TPM as an Editor tool, tell TPM to use it, and TPM will automatically switch to the external editor whenever it wants to open a source file. The editor may have its own menu(s) dedicated to TPM, to start compiles, check syntax, etc. I know of one third-party editor that works very well with TPM, BBEdit 2.5, recently released from Rich Siegel (on Internet: email@example.com). (I recommend investigating BBEdit if you are at all curious about a more sophisticated source code editor than the one built into THINK 6. Its got lots of neat features.) There are probably other Symantec-compatible editors in development, if not already released, by this time. With your favorite external editor installed, you get its whiz-bang features tightly coupled with TPM, for the best of both worlds. Très cool
Installing the SourceServer and ToolServer tools into THINK 6 goes a long way towards solving the shortcomings of the old THINK system when dealing with large, multi-programmer projects. I have used THINK C off and on ever since version 1.0, and Ive always been impressed with its ease of use, compile speed and turnaround time. For lots of projects, its been an ideal development system. However, for many of the large projects that Ive worked on, I have not been able to use THINK because of its lack of support for multiple programmers, source code control, and scriptable tools. Those larger projects have always required MPW. However, with MPW came much longer edit-compile-link times and an generally more-complicated environment. What Ive always wished for was an environment as fast and easy-to-use as THINK C with the powerful tools of MPW there when I need them. THINK 6 grants many of my wishes.
ToolServer and SourceServer are stand-alone, not-quite-faceless applications that embody pieces of MPW. They are Apple event-driven workhorses (servers) that any application can call to do work for them. (THINK 6 comes bundled with SourceServer 1.0, and ToolServer is available from APDA either separately or bundled with the latest MPW.) ToolServer can execute MPW scripts and run MPW tools. SourceServer contains most of the functionality of the part of MPW called Projector, a source code control tool.
With ToolServer (or its alias) installed into TPMs Tool folder, you can click on a line or select multiple lines and hit option-enter to send them to ToolServer. ToolServer will process your commands in the background, and return any results to the window from which the commands were sent. You can select entire scripts for ToolServer to execute, or you can have ToolServer execute a script from a file anywhere on any mounted volumes.
SourceServer (SS) provides almost all of the features of MPWs Projector tool. Projector and SS allow you to create and maintain a database of the source code for a project. You check out files from the database to modify them; when youre done modifying them, you check in the files. When you havent checked out a file to modify it, you have a read-only copy of it that you can view and compile, but not change. You can tell SS to check out any files that are newer than what I already have, and the latest versions of the files will be copied into the correct directories. You can ask SS for any past version of any file in a projects SS database. If there is more than one person working on a set of source code, this kind of functionality is critical. SS/Projector functionality may be a benefit even if you are the only person working on a project, because of the ease with which you can archive and retrieve old versions of source files.
SS is very tightly integrated into TPM. In the Source menu in TPM, theres a SourceServer hierarchical menu. The menu contains the commands that tell SS what to do. When you launch SS with a THINK project open or open a THINK project when SS is already open, SS will automatically mount the Projector database whose alias is in the root of your source tree, if its named ProjectorDB. Once a database is mounted, you can check out and check in source files using the commands in the SS menu. The most common thing youll do is check out the frontmost window for modification, modify it, and check it back in. The first item in the SS menu checks out the frontmost file if its not checked out for modification and checks in the frontmost file if its checked out. Other commands allow you to check in/out groups of files at once, create new SS databases, mount or unmount databases, etc.
APPLE EVENTS SUPPORT
THINK 6 doesnt only send Apple events to other applications-it is fully-scriptable from AppleScript and Frontier 2.0. There is a Scripting folder containing documentation and demo scripts for both AppleScript and Frontier. There are a handful of interesting AppleScript scripts, but most interesting is the material in the Frontier folder. [See the Frontier article in this issue. - Ed.]
The folks at UserLand have put together a Frontier installer for THINK that installs the THINK verbs into Frontier and installs a shared menu into TPM that can be used to run Frontier scripts from TPM. However, youll need Frontier 2.0 or Frontier Runtime-its not included. (The documentation describes where you can get Frontier Runtime for the cost of downloading it.) The THINK verbs shield some of the complexity of the Apple Event interface to THINK and make for more-readable scripts. Also included is complete documentation of the THINK verbs accessible from DocServer, a part of Frontier. The tutorial in the Read Me file describe how to quickly write a script that automates the compilation of a whole hierarchy of projects, with error checking and limited recovery. The Read Me is very thorough, and describe additional sources of information about using THINK 6 with Frontier. UserLand has developed a very powerful package for linking THINK 6 with Frontier, and its free with THINK 6.
Apple has been professing the benefits of object-oriented programming for a number of years, and has shifted much of its internal development to the C++ programming language. (For example, System 7s Finder is substantially written in C++.) Apple has been encouraging its developer community to likewise adopt an object-oriented strategy. THINK C incorporated its own brand of object-oriented C a number of years ago. THINK 6 continues to provide C with Objects. However, true C++ support is very important to a significant, and growing, number of developers. With the advent of both the new C++ packages, Symantec has fulfilled that need, in spades.
Symantec C++ for Macintosh and Symantec C++ for MPW both use the same fast, native C++ compiler that supports the latest C++ features, such as templates, multiple inheritance, and nested classes. A native C++ compiler is distinct from a CFront implementation like MPWs C++-a native compiler generates object code in one pass, directly from the C++ code. CFront is a pre-processor which accepts C++ source code as input and spits out C code (usually in a compact form, so it wont be a total slowpoke) to a C compiler, which then creates object code. This is probably the primary reason why Symantecs C++ compile times are 50% faster than those of MPWs C++. This increased compile-time performance is all the more impressive combined with the fact that Symantecs C++ optimizes its object code output much more than MPW does, generating significantly faster and/or smaller code. For those of you wondering, Bedrock is being developed under Symantec C++ for MPW.
C++ for Macintosh contains all of the THINK C 6.0 package, without exception. With C++ for Macintosh, you get a Symantec C++ translator, sample code (all of the samples that come with THINK 6 have a C++ version of their project file, as well as the original, and theres some C++-only sample code), lots of C++ libraries (some libraries are C++ versions of libraries that are in both products; others, such as the IOStreams class library, are unique to C++), and a THINK Reference database that describes the IOStreams class library.
The Symantec C++ translator works transparently inside of the TPM application. Many projects (e.g., all of the projects in the Demos and TCL Demos folders) will compile using either the C++ translator or the THINK C translator, just by changing the appropriate mapping in the Extensions section of the TPM options dialog. There are settings in the Symantec C++ options dialog that give you control over how code is generated from the compiler, controlling specific optimizations, etc. You can use Symantec C++ inside of code resources and drivers, since the compiler can generate code that uses A4 globals (a major benefit over MPW C++).
The Browser, Debugger, and Disassembler fully support the C++ compiler, including templates and multiple inheritance. TCL compiles under both C++ and C with Objects.
For those of you curious about MacApp 3 support, the C++ for MPW compiler deals with it without a hitch. Symantec Technical Support says that it is possible to get it running under the Symantec C++ for Macintosh environment, but that it does take some modifications to the MacApp source.
Symantec has slightly rearranged their documentation. Both THINK C 6.0 and Symantec C++ for Macintosh come with two manuals, a Users Guide and a THINK Class Library Guide. C++ for Macintosh comes with an additional manual, the C++ Compiler Guide. THINK Reference ships with both products with a database describing the Standard C Libraries (this used to be a bound manual). I found the online documentation to be more useful than the manual-it contains all of the manuals information in a form thats easier and quicker to navigate. C++ comes with a THINK Reference database describing the IOStreams class library.
The Users Guide has over 800 pages containing everything you need to know to use THINK 6. Its excellent in almost all respects. Most of it is essentially identical to the THINK 5 User Manual. The new sections include a surprising amount of documentation about the C++ compiler (you get this even if you didnt buy C++-I guess a little plug never hurt anybody). There are very brief (perhaps too brief) sections describing how to execute MPW commands using ToolServer and how to use an external editor. Theres a very good chapter describing SourceServer, its databases, and how to manage them. I did notice that the index did not seem to have been thoroughly updated with the newest topics-I spent too long in the index trying to find the documentation about ToolServer and using external editors-I ended up using the table of contents.
The THINK Class Library Guide, weighing in at 568 pages, is essentially the same as THINK 5s Object-Oriented Programming Manual, minus a couple of chapters that were moved into the Users Guide.
The C++ Compiler Guide is a good 100 page manual describing Symantec C++, how to use it in the THINK 6 environment, and what all of the compiler options are good for. Theres a very good appendix discussing code porting issues and another talking about how conformant the C++ compiler is.
As wonderful as THINK C 6.0 and C++ for Macintosh are, they arent yet perfect. TPM and earlier versions of THINK C have a handy shortcut for opening any of the header files included by a C source file-if you option-click on the title bar of the source file, a menu containing the names of the included files pops up. With TPM, if you use precompiled headers (and you should-compiles are much faster), youll notice that any header file contained in your precompiled header file doesnt show up in the menu of included files. The same limitation applies to option-clicking on the title bar of the project window to see all of the header files in the project.
The Apple #includes: folder doesnt contain the latest header files from Apple, which were updated with MPW 3.3, shipping on E.T.O. #11. If you want to use the latest includes, containing a lot of System 7-specific stuff, you cant just drop them into the Apple #includes: folder-they need to be massaged quite a bit in order for them to compile correctly under the THINK C translator-not an easy task. Hopefully, Symantec will release an quick upgrade incorporating the current header files.
The integration with SourceServer has some rough edges. TPM sometimes has trouble automatically launching SS, even though the Launch SourceServer menu item always works.
TPM has some glitches when dealing with hierarchies of SS databases-databases that themselves contain databases. We get around it by using MPW Projector for serious project management. TPM & SS work fine for checking in and out single files and for dealing with flat databases, though, which is the more typical scenario.
All of the programmers at my office use multiple monitors on their development machines-its much easier to work with a number of files at once when you can set them up side-by-side (-by-side ). The problem is that TPMs Clean Up command always cleans up all windows onto the monitor containing the menu bar, rather than cleaning them up on the monitor on which they started.
Weve encountered some occurrences of TPMs built-in make getting confused about THINK Rez source files-it sometimes doesnt notice that they need to be compiled when they should. Since theres usually a small number of .r source files, its easy to double-check, or force a re-build.
My company has been using THINK 6 for several months (we were beta testers for it), and we did run into a few problems, none of which were show-stoppers. We are very happy with THINK 6, and couldnt imagine going back to THINK 5.
AVAILABILITY AND PRICING
All three products are available immediately. THINK C 6.0 has a suggested retail price of $299 and upgrades for THINK C 5 users are $89.95. Symantec C++ 6.0 for Macintosh is $499 and upgrades from THINK C 5 are $149.95. Symantec C++ 6.0 for MPW is $499 with no upgrade policy for THINK users. Information about Symantec Corporation and its products can be obtained by calling 800/441-7234 or 408/252-3570 (Cupertino, California).