Home/Ada Products & Tools

Ada Flyer Claw:
Ada 95 - Windows 95 Binding

An Ada Technology Insertion Program-Partnerships (ATIP-P) Project

System Improvements Create Opportunity
The Ada programming language was revamped in the same year as MicroSoft Windows, which was a serendipitous bit of luck for R.R. Software. The Madison, Wis., company took advantage of the two systems' improvements to create a binding between them called "Claw." Currently in beta release, the binding and GUI builder in one is a tool for creating applications using Microsoft's Windows interfaces.
Developing Claw
The Ada 95 GUI Binding and Tools for Microsoft Windows 95 is one of the projects funded by the Ada Joint Program Office's Ada Technology Insertion Program-Partnerships (ATIP-P). Their motivation for funding the development of a Windows 95 binding was strong: X-Windows bindings put software engineers through the horrors of non-standardization, from which Ada 83 was supposed to protect them. There were 10 different specifications for Xlib, Xt, and Motif -- most were incomplete and all incompatible with each other. The decade of recoding and testing GUIs opened the Ada community's eyes to the importance of committing money up-front to the creation of a single robust binding.

R.R. Software specifically designed its GUI binding and tools to be compatible with four groups of compilers -- its own, Thompson Software's, Rational's, and the freeware GNAT. Because Ada compilers must all pass the same suite of tests in order for the government to "validate" them, R.R. Software's Randall L. Brukardt is confident that, if the binding and GUI builder run on these four compilers, they will run universally. The company plans to have a set-up program that will slightly tailor the binding for different compilers and, otherwise, be completely portable.

In the best case scenario for R.R. Software, compiler vendors will package their products with the Claw binding rather than commit funds to create their own. As Brukardt says, "It's good for Ada too, since if people develop their own bindings, we have another example of the Tower of Babel."

Another factor motivating the bid for a standard binding was the immense difficulty of programming in Ada for a Windows application before 1995. C and C++ programmers could access Win32 directly. An Ada 83 programmer developing a Windows application would have to write C code in Ada syntax, which, Brukardt points out, is "unnatural coding." Some bindings do exist now for the Microsoft Windows 95 operating system, but are they insufficient. R.R.'s current compilers, for example, only cover about a third of Win32.

Claw's Capabilities
R.R. Software demonstrated Claw, which runs equally on Microsoft's Windows 95 and Windows NT operating systems, at the TRI-Ada trade show in December 1996.

Its capabilities were described in the following example, where a developer is creating an Ada 95 application with a Windows 95 interface to monitor the air pollution of a factory. The developer wants to design a large window that displays the day's data. To save it, she creates a small dialog window with a child package that asks for the name of the new file. She can compile the smaller window independently of the large one. If later she decides to make the name of the file default to the day's date, then she can edit the child package and recompile it as an independent entity, again without involving the code for the large window. With Ada 83, the developer would have had to recompile a monolithic system each time. Aside from slowing compilation, it would have brought in thousands of functions that she would not use.

In addition, the Claw helps to reduce the size of the developer's application. In following good application development techniques, a developer will strive to restrict herself to one kind of dialog box, window type, etc. Having a wide variety of boxes or windows among functions, such as dialog boxes of different sizes for saving files versus opening files, distracts and confuses the user. But without owning the code to Win32, Microsoft's Application Program Interface (API) for both Windows 95 and Windows NT, the developer would be forced to abandon the strong development technique and use many different styles as she added functionality or to maintain one style at the cost of greatly increased application size.

To give an example of the Claw's savings in application size, Brukardt discussed the project's GUI builder, currently under development at R.R. Software. The builder is being written in Microsoft Foundation Classes (MFC) and C++ because, until they complete their own work, no binding yet exists with which to develop it in Ada 95. The prototype version, linked statically, was 1.6 MB-2 MB, without any functioning. "It dragged in everything," Brukardt said. "It can't be using all that code, but it is all in there, because it is all part of the MFC." The prototype for the first cut at the bindings, on the other hand, was only 70K. While Brukardt admits that the comparison of the GUI prototype builder and the prototype binding sample program is a bit like comparing apples and oranges, it is still notable that the first is larger than the second by a factor of 20.

Claw also has a default value for many parameters, such as window size and colors, which further ease the Windows application developers' workload. The environment assumes that system default sizes and colors will be used for each function so that the developer does note have to specify size and color with the addition of each new function.

Claw also allows developers to build the visual elements of the application by drawing them on the screen: the developer draws the box and the software generates new code for it. Previously, Ada programmers who did not want to resort to a C code generator would have to create a dialog box, for example, by counting the coordinates on the screen, compiling the whole program, then checking the results and editing the numbers until they got it right, often requiring several hours.

The Role of Object-Oriented Design (OOD)
Not only will the GUI help Ada programmers to use object-oriented design, the binding itself is designed around objects. Brukardt asserts that an OOD approach is the natural choice for GUIs.

Brukardt also chose OOD to avoid changing the underlying code that structures the application. If he had used Ada 83 or C, every time he changed the custom part of code, he would have had to change the driver for it, introducing mistakes that would be hard to find.

For those using the Microsoft Windows 95 binding to program in Ada, OOD allows the framework to insert its own code with minimal editing to the code of the basic application. By declaring a single object, the developer gets a blank tool bar and menu without any coding. For example, the OOD allows him to change the menu handler without changing the resize code if he did not want to, which is an inherent part of the GUI and should work fine. In other words, the GUI binding looks like an application before the developer does any coding at all; much like a standard form, the format is provided, but the user fills in the content.

The Ada 95 Advantage
Ada 83, the original Ada, could have interfaced with Microsoft's new operating system, but only with a colossal commitment of program size and compilation time. According to Brukardt, Ada 95 can now interface easily with Windows 95 because of the language's new, standardized interface to C. It also allows Claw to be ported to other compilers. R.R. Software has developed the binding along an object-oriented design, which Brukardt says is a perfect match for a user interface.

Ada 95 features many new characteristics that support object-oriented design more strongly than did Ada 83. Ada was designed to facilitate strong software engineering, which often encouraged an OO approach; Ada 83, therefore, did offer some OO capabilities. Veteran Ada programmers insist that inheritance support, for example, is not a feature that is new to the language -- Ada 83's generics performed that function. In fact, since the first release of the language, Ada has offered many C++ features: modularity, packaging, etc. "Studies show that most C++ users really use very little OOP," Brukardt said. "Ada has always offered exactly what C programmers actually use in C++. They get the wonders of strong typing and encapsulation, which they could have had 10 years ago if they had used Ada." Ada 95, however, does offer many more fully object-oriented design features, rather than just object-based.

Writing Windows 95 applications in Ada 95 may now be easier than writing them in any other language because Claw exploits many of Ada's new features. In addition to child packages, Ada 95's inheritance is a "big advantage" in designing the GUI through objects. Developers using the GUI for their own applications will exploit the inheritance feature extensively, since the ability for types to inherit the primitive operations of "ancestor types" is fundamental to OOP. If types Heat and Smoke are derived from type Pollution, all three can be added and subtracted from the previous day's figures without separate declarations. Such an application would also bring in Ada 95's dynamic binding, which allows the parameters of a type to be determined during execution rather than during compile time, such the amount of Heat and Smoke that Chimney #1 has emitted in the last hour.

Another Ada 95 innovation is returning errors via exceptions, finding the right balance between ignoring unimportant glitches and warning the developer when major problems arise. The Win32 binding returns a Boolean true or false when checking for the existence of errors. A lot of the errors are extremely rare or nonexistent, while others are crucial. C software will usually compile no matter, which allows programmers to ignore errors -- sometimes wisely, sometimes not.

Ada 83 bindings to Win32 returned every error as a function, which the programmer had to read and do something about whether or not it was important. With Claw, the error is turned into an Ada program that returns an exception. Usually it does not raise an exception and does not have a return, because the program treats it as a procedure call. If an error does occur, then the program raises an exception and handles it. If it is important, then the program aborts and the programmer can handle the error while debugging it, instead of during run-time. Along with the exception, the binding returns error numbers that are part of Windows' exception message.

In Claw's object-oriented design, the R.R. developers have made extensive use of one of Ada 95's five new reserved words, "tagged," which indicates a tagged type, as well as Ada 95's type extension, inheritance, and polymorphism, all of which are interrelated. A developer can add components to a tagged type derived from an ancestor type. The derived type is an extension of the ancestor. She can then define additional primitive subprograms, called dispatching operations, and override others as part of the inheritance feature. The software can call the dispatching operations statically through controlling tags during compilation. It can also determine the controlling tag dynamically -- at run-time, it determines the body to which the call is dispatched. The controlling tag is determined through the properties of the operands and context of a particular call on a dispatching operation. In turn, that decides whether or not the call is a dispatching call. When the programmer has a dispatching call call a dispatching operation, she has achieved run-time polymorphism.

The Claw Mailing List
Those who are interested in receiving updates on Claw, may join R.R. Software's Claw mailing list by sending an email message to
Include in the body of the message: SUBSCRIBE

For more information via the Web, access R.R. Software's homepage for Claw at http://www.rrsoftware.com/claw.htm.

Ada Technology Insertion Program-Partnerships.
All registered and trademarked brand names are the property of their respective holders.

Copyright 1998. IIT Research Institute
All rights assigned to the US Government (Ada Joint Program Office). Permission to reprint this flyer, in whole or in part, is granted, provided the AdaIC is acknowledged as the source.
Form T225

Home Webmaster Last Updated: 08/11/98