Objective-C: What Does The “.m” Extension Stand For?
I found old notes I wrote down around 2006 when I first searched for the origins of the “.m” file extension for Objective-C implementation files.
So, what does “.m” stand for ?
Back then, the Apple developer site was already vague:
The compiler recognizes Objective-C source files by the filename extension
.m
, just as it recognizes files containing only standard C syntax by filename extension.c
These days, it just mentions:
As stated earlier, the interface for a class is usually placed inside a dedicated file, often referred to as a header file, which generally has the filename extension
.h
. You write the implementation for an Objective-C class inside a source code file with the extension.m
.
The comp.lang.objective-C FAQ listing mentions:
The organisation of Objective-C source is typically similar to that of C or C++ source code, with declarations and object interfaces going into header files named with a .h extension, and definitions and object implementations going in files named with a .m (short for methods) extension.
The conversation on the cocoa-dev mailing list archive (conversation also archived on cocoabuilder.com) is the most interesting one: the .m
extension was probably first used by Brad Cox when developing the Objective-C compiler at Stepstone Corporation. Afterwards, the question was asked as part of the “Stump the Experts” session at WWDC where Steve Naroff, who wrote the original Objective-C front-end support for gcc, answered that .m
stands for messages.
In November 2003, Prachi Gauriar decided to ask Brad Cox in person who replied:
You came to the right place. But for the life of me, I can’t remember for sure. Main requirement was something that wasn’t already used. Possibly messages.
Lately, the very same question popped up on Stack Overflow and 10 years later, Stefan Plattner emailed Brad Cox again who replied:
Because
.o
and.c
were taken. Simple as that.
All in all, it seems they were indeed in a need for a single letter file extension that wasn’t already taken and chose .m
for messages.