Re: programming in C++ ?
Re: programming in C++ ?
- Subject: Re: programming in C++ ?
- From: Jay Reynolds Freeman <email@hidden>
- Date: Thu, 31 Jan 2008 10:20:08 -0800
On the general topic of mixing Cocoa/Objective-C and C++, I might
knock on wood and report a modest success story:
I have an application -- a Scheme-programming-language interpreter
(Wraith Scheme) -- designed in the model/view/controller pattern.
The model is essentially all straight C++ -- all ".c++" files and
associated headers -- and when I use it in a standard Macintosh
application, it runs in its own thread. The view and controller are
in that case mostly Objective-C, with occasional references to things
to get the model's thread going and keep in touch with it; they use
all either ".m" or ".mm" files, with associated headers, and with
lots of Cocoa calls.
I set the application up this way because I originally got the
application going with the model running with two additional,
different, view/controller combinations: The same C++ code for the
model can run with a straight Unix-shell view/controller -- as a text-
oriented line-at-a-time process in a "Terminal" window -- or with an
"ncurses" view/controller, also running in a Terminal window. I
followed that development path to port the program to Tiger from a
much older Mac application, dating from pre-Carbon Mac-Toolbox days.
I was a newcomer to Cocoa at the time of the port, so I did it that
way in order to deal with upgrading the model separately from coming
up to speed on Cocoa. I use #ifdefs on symbols defined by compile-
time flags to control which build to create and to control how the
model communicates with its view/controller -- the Cocoa version is
built with XCode (2.4.1, on Tiger), the Unix versions with
conventional make files. There are also, of course, different source
files used for the different view/controller combinations.
This mix of languages, libraries, and build mechanisms has worked
seamlessly so far (and this is where I knocked on wood). My suite of
regression tests automatically builds and tests all of these
versions, and there have been few maintenance problems associated
with the differences between them. I suspect (another knock on wood)
that it would be straightforward to adapt the Unix versions of the
application to (heresy!) other Unix versions and other hardware
platforms.
-- Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden