Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 1.5


The REALbasic Compiler

New & Improved

Issue: 1.5 (April/May 2003)
Author: Joe Strout
Author Bio: Joe Strout is a software engineer at REAL Software, and has also been known to play a passable game of Boggle now and then.
Article Description: No description available.
Article Length (in bytes): 14,342
Starting Page Number: 25
Article Number: 1512
Related Link(s): None

Excerpt of article text...

As most REALbasic users know by now, RB 5.0 uses a brand new compiler. But few people know the story behind this simple fact -- why it was done, what problems it was expected to solve, and what new problems it might cause. In this article I'll cover a bit of the history, and then explain what you need to know to use the new compiler most effectively.


From the dawn of REALbasic up through version 4.5, your code was compiled with what we affectionately call "the old compiler." Actually it was two compilers, one for MacOS and one for Windows. The two compilers shared very little code, but worked in basically the same way: the source code was parsed and compiled directly to machine language for the appropriate platform (see Figure 1).

This approach is known as "one-pass" compiling. It has two main advantages: it compiles code very quickly, and it is relatively expedient to write -- that is, if you wanted to write a compiler in a hurry, this is probably the method to use.

However, this quick development and quick compiling comes at a cost, especially in a cross-platform product like RB. Because we had a separate compiler for each platform, it would have been very expensive to add another platform (for example, Palm) -- we would have had to write a new compiler from scratch. For the same reason, there were also a number of subtle differences between the platforms. For example, I recently learned that parameters in a function call are evaluated left-to-right on MacOS (as you would expect), but with the old Windows compiler, they're evaluated right-to-left -- this sort of thing can introduce hard-to-find bugs into your code. Also, the two compilers had different bugs of their own. ByRef parameters, for instance, worked correctly on MacOS but never did work quite right on Win32. Finally, forget about doing any serious optimizing of the compiled code -- a one-pass compiler just isn't set up for that.

There were other issues with the old compilers as well, and to understand these requires a bit of historical perspective. REALbasic was originally the project of a single person, Andrew Barry -- and in fact it was a part-time, evenings-and-weekends project. He had precious little time to work on it, and had no reason to believe that someone else would ever have to maintain his code. Yet he managed to do what very few people in the world could have done: he wrote a complete development environment including not one, but two, compilers.

...End of Excerpt. Please purchase the magazine to read the full article.