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? Wny not Pascal? Why not Oberon? Why not Ada?
The primary goal of the project was to add native support for the Objective-C object model to a language of the Pascal family, or in other words, to remove the C base language from Objective-C and replace it with a language of the Pascal family, leaving the Objective-C object model intact.
Modula-2 is quite possibly the most suitable C-replacement for system level development. In any event, Modula-2 is structurally closer to C than any other language of the Pascal family.
In comparison to Pascal, Modula-2 is more strongly typed and it has cleaner syntax and more pronounced support for modular programming. Unlike Pascal, Modula-2 uses separation of interface and implementation which maps nicely to the separation of interface and implementation in Objective-C.
In comparison to Oberon, Modula-2 is unmanaged and does not have a native object model that would have had to be removed or would have caused duplication of features when adding the Objective-C object model for native Cocoa/GNUstep support. Furthermore, like Pascal, Oberon does not separate interface and implementation.
In comparison to Ada, Modula-2 is much smaller and lightweight. Since Ada does not permit any subsets, a full Ada implementation would have been required. The project would not have been able to muster the resources for such an effort.
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.
Modula-2 is a type-safe language. Research by the University of Loughborough in the United Kingdom has shown that Modula-2 source code contains on average only 1/3 the number of bugs of comparable C source code. This is a result of the strongly typed nature and clarity of the syntax of Modula-2.
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, Objective Lua and Objective Smalltalk. And of course there is Objective-C itself.
Is Objective Modula-2 based on ISO Modula-2?
Objective Modula-2 defines a set of language extensions to add native support for Cocoa, Cocoa Touch and GNUstep to any existing Modula-2 dialect without conflicts or inconsistencies. It is therefore possible to implemen the Objective Modula-2 language extensions in an ISO Modula-2 compliant compiler.
However, the Objective Modula-2 reference implementation is based on the Modula-2 R10 dialect, a modern revision of Niklaus Wirth's fourth edition of Programming in Modula-2.
Why the omissions of classic 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. For the goals of the Objective Modula-2 project, Modula-2 R10 is considered to be the most suitable dialect.
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 compiler is based on the Modula-2 R10 reference compiler and its completion is therefore dependent on the completion of the Modula-2 R10 reference compiler which is at present expected for the end of 2010.
However, either project is entirely volunteer based and it is therefore difficult to set and meet deadlines. With a bit of luck we may have a working compiler generating ObjC source code around the end of 2010 or early 2011. The LLVM code generator will follow.
What are the dependencies for the the Objective Modula-2 compiler?
- a C compiler (C99)
- the C libraries stdlib, stdio, stdint, stdbool and errno
What are the dependencies for the generated code?
- an Objective-C compiler (initially) or LLVM
- the Objective-C runtime
Which C99 features does the Objective Modula-2 compiler depend on?
//
comments- additional integer types in
stdint.h
- boolean type in
stdbool.h
- compound literals
- variable length arrays
- variadic macros
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?
The Objective Modula-2 compiler implements a superset of Modula-2 R10 and it can therefore be used for development in the Modula-2 R10 dialect. For developing in the PIM and ISO dialects, we recommend 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?
Yes, eventually the Objective Modula-2 compiler will be usable together with Cocotron on Windows.
Which C compilers can be used to build the compiler on Windows?
The compiler sources should compile on Windows with any of the following freely available C compilers:
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).
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.
But did you ask Niklaus Wirth if it is ok to use the Modula-2 name?
Yes. We have received email from Prof. Wirth in which he stated that he welcomes others to use his languages and develop them further. He also expressed gratitude for keeping the Modula-2 name alive.
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