[R-SIG-Mac]Re: cocoa darwin and all that..

Jan de Leeuw deleeuw@stat.ucla.edu
Wed, 25 Jul 2001 10:19:48 -0700


Sure. You have enlightened me recently about quantum
statistics , so it's only fair. This may be
useful to other people as well, so I'll copy to the
r-sig-mac list.

X11 or X11R6 is the X Window system. This is client-server software to 
display
and manage desktops on networked machines. So if you
write an X client program, you can run it on one machine, and
display its windows on any other machine on the net which has the
X server program running (and which gives you permission
to display). X comes with various widget libraries that
make it easier to do graphics programming, and with a whole
bunch of client programs. Some of these client programs are
called window managers, they determine the details of how
your windows look (popup menus, scroll bars, and so on)
and move. So the Mac Finder is, among other things, a
window manager. Typically X programs run on Unix, but
there are also X servers for Windows and even for Mac OS
(classic). There are not many client programs for X11 on
MacOS, but of course you can run programs such as
Xemacs, Xdvi, Xpdf etc remotely on a Unix box and have
them display their window on your Mac running the X server.

Darwin is Apple latest version of the Unix operating system,
based on a combination of FreeBSD and the Mach kernel
from CMU. It is the core of MacOS X, but MacOS X is written
in such a way that Darwin is invisible to end users (unless
they open the Terminal application). For programmers, and
for dabblers like me, MacOS X is very attractive, because
it allows you to work under MacOS X (in the Mac like
interface), on the Unix command line (in Terminal), and
(after installing an X11 server and clients for Darwin) in
X Window. The big step ahead is that virtually all Unix
and X11 software ports to the Darwin layer of MacOS X
with almost no effort at all. And the major benefit is that
so much scientific software exists for Unix/X11. So the
only thing you need is source code, and it will usually
compile without problems. This is what I did for my X11
version of R on Darwin (which assumes there is an
X server on the local machine). I also compiled support
for gnome (a desktop system on top of X11, which in this
cases provides buttons and menus to R windows) and
for tcl/tk which allows you to write programs in R
with graphical user interfaces (again, on top of X11).

On MacOS X you can run software in many different
ways, depending on what type of software it is. Previous
Mac programs run in an emulation layer called Classic,
with is comparable to emulators such as VirtualPC. You
can run PowerPC applications in this "Mac in a Mac",
with some loss of efficiency.

There is also specially written software which uses the
Carbon libraries. Programs using Carbon can run
natively on MacOS 8 or MacOS 9, but they also run
natively on Mac OS X (i.e. they do not need the Classic
emulation layer). They have the Aqua look, i.e. the
"traffic light" buttons at the top, and the "lickable" look.
If Carbon programs run on OS X, they have advanced
virtual memory, protected memory, symmetric multiprocessing,
and so on. This means that when a Carbon program running
in OS X goes down, nothing else goes down. A Classic
program running in OS X that bombs tales Classic down
with it, but the rest keep sunning smoothly. A Classic
Program in Classic takes the whole system down, and
requires a reboot. Stefano's version of R is a Carbon
program.

So Carbon is an API (Application Programmer Interface)
that gives programmers access to a cleaned up and extended
version of the MacOS Toolbox (the Classic API) and that makes
most of the advanced services of MacOS X available. Cocoa
is another API (the latest version of NextStep for MacOS X),
with it you can write Cocao applications that only run on
MacOS X (not in Classic, not on older Macs running MacOS 8
or MacOS 9). They use even more of the Mac OS X facilities
(the multiprocessing, for instance), and they have characteristic
GUI (graphical user interface) elements that makes them
easily recognizable (in addition to the Aqua look, which they
share with Carbon applications). A Cocoa programmer could fairly easily
write a Cocoa driver for the Darwin version of R. I think that
would be the ideal version of R for OS X.

Although you did not ask, there is also Quartz, which is the
rendering engine that draws to the screen and to printers. It
replaces Quickdraw from Classic and DisplayPostscript from
Next -- it's native file format is pdf (which makes using TeX
on MacOS X a real pleasure -- TexShop is a Cocoa shell
around the teTeX system, which is living in the Darwin
layer).

Best -- Jan

Books: the Apple Developer Library

Inside OS X: System Overview
Inside OS X: Performance
Inside Cocoa: Object Oriented programming and the Objective C language
Inside Carbon: Carbon Porting Guide

PDF for these books can be downloaded from Apple,
http://developer.apple.com/techpubs/,  print-on-demand
versions can be ordered from www.fatbrain.com

OReilly
Learning Cocoa
Learning Carbon

Osborne
Feiler: MacOS X. The Complete Reference.
Morgan Kaufman
Feiler: MaxOS X Developers Guide.
Not out yet.

The number of books about Unix and X11 is infinite, for
all practical purposes.

On Wednesday, July 25, 2001, at 09:13 AM, Richard D. Gill wrote:

> dear jan
> i'm on the mac r email list but i have no idea what is darwin,
> cocoa, x11 ... can you enlighten me?
> yours
> richard
>

===
Jan de Leeuw; Professor and Chair, UCLA Department of Statistics;
US mail: 9432 Boulter Hall, Box 951554, Los Angeles, CA 90095-1554
phone (310)-825-9550;  fax (310)-206-5658;  email: deleeuw@stat.ucla.edu
homepage: http://www.stat.ucla.edu/~deleeuw
========================================================
           No matter where you go, there you are. --- Buckaroo Banzai
                    http://www.stat.ucla.edu/~deleeuw/sounds/nomatter.au
========================================================