Page 1 of 1

objective c syntax

Posted: Sun Jun 15, 2008 11:11 am
by yacahuma
Any objective c coders in the house??

I am trying to figure out what was the purpose of the objective c syntax. What are the advantages? why not use a more normal syntax(c,c++, java, php) and do something like frac->setNumerator(1)

Also there seems to be a lot of little additional characters to help the compiler(maybe)

Maybe someone with object-c experience can share some light. Thank you

// set the values
[frac setNumerator: 1];
[frac setDenominator: 3];

// combined set
[frac2 setNumerator: 1 andDenominator: 5];

Re: objective c syntax

Posted: Sun Jun 15, 2008 11:22 am
by arjan.top
it is inspired by smalltalk, I would say

Re: objective c syntax

Posted: Mon Jun 16, 2008 1:00 am
by Weirdan
yacahuma wrote: I am trying to figure out what was the purpose of the objective c syntax. What are the advantages? why not use a more normal syntax(c,c++, java, php) and do something like frac->setNumerator(1)
You have to know a bit of history to understand that. Objective C started its evolution as a superset of C (unlike C++ which started as a preprocessor to C) pretty much at the same time as C++ did. Both languages were not in common use and thus were not influencing each other. Besides, different level on which they were integrated into C made sharing the syntax harder, if not impossible (later C++ compilers appeared, but those were different times already). Other languages you mentioned appeared much later, in mid-90, thus obviosly ObjC could not borrow from them.

Objective C doesn't have to be 'better' than C++, as it's just another implementation of same ideas, on the same common base (C).

And yes, as arjan.top noted, Objective C is heavily influenced by Smalltalk.

Re: objective c syntax

Posted: Mon Jun 16, 2008 8:32 am
by yacahuma
thank you.