In Objective C you have the concept of sending messages to other objects, and, well this is very similar to method calling in languages like C# and Java.

But what exactly are the subtle differences? How should I think of messaging when thinking about my code?

Note: Just a bit of background here, I'm a C#/Java developer trying to understand some concepts about Objective C.

  • 2
    Since they're all different languages, the differences aren't subtle. They're different languages. "when thinking about my code"? What code? When thinking about Java or C#, you don't think about messages. You think about methods. Can you clarify how unrelated languages with unrelated concepts can have "subtle" differences?
    – S.Lott
    Feb 11, 2011 at 11:49
  • 1
    Please ask you question at stackoverflow.com Feb 11, 2011 at 12:13
  • 1
    Should this question really be on StackOverflow ? It's a question about programming concepts not a problem about some code I've got. Maybe I'm wrong, I dunno - the boundaries are blurring...
    – Vidar
    Feb 11, 2011 at 15:22
  • 1
    @Vidar, the question is not subjective. You're looking for a textbook definition. Programmers is more for opinions, experience, and subjective questions. Feb 11, 2011 at 15:31
  • 1
    OK - is there a way to get the moderator to move this question to StackOverflow?
    – Vidar
    Feb 11, 2011 at 15:50

5 Answers 5


A message is the name of a selector, and the parameters for that selector.

A selector is a symbol.

A method is a piece of code in a class identified by a selector.

In other words, [foo bar: baz] says "send the message called @selector(bar:) with parameter baz to object foo. You could send that message to many different objects.

In contrast, the method bar: for a Foo might look like

-(int)bar:(int)n {
  return n + 1;

but for a FooTwo might look like

-(int)bar:(int)n {
  return n + 2;

(I hope I have the syntax right; it's been a while since I last touched Objective-C.)

When you send the message, the Objective-C kernel dispatches the message to foo which decides whether it understands the message. It decides this based on whether it can find a method identified by that selector.

Two methods with the same name, and one message.

It's also possible for an object to simply forward a particular message (or set of messages) to another object for processing. In this case, you send a message to this proxy object, which has no methods to match that message, and the proxy forwards the message to its wrapped object.

  • so... a message is when you call a dispinterface(a.invoke selector, args) and a method is when you call an interface(a.methodName)? Wouldn't that make java, JavaScript, all dynamic languages have messages because everything happens through dual interface rather than direct jumps and offset into vtable jumps)?
    – Dmytro
    Mar 19, 2018 at 21:45

From a purely theoretical viewpoint, there's no difference between the two at all -- there have been a number of formal proofs showing that the two are completely equivalent, and either can be implemented entirely in terms of the other.

From a slightly less theoretical viewpoint, there is one possible difference: in a typical implementation, the virtual function table is statically allocated and the content of each vtable is fixed at compile time. Message lookup, by contrast, is typically done with some sort of map-like object, which is typically dynamic, meaning you can modify it at runtime. This makes it relatively easy to add a new response to a message in an existing class. Unfortunately, in most cases this remains mostly theoretical. First, you're basically dealing with self-modifying code, which most people decided was a pretty bad idea a long time ago. Second, to make it very meaningful, you pretty much need to be able to compile new code into the existing class to respond to the new message you support. Without that, about all you gain is the ability to dynamically add a new name for an existing method.

As implied by the end of the previous paragraph, from a truly practical viewpoint, there's very little difference between the two at all. They're simply two (very slightly) different ways of supporting late binding. Although message-based lookup is generally a bit slower, it would be pretty unusual for the difference to be truly significant. For most practical purposes, they're just two different ways of accomplishing the same thing.

  • 3
    Do you have references showing the proofs? I'd like to take a look. There's a vast difference between Java's method invocation and Smalltalk's message sending, not just because of the late binding, but also because of the decoupling of sender and receiver: you can't tell whether the receiver of a message processes it, or forwards the message on, for instance. Feb 12, 2011 at 0:30
  • @FrankShearar: Sorry, but no. The proofs I saw were printed, and long ago when OOP and methods of implementing it were new enough that proofs about such things were interesting to academics. Feb 26, 2020 at 15:51

In Objective-C, messages are late-bound. That is they are resolved at runtime. C# supports a similar construct through the Dynamic keyword which declares an object as being late-bound as well.


Usually method calls are resolved at compile time (unless you use reflection in Java), while messages in Objective C are dispatched at run time.

  • 2
    If method calls are resolved are compile time, you aren't using OOP, you're using syntactic sugar for overloaded functions taking a struct as first parameter. Late bindung is an essential part of polymorphism and therefore of OOP.
    – user7043
    Feb 11, 2011 at 11:42
  • 2
    Yes. But still you can only code a method call against something (in Java) that is well known at compile time. Calling MyObject.foo() will give an error if MyObject or MyInterface has no method foo() defined. ObjC will allow to send you a message 'foo' to object MyObject - and if MyObject has no 'foo', this will bomb at run time.
    – Heiko Rupp
    Feb 11, 2011 at 11:47
  • I thought Objective C was a compiled language?
    – Vidar
    Feb 11, 2011 at 11:47
  • 1
    That's unrealted to early/late binding (dynamic typing vs. structural typig - in your example, the method calls are checked at compiletime but not necessarily dispatched). @Vidar: It is, but it adds magic for dynamic features. You can also compile Python.
    – user7043
    Feb 11, 2011 at 11:53
  • @Vidar: It's not an issue of compiled vs. interpreted, but rather static vs. dynamic. In static OOP languages like Java, the compiler checks to make sure that a class defines a method during the compilation phase. In a dynamically-typed language like Objective-C, messages are passed at runtime.
    – mipadi
    Feb 11, 2011 at 14:13

Messages are either handled by the kernel or by the language itself (for ObjC for example, there is a very small assembly code that does it).

In the linux kernel for example, messages are done with system calls/function: you can find about them if you search about unix system programming.

The core difference between a method call and a message is this:

  • a method call only happens in your code: in ASM it's translated by a PUSH of the passed arguments.

  • a kernel message is mostly something sent to the kernel which is tracked and send back to a certain processes. I may mistake them for pipes, but whatever: know there already is a mechanisms that allows you to run several programs at the same time and let communicate at the same time. Of course, don't hope that this will work the same way on windows or other OS.

  • This isn't "message passing" as it applies to programming languages.
    – mipadi
    Feb 11, 2011 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.