Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / January 2006



Tip: Looking for answers? Try searching our database.

Coming over from the dark side...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nony Buz - 26 Jan 2006 02:58 GMT
I have been a professional programmer for 10 years now.  Most of
those years I have developed Microsoft Windows applications in C++
using MFC.  In the last three years I have been working with
Microsoft .NET more and more.

Today I am designing a client/server application for a business I
am going to start.  There are simply too many issues, which I
don't want to get into, which point to OSX as the correct platform
in which to develop this application and business.

The one problem I have leaving the Windows platform is .NET.  I
have really come to appreciate what Microsoft has done with .NET.
It is as fast as C/C++ without many of the risks and overhead.
.NET also provides a very powerful framework to do a lot of things
very quickly and easily, such as Remoting.

This evening I found documentation on Distributed Objects in
Objective-C.  It started to sound like Objective-C is my answer;
especially considering memory management is built in, like .NET
and Java.  Then I found some posting, old 2001~2003, saying that
the Objective-C code is a lot slower then carbon.

Can anyone point me to any documentation that does a good job
comparing the world I know, Microsoft Windows development
languages/frameworks to those on the Apple?
Eric Albert - 26 Jan 2006 04:45 GMT
> This evening I found documentation on Distributed Objects in
> Objective-C.  It started to sound like Objective-C is my answer;
> especially considering memory management is built in, like .NET
> and Java.  Then I found some posting, old 2001~2003, saying that
> the Objective-C code is a lot slower then carbon.

Not so.  An Objective-C method call is very slightly slower than a
Carbon (C) function call, but if method call overhead is the performance
bottleneck in your application, well, you either have the best optimized
code in the world or your app isn't doing anything interesting.  That,
and if you do need to eke every single last instruction out of code
that's calling Objective-C methods, there are ways to make method calls
faster.  But you should never have to do this.  Lots of very fast
applications have been written in Objective-C.

However, one thing you've said isn't quite right.  Memory management
isn't built into Objective-C today.  It's not terribly hard to follow
the Obj-C paradigm for managing memory, but memory isn't
garbage-collected in the way you're used to with Java or .NET.

-Eric

Signature

Eric Albert         ejalbert@cs.stanford.edu
http://outofcheese.org/

Nony Buz - 26 Jan 2006 05:37 GMT
> However, one thing you've said isn't quite right.  Memory management
> isn't built into Objective-C today.  It's not terribly hard to follow
> the Obj-C paradigm for managing memory, but memory isn't
> garbage-collected in the way you're used to with Java or .NET.

Eric,

I can see your argument about Obj-C being a speedy language.  But
the fact that the language is not garbage collected concerns me.
The garbage collection is the feature I like the best and I
leverage the most in .NET development, which saves me a lot of
time in both design and development.  

Are there any sites that discuss the different
language/framework/tools available on OSX to develop serious
client server applications?

At this point in time, I am not ruling out any language except for
Java, been there, done that and not a language I want to develop
UI's in!  I am very interested in the OSX, but I am trying to make
heads and tails of all the different languages/frameworks/tools to
develop applications on OSX.  Is there somewhere I can go which
will explain to me the difference and relationship of the
following: xcode, Objective-C, Objective-C++, Cocoa, Carbon.

So far this is my take on them all:

Xcode: an IDE, similar to Microsoft VisualStudio
Objective-C: a language that make life easier, but does not have
garbage collection
Objective-C++: a more OO version of the former
Cocoa: a framework which is built on top of Objective-C/C++
Carbon: Either Apple's C SDK similar to Micorsoft's Win32 SDK or a
OO Framework along the lines of Microsoft's MFC

Nona
David Phillip Oster - 26 Jan 2006 05:54 GMT
> Xcode: an IDE, similar to Microsoft VisualStudio
Yes.
> Objective-C: a language that make life easier, but does not have
> garbage collection
Instead it uses reference counting and autorelease-pools.

> Objective-C++: a more OO version of the former
Objective-C extensions to C bolted on to C++.

> Cocoa: a framework which is built on top of Objective-C/C++
Yes

> Carbon: Either Apple's C SDK similar to Micorsoft's Win32 SDK or a
> OO Framework along the lines of Microsoft's MFC
The first one.
David Phillip Oster - 26 Jan 2006 06:01 GMT
> I can see your argument about Obj-C being a speedy language.  But
> the fact that the language is not garbage collected concerns me.
> The garbage collection is the feature I like the best and I
> leverage the most in .NET development, which saves me a lot of
> time in both design and development.  

You might consider <http://www.gnustep.org/>, a portable implementation
of Objective-C with garbage collection, if you want it. I don't know if
it is good for anything in practice.
Uli Kusterer - 26 Jan 2006 07:20 GMT
> You might consider <http://www.gnustep.org/>, a portable implementation
> of Objective-C with garbage collection, if you want it.

Err... that's not quite right: GNUstep is an open-source ("free as in
speech", as the catch-phrase goes) clone of Cocoa. Yes, it's based on
the official version of GCC and not on Apple's hacked one, and yes,
there are garbage collection extensions for it, but GNUstep is not "a
portable implementation of ObjC".

> I don't know if it is good for anything in practice.

There are people who're using the Foundation part of GNUstep
commercially, as far as I've heard. That said, they have a great
continuity, though the people there seem to be a bit too optimistic,
IMHO, about what constitutes a finished release for real-world usage.
There have been a couple of sweeping changes that broke compilation (or
compatibility with Cocoa) for half the platforms and the likes.

Bottom line: Don't take anyone's word on how viable GNUstep is for
real-life work. Evaluate it yourself. It still has some rather glaring
holes, but depending on what you're trying to do, you may not care about
those.

Oh, and one more thing: GNUstep is rather large and based on X11. If you
plan using it on a machine in your office, that's okay, but opinions are
divided on whether customers will be able to install it on local
machines without being Unix gurus...

Just clarifying,
-- Uli
http://www.zathras.de
Uli Kusterer - 26 Jan 2006 12:19 GMT
> That said, they have a great continuity,

Ummm... I meant "community" ... :-/

-- Uli
http://www.zathras.de
David Phillip Oster - 26 Jan 2006 17:11 GMT
> > You might consider <http://www.gnustep.org/>, a portable implementation
> > of Objective-C with garbage collection, if you want it.
[quoted text clipped - 4 lines]
> there are garbage collection extensions for it, but GNUstep is not "a
> portable implementation of ObjC".

Thank you. Yes, you are quite right. gnustep is an open source
implementation of a framework similar to Cocoa. Objective-C is a
language, supported by the GNU compiler.

Since the original poster is familiar with MFC, he might consider
dividing his program into two sections: a User Interface done in
Objective-C++, where his U.I. objects hold pointers to C++ objects that
do the real work. This 'engine' could be basically C++, using
objective-C constructs only as necessary to call back into the user
interface layer of the system. And using the <http://boost.org/> or
std::tr1:: smart pointer classes scoped_ptr, auto_ptr, shared_ptr, and
weak_ptr for memory management in places where a strict discipline of
single-ownership isn't sufficient.

scoped_ptr makes sure that objects allocated on the heap are cleaned up
then the only reference to them goes out of scope.

auto_ptr lets functions return objects allocated on the heap, but
guarantees that those objects will get disposed if the return value
isn't assigned to anything.

shared_ptr manages reference counts for objects that might be owned
equally by a number of different containers, where it disposes itself
when the last one goes away.

weak_ptr manages references to shared objects where you don't want a
share in the ownership, you just want to be informed if you are holding
a weak pointer and the underlying object goes away.  For example, in a
word processor with an asynchronous spelling checker that is working on
paragraphs of a document. Close the document, the paragraphs, owned by
the document go away, even though the spelling checker thread is still
running. The spelling checker discovers its got a dead weak pointer, and
stops.

That way he could take advantage of C++'s RIRA idiom (Resource
Initialization is Resource Allocation (where objects are allocated in
initialized in constructors, which throw on failure)), and C++'s
guarantee that destructors get executed when you leave a block even if
you leave because something throws an exception.

That way he could take advantage of C++'s standard library which
separates containers from algorithms using iterators to glue the two
together. The Boost Graph library has some very sophisticated graph
algorithms, that can work on many different kinds of representations

I used to be a fan of garbage collection, but not any more. It is kind
of like getting to the moon by climbing a tree: you make a lot of good
early progress, but pretty soon you have to go back to your funding
agency and ask for a bigger tree. Yes, during the early stages of the
project, you don't have to worry about when objects are deallocated, but
when the times comes that you _do_ have to worry, because your program
is a success, for example, the problems are buried in layers of
asynchrony and nondeterminism. Much better to think about the issues up
front and get them right while the program is still small. Much better
to train yourself to write correct programs, than it is to use a system
that is forgiving of your mistakes until it is extremely expensive to
fix them.
Uli Kusterer - 26 Jan 2006 07:30 GMT
> Xcode: an IDE, similar to Microsoft VisualStudio

Yup.

> Objective-C: a language that make life easier, but does not have
> garbage collection

Well, it uses reference counting, which you could call a precursor to
automatic garbage collecting (IIRC there are actually simple automatic
garbage collectors who use reference counts internally). The rules are
pretty straightforward, but you still need to understand memory
management so it'll work.

> Objective-C++: a more OO version of the former

Nope. Objective C++ is a variant of Objective C based on C++ instead of
C. Since ObjC is much closer to Smalltalk than C++, one could argue that
ObjC is by design already "more OO".

The point of ObjC++ is not more OO, but rather it allows you to mix ObjC
and C++ code on a per-statement basis in the same file. This is very
handy if you have a portable core written in C++ and want to use Cocoa
to put a GUI around it (and if you want a GUI on a Mac, you want to use
Cocoa).

> Cocoa: a framework which is built on top of Objective-C/C++

Pretty much *the* framework. It's the closest ObjC has to a "standard
library".

> Carbon: Either Apple's C SDK similar to Micorsoft's Win32 SDK or a
> OO Framework along the lines of Microsoft's MFC

It's a C API like Win32. It's based off of the pre-MacOS X APIs and is
mostly used these days for very low-level stuff, and was used by many
companies to port their "Classic MacOS" (i.e. 9.x and earlier)
applications to OS X. These days most of it is C code trying to emulate
OO APIs with a structures-and-functions approach. It uses fully manual
memory management (though it also has reference counting in some areas,
but no autorelease pools or exceptions).

It's a handy tool to have under your belt to do unusual things, but I
wouldn't develop an entire GUI application with it anymore.

HTH,
-- Uli
http://www.zathras.de
Nony Buz - 26 Jan 2006 11:57 GMT
>> Xcode: an IDE, similar to Microsoft VisualStudio
>
[quoted text clipped - 26 lines]
> but I wouldn't develop an entire GUI application with it
> anymore.

So it sounds like if I am going to start with no code base, that I
simply need to develop in Objective-C and be done with it.  If I
need to do my own custom DB, then I might write that in Carbon,
but for the most part all aspects should be in Objective-C.  Would
any disagree with this statement?  If so, why?
Gregory Weston - 26 Jan 2006 18:10 GMT
> So it sounds like if I am going to start with no code base, that I
> simply need to develop in Objective-C and be done with it.  If I
> need to do my own custom DB, then I might write that in Carbon,
> but for the most part all aspects should be in Objective-C.  Would
> any disagree with this statement?  If so, why?

If you have an existing ANSI C corpus, you can leverage that. If it's
clean, it should build with little or no trouble.

G

Signature

"Congurutulation!!!" - The subject line on some spam I received last night.
I have no idea what it means, but it's such a cool "word" (by which I mean
pronouncable sequence of letters) regardless.

Patrick Machielse - 26 Jan 2006 20:46 GMT
> So it sounds like if I am going to start with no code base, that I
> simply need to develop in Objective-C and be done with it.  If I
> need to do my own custom DB, then I might write that in Carbon,
> but for the most part all aspects should be in Objective-C.

Just forget about Carbon! (Some Carbon functions are handy, but you can
always call them directly from within your Cocoa/Objective-C code if you
need them. Remember: any valid C-code is also valid Objective-C code).
If you are a 1-man outfit you'll be much more productive with Cocoa.
(for custom DB, see if the Cocoa CoreData framework suits your needs).

Cocoa is easier to develop, has clean object-orientation, and is
favoured by Apple. New stuff is added to Cocoa first.

patrick
David C. Stone - 27 Jan 2006 12:41 GMT
> > So it sounds like if I am going to start with no code base, that I
> > simply need to develop in Objective-C and be done with it.  If I
[quoted text clipped - 9 lines]
> Cocoa is easier to develop, has clean object-orientation, and is
> favoured by Apple. New stuff is added to Cocoa first.

I finally managed to get my hands on a box running OS X (Tiger).  What's
a good starting point on Cocoa for someone coming from Classic Toolbox,
C, and C with object extensions?  (The latter being the extensions to
C in Think C)
Patrick Machielse - 27 Jan 2006 15:00 GMT
> I finally managed to get my hands on a box running OS X (Tiger).  What's
> a good starting point on Cocoa for someone coming from Classic Toolbox,
> C, and C with object extensions?  (The latter being the extensions to
> C in Think C)

The standard answer is Aaron Hillegass' "Cocoa Programming for Mac OS
X", Second Edition. A well written introduction which also demonstrates
the strenghts of Cocoa very well. Additionally, you will want to read
Apple's text on Objective-C:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/in
dex.html>

Not in print, alas.

patrick
Gregory Weston - 26 Jan 2006 12:04 GMT
> So far this is my take on them all:
>
> Xcode: an IDE, similar to Microsoft VisualStudio
> Objective-C: a language that make life easier, but does not have
> garbage collection

Objective-C: Standard C with a thin layer on top of it to support OO. GC
is not part of the language, but is also not denied by the language. It
is available from some libraries.

> Objective-C++: a more OO version of the former

C++ with that same layer to support Objective-C style objects and
message sending. I'd actually say that Obj-C is more OO than C++ while
also noting that C++ has some interesting features that have nothing at
all to do with object orientation.

> Cocoa: a framework which is built on top of Objective-C/C++

A framework written in Objective-C. It does have a memory management
model that's much simpler than the fully manual process typically used
by to C programmers. It's not full auto GC but for mainstream
development it's really not functionally different either. With the
current memory management model, you can readily find non-trivial
programs that don't contain any explicit memory management commands.
There are some indications that a full auto GC implementation will be
available in a near-future release.

> Carbon: Either Apple's C SDK similar to Micorsoft's Win32 SDK or a
> OO Framework along the lines of Microsoft's MFC

Carbon is the name for the API descended from the original 1984
Macintosh "Toolbox." It's procedural, but most of it was designed with
an OO mindset. Memory management is fully manual.

Signature

"Congurutulation!!!" - The subject line on some spam I received last night.
I have no idea what it means, but it's such a cool "word" (by which I mean
pronouncable sequence of letters) regardless.

Tom Harrington - 26 Jan 2006 17:48 GMT
> I can see your argument about Obj-C being a speedy language.  But
> the fact that the language is not garbage collected concerns me.
> The garbage collection is the feature I like the best and I
> leverage the most in .NET development, which saves me a lot of
> time in both design and development.  

I'd suggest you read up at least a little on Obj-C's retain/release
system of memory management, and its use of reference counts.  It's true
there's no automatic gc, but on the other hand that doesn't mean you're
stuck with malloc/free to keep track of things.

Signature

Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0:  Delocalize, Repair Permissions, lots more.
See http://www.atomicbird.com/

David Phillip Oster - 26 Jan 2006 05:37 GMT
> I have been a professional programmer for 10 years now.  Most of
> those years I have developed Microsoft Windows applications in C++
[quoted text clipped - 21 lines]
> comparing the world I know, Microsoft Windows development
> languages/frameworks to those on the Apple?

Porting to Mac OS X from Windows Win32 API

http://developer.apple.com/documentation/Porting/Conceptual/win32porting/win32po
rting.html


Introduction to Porting UNIX/Linux Applications to Mac OS X

http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/

Also, Mac applications have support for being SOAP or XMLRPC clients:
http://developer.apple.com/documentation/AppleScript/Conceptual/soapXMLRPC/

If you want garbage collection, there is Java, but I'd advise you to learn
and use Cocoa instead.
Robert - 26 Jan 2006 18:25 GMT
A recent Dr. Dobb's Journal (#380, Jan 2006, pg 62) has an article
"Cocoa Memory Management", which seems to cover all the details.

http://www.ddj.com/documents/s=9938/ddj0601k/0601k.html
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.