REALbasic Release 1
Volume Number: 14 (1998)
Issue Number: 10
Column Tag: Tools Of The Trade
Review: REALbasic Release 1
by Scott J. Anchin
Edited by the MacTech Magazine Editorial Staff
The Power and Simplicity of BASIC
For some time now, Macintosh developers have been searching for a Mac OS equivalent to Microsoft's popular Visual Basic. Enter REAL Software's REALbasic, a visual object-oriented development environment well suited for a variety of tasks ranging from RAD to full-scale commercial application development.
REALbasic uses an object-oriented implementation of the BASIC (Beginners All-purpose Standard Instruction Code) language. Like all modern object-oriented programming languages such as C++ and Java, REALbasic uses classes, inheritance, properties and methods. This allows a simplified approach to programming by allowing code to be reused throughout a project. REALbasic's syntax is also highly compatible with that of Microsoft's Visual Basic, a similar (but in this author's opinion inferior) development tool. This allows developers accustomed to writing software on the PC to feel at home with REALbasic, a definite advantage to cross-platform software authors.
REALbasic supports automatic garbage collection, much like Java. This frees the developer from having to worry about memory management, which in and of itself takes up much of the development time when working with many other languages.
The IDE (Integrated Development Environment) contains all of the expected features in a small streamlined package. Occupying as little as 1.5 Mbytes of RAM, the IDE is blazing fast and incredibly simple to use. The IDE consists of six main components: the Toolbar, the Properties window, the Colors window, the Project window, the Code Editor, and the Debugger
Figure 1. The Toolbar and the Properties window.
The toolbar (see Figure 1) is located by default on the left side of the screen and contains a large number of colorful icons. Each icon designates a Control, which can be best described as an interface object such as a button, a tab panel, or a contextual menu. To add a Control to your project, simply drag the desired Control from the Toolbar to the desired window. Once the desired Control is positioned in the desired window, editing the code for a Control is as simple as double clicking on it.
The Properties window (see Figure 1) is located by default on the right side of the screen, opposite the Toolbar. It contains a variety of changeable settings that pertain to the operation, location, and appearance of the selected Control or window. While many of the settings can also be modified through code, the Properties window provides a convenient central location to specify default values for each of the specific Controls.
The Colors window provides the developer with a single location to store colors frequently used throughout the project. The Colors window is a small floating palette consisting of sixteen small squares, arranged in a four by four grid. Clicking on any one of these brings on screen the standard Mac OS color picker, from which one can then choose the desired color. At that point, the developer can drag the color from the Colors window into the Properties window to change the colors of various interface elements. This small but useful feature can save a great deal of time when dealing with application-wide custom colors.
Figure 2. The Project window.
The Project window (see Figure 2) provides the central location to view all of the elements comprising one's project, i.e. windows, classes, modules, AppleScripts, pictures, movies, shared libraries, and XCMD/XFCNs. To enhance organization, folders can be added to the Project window, and the aforementioned elements can then be placed inside of them. In order to access one of the listed elements of one's project, all that is required is a double click. As an added convenience, clicking once on the element concurrently displays pertinent information in editable form in the Properties window.
Figure 3. The Code Editor.
While much of the REALbasic developer's time is spent visually creating interfaces, a great deal of it is also spent in the Code Editor (see Figure 3), writing and tweaking code in order to attain perfection. The Code Editor is a two-paned window. The left pane is a hierarchical listing of all Controls along with their related events, the events for the window, menu handlers, methods, and properties. With the exception of properties, clicking on any one of these items displays its source in the right pane; properties can be edited by double clicking on their specific names. The Code Editor supports auto indenting, keyword highlighting, and auto completion, resulting in code that is easy to read as well as easy to write. The Code Editor also supports contextual menus which serve the same function as the left pane and are often more convenient. The two panes in the Code Editor are also resizable, allowing the developer to tailor the display to their unique tastes.
The final main component of the REALbasic IDE is the Debugger. Just as with all powerful debuggers, REALbasic's supports breakpoints, step over, step in, and step out. When running your application in the IDE, two windows are displayed in the background: a Variables window and a Stack window. The Variables window displays the current values of one's variables and has a simple object viewer. The Stack window displays the current stack so as to help the developer detect any memory leaks or other memory-related bugs. The debugger is a solid and necessary portion of the REALbasic IDE and is truly useful in tracking down and squashing bugs.
After spending hours developing your interface and code, it is time to test your budding killer app. When the developer chooses to run their application from within the IDE (with a simple "Run" menu command), REALbasic brings its advanced, dynamically recompiling compiler into action. This is described as having "all the benefits of an interpreter, while running at fully compiled speed," i.e. every time the developer runs his or her application, REALbasic recompiles it instantly. This provides the speed and versatility of a HyperCard-like interpreter, while allowing the application to run just as any compiled C++ application would.
If You Build It, They Will Come
When it comes time to compile an application and show it to the world (or at least to some beta testers), REALbasic's Build dialog (see Figure 4) comes into play. This dialog houses all information relevant to a final application, including its name, icon, and version information. It also lets one specify whether they want a 68k app, a PowerPC app, or a FAT app. Compiling a PowerPC app also has an additional option: Compress. Compressing a PowerPC app applies a proprietary resource compression scheme which cuts the size of the application dramatically while allowing it to retain full speed despite requiring only an additional 600 kbytes of RAM. Clicking on the Build button compiles the application and places it in the same folder as the project file.
Figure 4. The Build dialog.
It should be noted that, unlike many similar languages, REALbasic compiles applications to machine code; it does not use an interpreter. Thus, REALbasic applications require less RAM, less hard disk space, and run considerably faster than one might expect.
Create Truly Powerful Mac OS Apps
REALbasic allows the developer access to a wide variety of features without the need to delve into the toolbox. With support for a number of industry and Apple standard features, REALbasic makes it easy to create truly powerful Mac OS apps.
Game developers will appreciate REALbasic's advanced sprite engine. Based on SpriteWorld, it is fast, efficient, and simple to use. With complete control over virtually every aspect of sprites, the developer is freed of virtually all creative limitations. Using the sprite engine also creates animations which are flicker free, thereby creating a professional appearance.
REALbasic's graphics support is also very powerful. With support for off screen drawing areas, developers can modify information displayed on the screen without flicker, and can preload images for enhanced speed. Text drawn with the graphics object can support automatic word wrapping, and can be drawn with varying fonts, sizes, styles, and colors. REALbasic also supports drawing various simple shapes. Additionally, it can display any graphic supported by QuickTime, giving the developer convenient access to a wide variety of file formats.
Still another advanced feature of REALbasic is its text handling. It is second to none. By using the WASTE text engine, fields can contain greater than 32 kbytes of data, a limitation imposed by standard TextEdit. Fields can contain varying fonts, sizes, styles, and colors, all of which can be changed on the fly through code. Fields also have a number of filters which can be applied to them in order to limit input to a specified type of data.
Getting information in and out of an application is essential to many programs. Thus, REALbasic provides excellent support for file i/o. REALbasic can retrieve and change almost every aspect of a file, and can read and write to them with a great deal of speed.
REALbasic also allows for transferring data through the serial ports or via TCP/IP. The Serial Port Control makes communicating with custom pieces of hardware a breeze. The OpenTransport native TCP/IP Socket Control allows the developer to add support for various Internet protocols to their applications quickly and efficiently.
For added speed and efficiency, REALbasic supports the use of threads. This allows code to be running in the background, will still allowing the user access to the program's interface.
Support For Key Mac OS Technologies
REALbasic embraces virtually all technologies that have made the Mac OS such an excellent platform. With built-in support for such technologies as QuickTime, AppleEvents, Drag and Drop, Contextual Menus, and the Appearance Manager, REALbasic applications can be as advanced as the developer desires.
Using the MoviePlayer Control, the developer has access to a wide variety of QuickTime features. Users can specify how a movie will be played, as well as when it begins to play. One particular benefit of the MoviePlayer Control is that it supports the display of any media type that the currently installed version of QuickTime allows. For example, an animated GIF can be played back from within a REALbasic application with the presence of QuickTime 3.
REALbasic includes extensive built in support for AppleEvents. AppleEvents, the Mac OS standard method of interapplication communications, provides a way in which developers can send messages between their applications and others in order to perform such tasks as transferring data. For example, data could be entered into a REALbasic app which could then be transferred to FileMaker Pro for subsequent addition into a database.
With Drag and Drop becoming more and more standard throughout the software industry, REALbasic's support for Mac OS standard Drag and Drop is a most welcome feature. Developers have full control over drag regions and the contents of the drag data. As an added bonus, Multiline EditFields support Drag and Drop without the need for any code. REALbasic also provides a mechanism for easily adding these capabilities to ListBoxes with very little code.
It is also a comfort to know that REALbasic-built applications will look at home in future versions of the Mac OS. With built in support for Apple's Appearance Manager, all of the Controls are Appearance-savvy. With the release of Mac OS 8.5 and switchable themes, the Controls will alter their appearance to fit in with the current theme.
REALbasic's support for the latest Mac OS technologies does not stop there. It allows you to quickly and easily apply balloon help to any control or menu item, and allows placement of items in the Help menu. This allows for the creation of custom help systems, such as HTML help viewers. Also supported is the creation of Contextual Menus which, through a custom implementation, are displayed regardless of whether or not Mac OS 8 is installed.
While REALbasic's built-in capabilities are generally sufficient for virtually all tasks, one occasionally needs access to an unsupported feature or the Macintosh toolbox. For this reason, REALbasic is easily expandable through the use of AppleScript, XCMD/XFCNs, shared libraries, and REALbasic native plug-ins.
Compiled AppleScripts and XCMD/XFCNs can be incorporated into a REALbasic project by dragging and dropping it from the Finder to the Project window. Once added to the project, they can be called just as a built-in method would be called.
Shared libraries can be added to a project in the same fashion as AppleScripts and XCMD/XFCNs. Double clicking a shared library once it is in the Project window displays a window, from which one can define entry points for the shared library. The entry points can be accessed through code with support for such items as MemoryBlocks, enabling one to store data returned from the libraries.
Perhaps the best way to add functionality to REALbasic is through a REALbasic native plug-in. Plug-ins have full access to the toolbox, and can add either methods or Controls to REALbasic. Placing a Control plug-in into REALbasic causes the Control to appear in the Toolbar just as any built-in control would, and is used in the same way. Developers wishing to create plug-ins can download the SDK directly from REAL Software's web site, free of charge.
Port Your Windows Apps
The high level of compatibility between REALbasic and Visual Basic's syntax makes REALbasic the perfect tool for porting Windows-based Visual Basic applications to the Mac OS. By dragging any Visual Basic 2.0 or later form (.frm file) into REALbasic's project window, it is automatically converted into a REALbasic window, and incorporated into your project. Additionally, REALbasic supports dragging and dropping Visual Basic Code Modules (.bas files) into the project. This too incorporates the file into your project. The extensive Visual Basic support provides an excellent opportunity for Windows software developers to expand their market, while adding to the growing number of Mac OS applications on the market. This approach is also extremely cost-effective, as it requires very little time on the part of the software developer to perform this porting.
The center of the large REALbasic community is the REALbasic NUG mailing list. From here users of any level can ask questions, request features, and hold discussions on almost any aspect of REALbasic programming. The members of the list are helpful, and for the most part courteous. As one of the first members of the list, I have seen it grow from a small resource to an essential aspect of REALbasic programming.
On the web, REALbasic users have set up the REALbasic Webring. With a fairly large number of members, this is another excellent resource for any developer. Pages on the webring range from companies which utilize REALbasic in their development, to individuals offering code snippets, to extensive FAQ listings.
REALbasic users have also set up a Hotline server, the REALbasic Café, as a place to discuss the language, ask questions, share ideas, and upload your programs for others to see. When visiting the Café you will notice that the people there are always willing to help you out, and during discussions, will even create programs for you to illustrate their points.
Overall, members of the REALbasic community are an enthusiastic, helpful, and pleasant bunch. They hail from many countries across the globe, and together make up an indispensable programmer's resource.
What Will The Future Hold?
Quite appropriately, a primary concern of those interested in purchasing a new development environment is whether the company is planning a future for the software. It seems clear indeed that REALbasic has a long and bright future ahead. As of this writing, REAL Software is in the early development stages of Release 2. As of this release, REAL Software will be producing two versions of REALbasic: a standard version and an extended version.
The standard version of Release 2 will be similar to the current version, with the addition of numerous features, including improvements in such features as QuickTime support, Sprite support, and the Socket Control. Release 2 will also feature a Java compiler, which will allow Java applets to be compiled just as easily as standard Mac OS applications are compiled.
The extended version will be identical to the standard version, with two important differences. The first is the addition of ODBC and SQL database support, with the inclusion of a single user database. The second of these differences is the addition of a Windows compiler. Much like the Java compiler, the Windows compiler will create applications that will run on Windows 95/98/NT as easily as creating a Mac OS application. This will give developers the exciting capability to create a single code base, and deploy their applications on the Mac OS, Windows, and on the web.
REALbasic's documentation is extremely thorough. Consisting of over six hundred pages, the printed documentation is divided into three parts. The first of these parts is the tutorial. As step-by-step guide to creating your first application, the tutorial assumes absolutely no prior programming experience, making REALbasic accessible to the beginner. The second portion of the documentation is the developer's guide. Made up of fourteen chapters, this guide covers everything from the basics of object-oriented programming to the complexities of interapplication communication. Finally, REALbasic provides a comprehensive language reference indexing every part of the language. The documentation is bound with a spiral binding so that it can lay flat on any surface, a convenience that should not be underestimated.
Though printed documentation is essential, it is often inconvenient to attempt to locate a volume while deeply engrossed in coding. For this reason REALbasic includes an online reference. Simply select any Control or word in the Code Editor, open the online reference (through either a menu selection or command-1), and it will automatically display the proper help topic. This feature proves to be indispensable over the course of the development process while working on a given project.
Being a first release and having so many features, it is almost inevitable that REALbasic would contain a few of minor bugs and inconsistencies. Though numerous work arounds exist, they are often bothersome nonetheless. To their credit, REAL Software has pledged to release free updates to the software in an effort to fix all outstanding bugs.
REALbasic is without a doubt a solid new entry into the Mac programming world. With HyperCard-like simplicity, C++-like power, and compatibility with Visual Basic, REALbasic is a most powerful tool. Whether you are involved in RAD, building front ends for AppleScripts, or developing custom software, shareware, and/or commercial software, REALbasic has the tools for you. In short, REALbasic is worth many times its $99 price.
Scott Anchin, firstname.lastname@example.org is the founder of Precise Sales & Research, http://www.psrsoft.com, a software development company. He is also associated with Fisher, Towne & Associates, a national developer of electronic catalog and commerce systems for several Fortune 500 companies. Additionally, he is an online support editor for MacTech Magazine.