Re: why Obj-C
Re: why Obj-C
- Subject: Re: why Obj-C
- From: Andy Lee <email@hidden>
- Date: Thu, 4 Apr 2002 23:46:21 -0500
At 1:52 PM +1000 4/5/02, Matthew Johnson wrote:
This is not a troll or anything so please don't flame me.
Sure, sure... ;)
Why did apple choose Obj-C over something people know and understand
like C++? or even C.
Technical merits of the language aside, Apple chose NeXT. NeXT had
already chosen Objective-C.
Why are we forced to learn yet another syntax that is very alien to C++/Java.
First, you aren't forced. As you've already discovered, you can use
Carbon. Or the Java Cocoa API, for that matter.
Second, Objective-C syntax shouldn't be alien to a Java programmer.
In some fundamental ways it is more like Java than like C++:
* Single-inheritance only.
* "self" is really "self", by which I mean the method that gets
invoked for an object depends on the object's actual class at
runtime, unlike C++ where the method invoked depends on the
variable's declared type.
* Protocols.
* What's called "introspection" in Java (the ability to query a class
about its members); I forget what it's called in Objective-C.
Third, despite the differences from C++, Objective-C shouldn't be
*that* hard for a C++ programmer to pick up. It is basically C with
a little extra syntax to support objects.
Fourth, don't you like learning?
I absolutly love the interface builder its
just excellent. But then you have to write the meat of the program
and its been not a very pleasent experience for a
newbie to mac but I experienced C/C++ dude.
Interface Builder and Cocoa *could not* have been developed around
C++. IB relies heavily on Objective-C's introspection and ability to
send any message to any object.
Writing for the Mac for the first time (I am a solaris programmer
(C/C++)) I thought I would try cocoa to write a one
off application for my company. Personally I have found this was a
very large mistake. If I every have to write another
one off Mac application I think it will be in Carbon.
As Stuart Smiley might say: "That's... okay." There can be valid
reasons to go either way. You should use what suits you, as long as
your reasons are intelligent and well-informed.
Can someone tell me what is it about Obj-C that makes the syntax for
class's and methods have to look like it does? why
"[" instead of "(".
The message-sending syntax comes from Smalltalk, which was a mature
language before C++, Java, *or* the Mac. Do you even understand
Objective-C's message-sending syntax? Parens would be a horrible
choice, because they already have meaning in C.
BTW, Objective-C adopts another nice feature of Smalltalk syntax,
which is using identifiers to separate arguments:
[myObject doSomethingWithThis:arg1 that:arg2 theOther:arg3];
I find this makes code a lot more readable, but YMMV.
I will never understand the IT worlds obsession with reinventing the wheel.
I know what you mean. If Bell Labs had just used Smalltalk, which
was already a well-thought-out object-oriented language, they
wouldn't have had to invent C++...
I wish people would understand that the power of Java is not Java
syntax but its the collection of Standard classes
Setting aside the question "What does this have to do with Cocoa" --
who *doesn't* understand this? Cocoa aficionados would agree in a
heartbeat and point to the Cocoa libraries as a prime example.
As an aside -- Java's libraries do have a lot of merit, but what
surprised me was how weak AWT was as a first stab at a UI framework,
given that NEXTSTEP had been around plenty long enough to serve as an
example of how to do it well.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >why Obj-C (From: Matthew Johnson <email@hidden>) |