Objective Modula-2 FAQ
Frequently Asked Questions about Objective Modula-2
What is Objective Modula-2?
Objective Modula-2 is a reflective, object-oriented programming language with both static and dynamic typing, based on the object model and runtime of Objective-C. It is a hybrid between Smalltalk and Modula-2, using Modula-2 as a base language for flow control and Smalltalk derived messaging for its object system.
Why Modula-2?
For almost every group of programming languages there is at least one language for which support for Cocoa or GNUstep is available, but there is not a single language from the Pascal family which has Cocoa/GNUstep support. Yet, languages of the Pascal family remain popular and are generally safer than C. Objective Modula-2 is intended to fill the gap.
The reason why Modula-2 was chosen as a base language over other Pascal family languages is also very simple. Since the heavy lifting in the new language will be done using the Smalltalk derived object model and Cocoa or GNUstep, there is no need for any advanced features in the base language. Consequently, the ideal candidate for the base language would be a small language which lacks the features that will be added by the Smalltalk derived object system.
The requirements for the base language were:
- minimalist design philosophy
- separate compilation units and data encapsulation
- suitable for systems programming without compromising safety
- lack of any generics and lack of any object oriented language features
- not requiring a runtime which might be in conflict with the ObjC runtime
- a C compiler (C99)
- the C libraries stdlib, stdio, stdint, stdbool and errno
- an Objective-C compiler (initially) or LLVM
- the Objective-C runtime
//comments- additional integer types in
stdint.h - boolean type in
stdbool.h - compound literals
- variable length arrays
- variadic macros
Within the Pascal family, the language which meets all of these requirements is Modula-2, as defined in Wirth's Programming in Modula-2 (PIM). Any other languages within the Pascal family fail to meet at least one of the requirements, which would have made integration with Cocoa/GNUstep cumbersome or it would likely have made the resulting language a poor alternative to Objective-C.
Why is it called Objective Modula-2?
Objective Modula-2 is not about inventing yet another way to add OOP to Modula-2. Instead, it is all about adding native Cocoa and GNUstep support to Modula-2 where Objective-C serves as a blueprint. The name has been chosen to reflect this.
Why not just use Objective-C?
Objective-C is a great language, even to those who do not particularly like C. However, the use of C as a base language means that even the most carefully written Objective-C code is exposed to the shortcomings of C, in particular it is potentially unsafe. Replacing C as a base language with a type safe programming language will result in safer software.
Last but not least, the choice of programming language is to some extent a matter of personal style and taste. Developers who prefer a language of the Pascal family will usually feel quite comfortable with using another language of the Pascal family, but many do not feel comfortable with using a language of the C family. Yet, many of them have an interest in Cocoa/GNUstep or iPhone development.
Why not develop a Cocoa bridge for Modula-2?
Cocoa bridges translate between a native object model and the Cocoa object model. This is achieved by copying data back and forth at runtime which impacts performance. Further, for every object used there are actually two objects being maintained, adding to the memory footprint. Finally, the development and maintenance of a bridge can be a daunting task as modifications and additions to the Cocoa framework often require amendments to the bridge.
Using the Cocoa object model natively in the language avoids the need for a bridge and consequently does not have any of these shortcomings. Native support for the Objective-C object model typically requires language extensions similar to the extensions that were added to C when Objective-C was first created. In the present Objective Modula-2 parser, there are a total of only 72 productions which includes all the grammar needed for native Cocoa support. We believe that building and maintaining a bridge would be far more effort.
If this was such a good idea, shouldn't there be other such hybrids?
Objective Modula-2 is not the only one. There are other hybrid languages following the same basic idea, for example F-Script, Nu, ObjectiveCLIPS, Objective-J, and Objective Smalltalk. And of course there is Objective-C itself.
Is Objective Modula-2 based on ISO Modula-2?
No, the Objective Modula-2 language is based on a subset of Modula-2 as defined
by Wirth in the fourth edition of Programming in Modula-2. Local modules, variant records,
subrange types, the WITH DO statement and non-zero array indices have been omitted.
ISO Modula-2 has made some changes to the language core which can fairly easily be incorporated
into the reference compiler at some point in the future. However, the libraries, generics and
object-oriented extensions of ISO Modula-2 would not add anything useful to Objective Modula-2.
The ISO libraries aren't neccessary because in Objective Modula-2, the Cocoa or GNUstep frameworks will be used instead. The ISO object oriented extensions aren't neccessary because in Objective Modula-2, object oriented extensions to implement the Objective-C object model are used instead. Finally, the ISO generics aren't neccessary because the object model in Objective Modula-2 features dynamic typing.
Yet, there is no reason why the ISO standard could not be incorporated in the future. This would be roughly comparable to Apple's incorporating C++ into Objective-C, the result of which is called Objective-C++.
Why the omissions of Modula-2 features?
Objective Modula-2 is aimed at Cocoa and GNUstep development. Language features which are not essential in the context of the object model and the Cocoa/GNUstep frameworks were considered unnecessary ballast. Omitting these non-essential features will speed up the development of the reference compiler.
Why not add the Objective Modula-2 extensions to GNU Modula-2?
That would be desirable at some point in the future. We had discussed this idea with Gaius Mulley, the lead developer of GNU Modula-2 and he seemed to be sympathetic to the idea in principle. However, for the time being it is more important for GNU Modula-2 to achieve full ISO compliance since GM2 has a much broader audience.
Can classes written in Objective Modula-2 be used in Objective-C?
Yes. Likewise, classes written in Objective-C can be used in Objective Modula-2.
Is Objective Modula-2 for Mac OS X only?
No. Objective Modula-2 is intended for use with any Objective-C runtime environment and any related framework regardless of platform. Frameworks of particular interest are Cocoa (on Mac OS X), Cocoa Touch (iPhone) and GNUstep (other Unix-based or Unix-like operating system environments).
Will it be possible to use Objective Modula-2 for iPhone development?
Yes. It will be possible to use Objective Modula-2 wherever Objective-C can be used.
When is the Objective Modula-2 compiler going to be ready?
The lexical and syntax analysis is mostly complete and there are not many changes in the language definition to be expected now. However, the code generator is mostly a TO DO item still. Since this is not a bread-and-butter project, it is difficult to set and meet deadlines. Hopefully, and with a bit of luck, we may have a working compiler generating ObjC source code by the end of 2009 or early 2010. An LLVM code generator should follow in 2010.
What are the dependencies for the the Objective Modula-2 compiler?
What are the dependencies for the generated code?
Which C99 features does the Objective Modula-2 compiler depend on?
Will the Objective Modula-2 compiler have X-code integration?
That's the intention, eventually, yes.
Will the Objective Modula-2 compiler generate Mac OS X universal binaries?
At the first stage, the Objective Modula-2 compiler will generate Objective-C source code, which can then be compiled using Xcode (or gcc directly) to generate universal binaries. When the compiler gets an LLVM backend, it will be able to generate universal binaries via LLVM and libtool.
Can the compiler also be used with Carbon instead of Cocoa?
In principle yes, but the compiler will come without any interface definitions for the Carbon library. For Carbon development, it may be advisable to use p1 Modula-2.
Can the compiler also be used for ordinary Modula-2 programs?
In principle yes, but the compiler will come without any Modula-2 libraries, at least initially. For traditional Modula-2 development, it may be advisable to use GNU Modula-2.
Can the compiler also be used on the Classic Macintosh?
Objective Modula-2 is aimed at Cocoa and GNUstep. There are already several Modula-2 compilers available for Mac OS Classic, both free and commercial.
Can the compiler also be used on Windows?
In principle, it should be possible to use Objective Modula-2 with GNUstep or Cocotron on Windows. Cygwin or MinGW will probably be needed to do so.
Which C compilers can be used to build the compiler on Windows?
The Digital Mars C compiler and the Equation port of GCC should work.
Under what license will the compiler be available?
All the source code for the compiler will be available under an amended BSD license. However, to prevent the emergence of dialects while the grammar is still in motion, source files which have an impact on the syntax are currently released under a peer review license. Once we have a finalised specification and a working reference implementation, these files will be relicensed under the amended BSD license.
I would like to contribute to Objective Modula-2. How do I go about that?
Both sponsorships and code contributions are welcome. Please contact the project by email (objective at modula2 dot net).
But didn't Wikipedia say this project was dead?
Wikipedia does have some very good content, but if wikipedians get something wrong, boy, they do get it wrong! Take it with a grain of salt ;-)
Is Apple involved in this project?
No. Neither Apple, nor any Apple subsidiaries are involved in Objective Modula-2.
Is Niklaus Wirth involved in this project?
No. Neither Niklaus Wirth, nor ETH Zurich are involved in Objective Modula-2.
The Modula-2 Webring
Web sites and web pages related to the Modula-2 programming language.
List all sites | Previous site | Next site | Random site | Join this webring
