

What is Objective-C programming language - acronmace

What is Objective -C and how is it different from other languagers like C,C++and java and what are its main uses.
======
MichaelCrawford
It is Smalltalk bolted onto C. Instead of garbage collection one uses
reference counting.

While it does have exceptions, they don't unwind the stack as do C++
exceptions. They are commonly used only for fatal errors; I use C++ exceptions
for all kinds of things that aren't really errors.

In C++, one calls a member function by dereferencing a pointer to that
function from a table of such pointers.

In Objective-C, one calls a "method" by "sending it a message". That message
is a small snippet of text. To dispatch to the actual function that implements
the method, the Objective-C runtime (libobjc.dylib on OS X and iOS) must match
the name of the method that one has targeted, to the name of the method whose
implementation is actually just a regular C function.

Of course that would be very slow, but the Mach-O executable format is
optimized for this case. Linux ELF and Windows COFF are not. So while in
principle one can use Objective-C on Linux and Windows, the same code will run
slower than on an equivalent Mac OS X box or iDevice.

Your code can send messages to methods that are not defined at compile time.
If you actually call them you will terminate, but you can provide the
implementation later.

I think Java can do that as well, but C and C++ do not have first-class
language support for such a thing.

It's most-commonly used for Mac OS X Cocoa and iOS (iPhone, iPad and iPod
Touch) Cocoa Touch GUI applications, but one can use it for GNUStep on *NIX as
well as Cocotron on Windows.

~~~
acronmace
Does it only run on Mac or it could run on windows.

~~~
MichaelCrawford
Objective-C can be compiled and run on Windows, Linux, *BSD (ie. FreeBSD,
OpenBSD and NetBSD), Solaris and Mac OS X.

You can run it on iOS Devices. You can't build it but must cross-compile on
Mac OS X.

There are two compilers - GCC and clang/llvm. Apple's Xcode comes with
clang/llvm, for the others one uses gcc.

There are three main things you need: the compiler, the runtime and the
libraries.

~~~
acronmace
Well thanks for helping me.

~~~
MichaelCrawford
I'll send you my bill in the mail. :-D

If you're on windows, use Cocotron.

~~~
acronmace
haha sure... Is there any way i could develop ios application in windows just
for learning purpose without hackintosh my pc.

~~~
MichaelCrawford
You'll need the iOS SDK. That can only be _installed_ on a Mac, but once
installed, I understand you can copy it over to Windows.

However I've never actually tried doing so.

