Ada Compiler Review
|Column Tag:||Ada Additions
Ada Compiler Review
By Patrick McDermott, Saint Louis, MO
Isnt Ada an acronym??
The Ada language has been approved by the International Standards Organization as a standard programming language for all computers hosting compilers which have been validated by the Ada Joint Program Office (AJPO). Ada has the backing of some powerful customers (i.e. United States Department of Defense). The United States Department of Defense (DoD) has mandated that Ada must be used on all future defense systems. Ah, I can hear the cash register ringing in the minds of many readers. Ada is fast becoming the language of choice in the military and commercial sectors of the world! Star Wars and the Space Station plan on developing all of the mission critical software using Ada. I believe that the Macintosh community has grossly overlooked Ada. Some programmers still think that Ada stands for the American Dental Association. The Ada train is leaving but there is still time to climb aboard!
History lesson & Free Software...what a deal
The Ada language was sponsored by the U.S. Department of Defense when the DoD realized that software maintenance costs were rising as military systems became more complex. A new common high order language was needed to meet the needs of larger problem domains. The initial goal from the start was defining/standardizing a language that would support modern software methodologies (i.e. Object Oriented Design) such as abstraction and information hiding and provide constructs for real-time control and exception handling. At the end of the design phase, four companies were competing for the definition of the language. The winner of the design was Honeywell/Bull. A compiler validation facility was established after the winner of the design was announced. This facility ensures that each compiler meets the requirements of the language. If the compiler passed these set of tests, the compiler was validated. Dont worry, I am getting to the free software portion. After the ball was rolling on the development of the Ada language, to encourage the use of Ada the AJPO established an Ada software repository(see insert Ada Information Clearinghouse) by which hundreds upon thousands of lines of FREE software can be obtained for the price of a magnetic tape. Granted, not all of the software is good but you never know what reusable software you might find.
JUST THE FACTS MAAM
The Meridian AdaVantage Ada compiler has been available since early 1988. I tested the following: Ada compiler version 2.2A ($1195), Ada debugger ($500), Ada utility library ($50) and the Macintosh Environment Library version 1.0 ($150). The Ada development system operates under the MPW (Macintosh Programmers Workshop) environment, version 2.0.2. The Ada compiler uses MPW C as an intermediate language. The intermediate C language is transparently compiled by the MPW C compiler. MPW and MPW C are included in the purchase of the Ada compiler. See the insert for the system/software requirements. Version 2.2A of the Ada compiler has been validated. Validation, defined, by the AJPO, encompasses a set of over 2,000 tests that the compiler must successfully pass.
Do U C what I C
Before I begin with the evaluation I want to mention something regarding Meridians decision for using MPW C as an intermediate language. Most programmers chuckle when they find out that Meridian uses MPW C as an intermediate language. Actually, I happen to think it was quite a clever idea! By using MPW C, Meridian was able to get a product to the Mac market that much faster although Meridian did pay a price. The obvious price Meridian paid for this type of implementation is compiler speed. Sure, compiling Ada programs on almost any computer is slower than if it were in another language. Let us not forget that Ada is NOT just another language. Ada is, for now, the most powerful language with wide acceptance in the world and Meridian is the only company to offer a validated Ada compiler that executes under the Mac OS (two Ada development companies, ALSYS & Telesoft, have products that run under A/UX). I purposefully left out comparing Ada with other languages due to the size and complexity of Ada. Read the only other article written about this Ada compiler if you want to examine some timing benchmarks (The timing benchmark are the result of an older version of the compiler tested) in the September 1988 issue of BYTE magazine.
Meridian recommends at least two megabytes of RAM, although one megabyte is adequate for compiling small compilation units. Memory problems may occur while compiling large compilation units. The problem takes place while compiling the intermediate C code generated by the Ada compiler. There are instances when the intermediate C code is compiling that a message UNABLE TO SWAP IN TOOL SEGMENT is displayed. The problem is the C compiler has used all of its RAM allocated to compiling a compilation unit. The next step is to exit out of MPW and restart the Mac. That task gets tiresome real QUICK. The solution is to reduce the size of the compilation unit by breaking out some of the sub compilation units into SEPARATE source files, a feature of Ada. The C compiler is not graceful when acknowledging out of memory problems. Two meg of RAM is strongly recommended if you plan on developing any serious software, with the Meridian Ada compiler.
Meridian uses a hierarchical library structure for maintaining compiled compilation units. This method makes it possible to have sublibraries dependent on a parent library. Using the MPW lslib command. I was able to extract a wealth of information, from the current library. Some compilation unit information accessible from the Ada libraries include: source file name, whether or not the unit is obsolete and must be recompiled, compilation unit type (package, procedure, function, generic), whether or not the body is defined, a list of that compilation units dependencies, the time the compilation unit was entered into that particular library and information regarding sub compilation units. A compilation unit dependency option is desperately needed. Without this option, I am responsible for knowing the entire dependency chain associated with each compilation unit. For medium to large projects, manually maintaining a complete compilation order is very difficult if not impossible. Each Ada library has the capacity to store up to 4,096 compilation units. When a compilation unit is imported into a dependent compilation unit. The compiler searches 2 levels up the library chain to locate the compilation unit being imported. Unlike other Ada development systems, the Meridian Ada library does not keep a copy of the source code file although it does keep the directory name where the source code is located.
The utility library contains a handful of packages. Three of the generic packages provide helpful service. A package, Array_Object, handles arrays larger than those allowed by MPW(currently an object is limited to 32K in total size). Array_Type allows for multiple large arrays to be defined with the same characteristics as others of the same type. Bit_Ops performs bit manipulation on objects. This utility library should contain the C bindings for interfacing to the Mac toolbox.
INSTALLATION = Piece-O-Cake
I performed my evaluation on a Mac II configured with two megabytes of RAM and a Jasmine 70 meg hard disk. Installation was a breeze! I followed the instructions in the MPW manual to get the MPW environment and C compiler up and running. I then proceeded to the Meridian Manuals. The MPW newlib command created an Ada library in my current working directory. I was now ready to compile Ada programs.
By typing Ada followed by the Ada source code file name, at the MPW command line, I was able to compile Ada source code. There are a variety of compiler options available to choose from. The compile options included: setup for optimization, setup for the Meridian debugger, create C language source file with Ada code annotations, suppress all checking, prepare the compilation unit for use with MacsBug, generate an error log and produce 68020 machine code for the Mac II owners. Some of the compiler options are transparently passed on to the C compiler. For curiosity sake, I decided to compile a three line program and select the option to generate C source. The C source was annotated with each Ada statement. The C code was very difficult to understand. The Meridian manual suggests that this option only be used for curiosity sake. I believe them. I did find occasional problems with separates when the debug option was selected. The problem is that the Ada compiler generates C code that causes the C compiler confusion. This results in syntax errors. The compilation unit is added to the Ada library. When I tried to link, the linker abnormally terminated with no clear explanation. This is a deficiency in the compiler NOT the language. When the debug option was not selected. The Ada code compiled clean. The Ada compiler supports the creation of DAs, MPW tools or Mac applications.
A pragma is a way to convey information to the Ada compiler (somewhat like a compiler directive). Meridian has implemented 8 of the 14 language standard (the definition of Ada, is located in ANSI/MIL-STD 1815A) pragmas for insertion into Ada code. The 8 supported are: elaborate, interface, list, pack, page, priority, shared, suppress. The remaining 6 may be included in compilation units but are currently ignored by this version of the compiler. A very important pragma implemented is the pragma interface. The pragma interface provides an interface to source code written in either MPW C or MPW assembly. By the time you read this review, Meridian will have released its own Mac toolbox interface standard known as the Macintosh Environment Library (MEL). The MEL addresses volumes 1-3 of Inside the Macintosh. Only the most frequently used toolbox routines are included in Mac toolbox interface offered by Meridian. For $150, the MEL IS A FANTASTIC BUY! If the Mac toolbox subroutine you desire is not available through the MEL, you will have to create an MPW C binding. An MPW C binding is an MPW C routine that calls the Mac toolbox routine with the associated parameters. After compiling the MPW C binding. The MPW auglib command, informs the Ada library of the location of the object code. Sometime in 1989 EVB software incorporated (located in Frederick, Maryland) plans on releasing a Mac toolbox interface library encompassing volumes 1-5 of Inside the Macintosh. No price is yet available.
A generic compilation unit is a template. A generic may or may not have parameters (i.e. types, objects, subroutines). A compilation unit passes the proper parameters to the generic compilation unit. The unit then becomes an instance of the the original generic. The Ada compiler uses the macro expansion method for implementing Ada generics. The compiler actually duplicates the generic compilation unit for each generic instantiation. This method may increase execution time. The trade-off is a larger executable.
-- sample Ada code
with Text_IO; -- attain visibility of the Text_IO package
package Print_Numbers is
-- here is a sample of a generic instantiation
package Do_Some_Integer_IO is new Text_IO.Integer_IO(Num => Integer);
Tasking is implemented by using a round-robbin prioritized scheduling technique. Every task is queued up according to task priority. You must insert a delay statement in the Ada code if a task contains an infinite loop with no tasking constructs. This delay statement will cause the task to suspend and allow other tasks that are queued up to execute. Priorities are defined for each task at the task declaration time with the pragma priority statement. Objects shared between tasks are permitted through the pragma shared. The pragma shared forces the reads/writes to that object to be synchronized between the tasks. The compiler assigns the lowest priority if a task is not assigned a priority at declaration time. Each task created is allocated one kilobyte for its stack size. This limit can be altered at task declaration time by using the Ada length clause. Meridian needs to incorporate preemptive tasking into their task scheduler. This would allow each task to execute in a time slice. After execution, the task would queue up for its next time slice.
The source level debugger has the makings of a very helpful product. All of the debugger commands are entered at the debug prompt. The debugger offers the traditional execution control features: set/list/cancel break points on executable code, examination of objects, list source code, Input/Output redirection, print the stack of subroutine calls, trace a subroutine/object. I was able to examine object attributes (last, length, first, constrained, address, size, all) from within the Ada visibility scoping rules. The debugger offers some more elegant features: a break point whenever there is a contact switch between tasks, a break point when an exception is raised, the ability to examine the raw memory and dump the value of each object that was compiled with the debugger option. I found a rather disturbing problem while executing the debugger. The debugger did not grant visibility to compilation units that are separate from its parent compilation unit. Meridian needs to address this deficiency. The debugger will work with the application option(the ability to create a stand alone Mac application) selected at link time so long as there are no Mac toolbox calls located in the code.
The Meridian optimizer is included in the purchase of the Ada compiler. The optimizer optimizes either on a local or global level. Global optimization removes unused subprograms and global data objects from the executable image. This includes Meridian run-time code. Due to longer link times the Meridian manual suggest that the optimizer be used only when the project is near completion. I used the optimizer to compare speed between optimized and non-optimized execution. Execution time was faster and the executable was smaller in size. It would be helpful if the optimizer informed the user of the compilation units and objects that were stripped out of the executable.
I thought the Ada on-line help facility was adequate. The topics listed in the help facility where valid topics of interest, however, there was not enough information on each of the topics. It would be helpful to have the Ada LRM (Language Reference Manual) available on-line so that syntax error explanations caused by a compilation may be referenced. I found the Meridian compiler/debugger manual to be easy to read and divided up such that it was possible to locate topics of immediate interest. Although I did not sign up for the Meridian technical support, they were very helpful when I did contact them regarding a possible compiler problem. Contact Meridian for information regarding the types of technical support.
Before I continue, let me just say that I will be the first to admit that Ada has its faults and is not the answer to all of our software problems. Ada is the BEST thing going currently and for the foreseeable future. The Meridian Ada compiler is good, although it does have some faults. The Meridian debugger has potential. It does need some work to make it really shine. I have two complaints that should be addressed immediately if this Ada product is to succeed in the Mac market. One, allow visibility of separates from the parent compilation unit in the debugger. Two, get the debugger to work with routines that access the Mac toolbox via the MEL. I discussed these problems with Meridian. Meridian told me that these problems would be fixed with the release of their native code compiler. The native code system is due out in August of 1989. With a price tag of $1195 for the compiler and $500 for the debugger, this development system is aimed at the professional programmer. If you plan on buying the compiler I would recommend that you purchase the whole shootin match for $1,700 (compiler, debugger, utility library and the MEL). Is the Ada development system worth it? Well, if you plan on doing any type of software business with the United States Department of Defense in the future you had better give Ada and the Meridian development system a careful look.
the hardware/software insert
Type of software
Validated Ada language compiler for a Mac.
Meridian Software Systems, Inc.
23141 Verdugo Drive
Laguna Hills, CA 92653
At least 1 meg of RAM
2 meg or more of RAM is recommended
Macintosh(Plus, SE, II)
and a Hard disk with at least 2
megabytes of free space
System 4.1 or higher
Finder 5.5 or higher
227 page manual for the compiler
114 page manual for the debugger
101 page manual for Macintosh Environment Library
$1195 for the compiler
$500 for the debugger
$150 for the Macintosh Environment Library
$50 for the utility library
ADA INFORMATION CLEARINGHOUSE
Information such as validated compilers, software repository and other Ada related information may be obtained by writing or calling.
Ada Information Clearinghouse
Room 3D139(1211 FERN street/C-107)
Washington, D.C. 20301-3081
Patrick McDermott has been an Ada consultant since 1985. He is an ex-Apple employee & cofounder of THE_Ada_EXCEPTION, Inc. which is a consultant group based in Saint Louis, Missouri.