Programmer's Wiki

Objective Modula-2 is a reflective object oriented programming language developed as a hybrid between Smalltalk and Modula-2 following Objective-C as a blueprint. The language is aimed at Cocoa and GNUstep application development as an alternative choice to Objective-C. It uses the Objective-C runtime system and classes written in Objective Modula-2 can be used within Objective-C and vice versa, without the use of a bridge.


Objective Modula-2 is a thin layer on top of Modula-2 with language extensions to implement the Smalltalk derived object model of Objective-C. The message passing syntax is inherited as is from Objective-C, all other language extensions are cast in a Modula-2 like syntax. An alternative Smalltalk style message passing syntax uses the backquote as an escape character, thereby avoiding the brackets used in Objective-C.

An example of an Objective-C style message:

  • foo := [[FooClass alloc] init];

An example of a Smalltalk style message:

  • foo := `FooClass alloc init;

Like Objective-C, as a hybrid of two languages with different programming paradigms, Objective Modula-2 is difficult to classify. Its core language is Modula-2 which makes it a statically typed, imperative systems programming language. However, on top of the Modula-2 core language, Objective-Modula-2 defines a thin layer of Smalltalk derived object oriented features which also make it a reflective, dynamic, late binding, object oriented language. These may initially seem to be conflicting programming styles, but in practise there is a clear separation between the two. The core language is used to code the control flow of a program and the Smalltalk derived extensions are used to define and work with abstract data types. As a result of this practise, a program written in Objective Modula-2 benefits from the expressive power and flexibility of Smalltalk and the execution speed and type safety of Modula-2.

Further reading[]