[ Direct Download: Latest TeXShop | Latest TeXShop Source ] [ Contact ]

The Fragile Base Class Problem

We call the classes Apple provides in Cocoa the "Base Classes". A Cocoa program subclasses these objects, and adds additional objects. The following dream is a consequence of this organization: perhaps Apple could add extra features to the base classes in a system update and all programs would inherit these new features for free. It is not uncommon to update macOS and hope that TeXShop runs a little faster. But if the dream were possible, you would update macOS and TeXShop would get the new features you always wanted without any work from me or my collaborators.

Unfortunately, object oriented languages have two problems which make this dream impossible. First, it is not possible to add new instance variables to the base classes. And second, it is not possible to add new methods or procedures to the base classes. A system update can rewrite the base classes and make them more efficient, but it cannot make them do brand new things.

Now NeXt and Apple used Objective C rather than C++. In Objective C, it is possible to add new methods to base classes . So half of the problem goes away. But it isn't possible to fix the other problem because Objective C has a "runtime component" which is provided by the operating system. Changing that component would break all existing Cocoa programs.

Apple found itself in a highly unusual situation when it added support for 64 bit programs to macOS. For just one moment, there were no existing 64 bit programs. So Apple could provide new runtime code for 64 bit Cocoa applications without breaking anything. Using this unique opportunity, Apple rewrote the runtime specification for 64 bit Cocoa applications and completely fixed the Fragile Base Class Problem in macOS.

Usually Apple is good at supporting much older systems, but for a short time starting with Snow Leopard, they made quite new systems obsolete so only the latest systems could upgrade to Lion and Mountain Lion. A consequence was that almost all applications on these systems were running in 64 bits with the new runtime. For the first time in history, Apple could update base classes and provide new features to existing programs automatically without recompiling anything. This is an astonishing accomplishment, and Macintosh users should celebrate. Instead, most seem unaware of what happened.

Consequences of the Fix

Users often requested the following TeXShop behavior. If they quit TeXShop with windows still open, and later restarted the program, they wanted the old source and preview windows to reappear exactly where they were before the program closed. For years I promised to add this feature but never did. Then macOS 10.7 (Lion) appeared, and suddenly the feature worked in TeXShop although we had done nothing. Apple made it work automatically. Currently it works in TeXShop and everything else provided you select the correct Apple System Preferences configuration.

On the main TeXShop web page, we provide a link which gives the original 2000 version of TeXShop and its source code. We recompiled the source without changing anything and it worked on Intel. Moreover that original version now has the feature described in the previous paragraph because Cocoa added it automatically.

Another common TeXShop request was tabbed source and preview windows. Instead of dealing with multiple windows, new source files should open as tabs in one source window, and their associated pdf files should open as tabs in the Preview window. The two tabs should be linked, so typesetting a tabbed source should open the corresponding tabbed preview. Etc. All very complicated, so we avoided the request. But it appeared automatically in Lion, and then in even more powerful form in later systems.

The full implications of these new tabs require several pages to describe fully, and yet Apple's automatic implementation worked with virtually no tweeking from the TeXShop developers.

TeXShop has a "Help" menu, and that menu contains several items including a 200 page manual for TeXShop. The manual describes tabs and how they work cooperatively in a full chapter. Consult that chapter for details.