Programming Topics

A program is normally written in a high-level language, which is understood and can be modified by a programmer. To be used, the completed work must be compiled into machine code, creating a stand-alone application that can be launched on the chosen computer platform. The original high-level form of a program is known as the source code while the final result is called the object code. A script is similar to a program but usually employs a simpler or specialised language.

Constructing a Program

You can test a program by using an interpreter or compiler application.

An interpreter executes each line of the source code every time you run it. This means the program runs slowly and can’t be used as a stand-alone application, although the effects of any changes are seen immediately. Such an interpreter, such as BASIC.COM on a PC, uses lines of source code that are kept in a specific data file, such as MYPROG.BAS.

A compiler application translates your entire source code into object code in one pass. The compiled result can then be used as a stand-alone application at full speed. Sadly, the need to re-compile the program for every minor alteration can make this a tedious process. Fortunately, each subroutine in your source can be compiled separately and the resultant components joined together by means of a link editor or linker. The final result is known as a load module.


Those who modify existing data or code in a constructive form are commonly known as hackers, the actual process being known as hacking. Sadly, hackers are confused with crackers, those misguided individuals who probe into computer systems, threatening both our national and personal security.

Programming Languages

Programs can be created at several levels:-

Machine Code

This consists of data and binary codes for instructions that are aimed at a particular kind of microprocessor. Few programmers work at this rudimentary level since it’s such hard work.

Assembly Language

This uses hexadecimal (hex) values for data and three-letter mnemonics for the instruction codes. Some programmers like working at this low level since it gives greater control, although it also allows them to break accepted conventions, resulting in programs that can be incompatible with other software or hardware.

High Level Languages

These languages are written in pseudo-English and are reasonably easy to understand. Fairly simple software can be used to convert a program from such a language into the final object code. The most common high-level languages include:-

APL ​(A Programming ​Language)Matrix ​manipulation
BASIC ​*General, ​poor ​structure
CGeneral, ​powerful
COBOL (Common ​Business ​Oriented ​Language)Text ​and ​records
ForthGeneral, ​reverse-Polish ​notation
FORTRAN ​(Formula ​Translation)Solving ​mathematical ​problems
LISP (List ​Processing)Building ​lists ​of ​data
Modula-2Real-time ​control
* Beginner’s All-purpose Symbolic Instruction Code

Of these, two deserve special mention. BASIC, which was popular with amateurs in the eighties, began its life as a highly unstructured language. In common with other older languages it used line numbers, which meant that references to other parts of a program were easily displaced by other modifications. In addition, it didn’t support subroutines or procedures, which meant that programs were constructed in an ad hoc manner, often ending up in an unworkable form. Fortunately, later versions of BASIC dispensed with line numbers and now include the missing features. Sadly, it retains a rather bad ‘image’, although programs written in BASIC are often easy to read.

The second language of great importance is C. Unlike BASIC, this is in a highly structured form, with routines forming the backbone of its environment, saving programmers from ‘re-inventing the wheel’ for every application. It’s also spawned numerous derivatives, such as Java, JavaScript, Perl and TCL. As with other modern languages, C is object-orientated, allowing a programmer to achieve the desired results without any deep understanding the processor that’s being used.

Inter-Application Communication

Traditionally, most programs operate in isolation, the only communication being between the application and the operating system. More recent systems, including Classic Mac OS 7.x or higher, allow data to be transferred directly between different processes. Usually this involves a pair of applications and is known as Inter-Application Communication (IAC).

Apple Event (AE)

As the name implies, this form of IAC is exclusive to the Mac OS, although other operating systems can use similar mechanisms. Each Apple Event, also known as a low-level event, belongs to a subset of the high-level events employed by AppleScript for communicating between applications and the Finder. Every event gives the destination process a full set of instructions on how it should behave. Although flexible, this makes Apple Events rather slow and cumbersome.

The events are grouped into the following sets, which are known as suites:-

Required Suite

All processes are expected to accept these instructions:-

Open Application

Open Documents

Print Documents

Quit Application

Core Suite

Most processes are expected to accept these events:-








Functional Area Suite

These events cover activities for a particular class of process, such as a drawing program.

Custom Suite

These events cover activities involved in software development.

Process to Process Communication (PPC)

PPC is a low-level form of IAC, also used in the Mac OS. It establishes a communication session with the destination process before sending any data. Having done this, the information can be sent in a simple form, which makes it less flexible than Apple Events but faster.

Here’s an example of PPC in action:-

Process 1 opens port A

Process 2 opens port B

Process 1 tells the System ​it’s ready for PPC

Process 2 asks the System ​for a session with port A

PPC is usually asynchronous, so each process executes its function and gives an instant response. The system can provide a call-back to confirm that operations have been completed or flags are in the correct state. Since PPC works in both directions the software can report any problems that occur.

Publish and Subscribe

This is exclusive to the Classic Mac OS and is no longer supported. Unlike other forms of IAC it only works in one direction. Any document, created in any application, can publish specified data from within itself to a publication file. A second document (created in the same application or in another application) can then subscribe to this file. If the original document is updated at a later date the publication and the subscribing document can be manually or automatically updated.

©Ray White 2004.