233

Since I started learning Objective-C and Cocoa, I've been wondering why they have chosen the extension .m for the implementation files - was it supposed to mean something, or was it just a random letter?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kuba Suder
  • 7,587
  • 9
  • 36
  • 39
  • 16
    It's for the *em*plementation. – dreamlax Mar 16 '09 at 21:36
  • 2
    I guess this was bothering someone else, so they did a bit of research finding contradicting evidence on the meaning behind .m extension. Ultimately it stands for messages. For the full read: http://pempek.net/blog/2013/11/30/objective-c-file-extension/&utm_medium=email&utm_source=iOS%2BDev%2BWeekly – John Riselvato Dec 06 '13 at 16:17
  • `.m` files are implementation files as you said. Knowing Apple likes to prefix everything with `i` it is easy to see that **i**mplementation becomes *mplementation* without said `i`. Then they just used the first letter of mplementation for the file extension: `m`. – Daniel Oct 25 '19 at 13:57

3 Answers3

523

Today most people would refer to them as "method files", but

"The .m extension originally stood for "messages" when Objective-C was first introduced, referring to a central feature of Objective-C [...]"

(from the book "Learn Objective-C on the Mac" by Mark Dalrymple and Scott Knaster, page 9)

EDIT: To satisfy an itch I emailed Brad Cox, the inventor of Objective-C, about the question and he answered with this single line:

"Because .o and .c were taken. Simple as that."

Here's the email as visual proof:

Visual Proof

nhubbard
  • 110
  • 2
  • 11
splattne
  • 102,760
  • 52
  • 202
  • 249
10

It stands for "methods". From the comp.lang.objective-C FAQ:

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.

NSDeveloper
  • 1,630
  • 15
  • 25
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
5

.m files contain the (m)ethods. Possible reason?

baker1990
  • 139
  • 1
  • 4