Re: Cocoa Newbie
Re: Cocoa Newbie
- Subject: Re: Cocoa Newbie
- From: Chris Gehlker <email@hidden>
- Date: Mon, 08 Oct 2001 20:05:00 -0700
On 10/8/01 4:11 PM, "Ben Mackin" <email@hidden> wrote:
>
John C. Randolph wrote:
>
> Try LISP, Forth, Python, Perl, and one or two assemblers.
>
>
Funny you say that, I am required to take an assembly class before I can
>
move on to upper divsion courses.
That's a great idea. You should enjoy it.
>
How different are C++ and Objective C? they both branch off from C,
>
correct? Why did you mention that C++ is a headache? How is objective C
>
easier to learn/implement than C++?
Here are four reasons. I don't claim it's an exhaustive list.
C++ had a goal of being fast on slow hardware. Therefore Stroustrup designed
it to be as statically linked as possible for a language with objects. With
current hardware, the overhead from dynamic linking is negligible but the
legacy of static linking makes C++ less flexible. You just can't do
categories, forwarding, delegation etc. in a language as static as C++.
C++ grew out of a mainframe tradition where you turned in your punch cards,
checked back in a few hours to hopefully find your job run, and then sat
down at a table with a printout to fix bugs. In this environment it was
important that the compiler find as many bugs as possible on each pass so
the language is statically typed. But later people noticed that the static
typing was getting in the way of expressing some fundamental notions that
were independent of type. You couldn't have a dictionary class, you had to
have an <int, string> dictionary class or a <float, string> dictionary
class. So programmers were writing the same thing over and over with
different types. The C++ response to this situation was weird. It's like you
built a wall around your house but forgot a gate. But you were so proud of
your wall that you couldn't bear to nock a section down so you added a
staircase on the inside and outside to allow you to climb over it at
considerable effort. Thus was invented "generic programming" an elaborate
way to automate writing the same thing over and over while substituting
different types. It makes the language much harder to master, it can really
bloat your code, and if you make a little mistake, it can start showing you
compile errors deep inside the Standard Template Library rather than at the
point where you made the mistake so it's a horror to debug. ObjC uses all
the type information you give it. If you find yourself fighting the type
system, you can stop using it until it's helpful again.
Memory management in C++ can be a bear. There are things called smart
pointers that help a lot but you have to come up with a policy for using
them and you and everyone else on the project have to agree on the policy.
The smart pointers and the policy are built into ObjC.
Finally C++ has no high level, UI oriented library + RAD tool for handling
common tasks like window and menu management, letting the user open files
and drawing on the screen. There are add-ons for C++ that range from the
pretty good, PowerPlant, to the awful, MFC. But AppKit is simply the best.
I like C++. I can even tolerate the template part. But I recognize that it
suffers from a legacy of decisions that, while they might have made sense at
the time, make it less than ideal for programming as it's done today.
--
Tact is the ability to describe others as they see themselves. -Abraham
Lincoln, 16th president of the U.S (1809-1865)