[comp.sys.next] Procedural + Objective mixing

wiml@milton.u.washington.edu (William Lewis) (01/09/91)

In article <ci8gV1w164w@questor.wimsey.bc.ca> aberno@questor.wimsey.bc.ca (Anthony Berno) writes:
>The question is this: Is it a bad idea to "mix"
>procedurally based C code with objective-C? I have little experience
>(so far) with object oriented languages and am just starting to learn
>Objective-C. I see one of three answers here:
>
>1) Absolutely not. The machine will do horrible unpredictable things and
>crash. (Unlikely)
>2) It works as expected, but is bad program design. Debugging is more
>difficult, and it is harder to trace program execution.
>3) No problem, do it as much as you like.

   Well, the answer is certainly not #1. I don't think that it's a bad
idea program-design-wise to mix them, but that's a matter of interpretation.
(On the other hand, there are situations where you *must* mix them -- 
using shellsort() or quicksort(), say, or supplying a callback routine
for many of the DPS and soundkit routines.) Gdb treats method calls just
like function calls when you're debugging. It's probably far better to
mix your metaphors than to try to cram a program into a paradigm which
doesn't fit it ...


-- 
 wiml@milton.acs.washington.edu       Seattle, Washington   
     (William Lewis)   |  47 41' 15" N   122 42' 58" W  
"These 2 cents will cost the net thousands upon thousands of 
dollars to send everywhere. Are you sure you want to do this?"

PFKEB@SLACVM.SLAC.STANFORD.EDU (Paul Kunz) (01/10/91)

   If you have existing program that needs a NextStep GUI, then I would
freely mix your procedural code with the Objective-C code.   As an example,
we have a NextStep application in which all the GUI is Obj-C (for sure)
but the computations are all done in FORTRAN.   That is, there's
almost 12K lines of old FORTRAN behind the scenes, some of it over
20 years old.
   Some readers may snicker at using FORTRAN behind the scenes.   But
why not?  Its code we did not write, its maintained by others, it happens
to be modular, and we didn't have to modify it to use it.   And the
big plus is when you look at how people us this FORTRAN code on mainframes
compared with our GUI to the same program on the NeXT; its night and day.
Its like a completely new program

Paul Kunz
Stanford Linear Accelerator Center
NeXT Mail to: pfkeb@ebnextk.slac.stanford.edu

cox@stpstn.UUCP (Brad Cox) (01/12/91)

In article <14036@milton.u.washington.edu> wiml@milton.u.washington.edu (William Lewis) writes:
>In article <ci8gV1w164w@questor.wimsey.bc.ca> aberno@questor.wimsey.bc.ca (Anthony Berno) writes:
>>The question is this: Is it a bad idea to "mix"
>>procedurally based C code with objective-C?

The rules for mixing and matching in Objective-C are very simple...

1) Use the right tool for the job
2) If ever in doubt, refer to rule #1.

The C part of Objective-C is not there as an vestigal appendix, a throwback
to bad old ways best forgotten.

It is for doing the gate- and block-level things that chip-level objects 
are poor at.

C provides silicon fab lines; Objective-C added soldering guns.  One is a
tightly-coupled fabrication technology for building things from first
principles; the other a loosely-coupled technology for assembling
things from off-the-shelf components.
-- 

Brad Cox; cox@stepstone.com; CI$ 71230,647; 203 426 1875
The Stepstone Corporation; 75 Glen Road; Sandy Hook CT 06482