home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Information / beginning-mac-programming.txt < prev    next >
Internet Message Format  |  1994-03-23  |  16KB

  1. Date: Thu, 04 Jan 90 08:56:05 EST
  2. From: KESLER%OUACCVMA.BITNET@cornellc.cit.cornell.edu
  3. Subject: SUMMARY: Intro Material for Mac Resources & Programming
  4.  
  5. Date: 4 January 1990, 08:43:49 EST
  6. >From: KESLER   at OUACCVMA
  7. To:   INFO-MAC at SUMEX-AIM.STANFORD.EDU
  8.  
  9. Dear Moderators,
  10.  
  11. I'm not sure whether I should have sent this as mail or not, but here goes.
  12. The following article is an edited collection of information that I
  13. received in answer to my request for details regarding some beginning level
  14. info on Macintosh Resources and Programming.  At the end of the summary
  15. is a *reading list*, of sorts, for those who want to delve deeper.
  16. I received a number of requests for this summary so I believe there may be
  17. many more out there who could use the info.  I suggest, because of its
  18. length, that you put it in the archives somewhere instead of inserting it
  19. into an issue of the digest.  The article is just in standard ASCII.
  20.  
  21.  
  22. ----------------------------------------------------
  23. SUMMARY:  MACINTOSH PROGRAMMING AND RESOURCE PRIMERS
  24. ----------------------------------------------------
  25.  
  26. I want to thank all of you who sent replies to my questions
  27. about Introductory materials for Macintosh programing and
  28. resources.  What follows is a spruced up version of what I
  29. received; something between a summary and a straight
  30. anthology of replies.  Forgive me if I mis-edited or deleted some
  31. information you sent to me.  It's DANGEROUS to let the novice in
  32. the group do the summary, but someone has to stand up for the
  33. little people!
  34.  
  35. The impression I got from these replies is that there is stuff
  36. out there for everyone -- from those who want (like me) to
  37. dabble, and those who want to do this sort of thing
  38. professionally, and everyone in between.  I have added a reading
  39. list to the end of this summary for those who requested it.
  40.  
  41.  
  42. GREETINGS NETLANDERS!
  43.  
  44. My curiosity has gotten the best of me and, like an increasing
  45. number of you, I want to do more than just *use* applications
  46. on my MAC -- I want to take them apart, make changes, and
  47. maybe even write a few myself!  What I need is some sort of
  48. primer or introduction to a lot of the terminology that I see
  49. posted here.  Where does someone familiar with programing in
  50. the IBM world begin a trek into MacLand?  Here are a few
  51. questions for starters:
  52.  
  53. 1) WHAT ARE *RESOURCES* IN MACINTOSH TERMINOLOGY?  WHAT DO
  54.    THEY DO?  HOW ARE THEY USED AND MANIPULATED?
  55.  
  56. 2) In reference to many postings to the archives I see the
  57.    acronym MPW quite a bit.  I know it has something to do with
  58.    programing and languages (is it a language?) but I'm not sure.
  59.  
  60. 3) There are many references to a utility program called ResEdit
  61.    and other similar programs.  Where can I get this program?
  62.    How much does it cost?  Who sells it?
  63.  
  64. 4) In short, where is a good place to begin learning how it all
  65.    works? I'm especially interested in introductory or beginning
  66.    materials.
  67.  
  68. --------------------------
  69. RESOURCES
  70. --------------------------
  71.  
  72. you have really opened a can of worms for yourself.
  73.  
  74. Resources:  Everything on the Macintosh is a resource.  Actually,
  75. that isn't entirely true, but close enough.  Programs consist of
  76. CODE resources that load WIND resources and open windows.
  77. They use ALRT & DLOG resources, including DITL resources to
  78. create alert boxes, and dialogue boxes.  The program is
  79. identified to the user with an ICN# resource.
  80.  
  81. ***
  82.  
  83. All Mac files have two parts: a "data fork", which contains data
  84. whose format is determined by the application, and a resource
  85. fork, which contains stuff whose format is determined by the
  86. Mac OS. It can also contain special resources whose format is
  87. determined by the application as well.
  88.  
  89. The resource for can be viewed as a tree-structured collection
  90. of data. This includes things like CODE (executable programs),
  91. WDEFs (window definitions), CDEFs (control definitions), FONTs,
  92. and so on.
  93.  
  94. ***
  95.  
  96. Every Macintosh file has a "Data fork" and a "Resource Fork".
  97. The data fork is just like a unix file, a sequence of characters.
  98. The resource fork is a random access data base.  Each resource
  99. is identified by a 32 bit type and a 32 bit id number.  The
  100. resource itself contains an arbitrary piece of data.  For example
  101. a character string.  Many resource types have a special meaning.
  102. For example a 'FONT' resource contains a font.  Most aspects of
  103. the Mac user interface are defined in resources, that can be
  104. edited with ResEdit.  For example, fonts, menus, window
  105. definitions, controls, dialogue icons and lots more.
  106.  
  107. Several resource files can be open at the same time.  When a
  108. program requests a resource it is found by searching all open
  109. resource files.  The order is normally
  110.  
  111. (1) The current document's resource file.
  112. (2) The current application's resource file.  (fork).
  113. (3) The system's resource fork. (File).
  114.  
  115. Hence a resource in the system file is always available, unless
  116. another resource of the same type and id number is stored in the
  117. application or document.
  118.  
  119. ***
  120.  
  121. Resources are a form of virtual memory understood well enough
  122. by most programmers for it to be successful, but misunderstood
  123. enough to convince analysts and MIS managers that the Mac
  124. doesn't have any ability to do the things virtual memory OS's can
  125. do.  Every Mac file can have a data fork and a resource fork.  A
  126. resource fork is just like a data fork except that part of it
  127. (called the resource map) is meant to be handled only by the
  128. resource manager (part of the OS).  Also, programmer is
  129. supposed to only use the resource manager rather than the file
  130. manager to access the resource fork of a file.  You use the File
  131. Manager to access the data fork of a file.
  132.  
  133. Resources are almost everything on the Macintosh except the
  134. data found in in your data files (documents).  Resources range
  135. >From being executable code, templates for data structures or
  136. data for other things like strings.  Executable code is actually
  137. split up into two or more CODE resources called "segments".
  138. Things like code for window definitions (WDEF) are also code
  139. resources but aren't called CODE because they're just a bunch of
  140. procedures.  There's only one set of procedures for all
  141. applications to use for drawing a window, it's title bar, close
  142. box and zoom box for all the "standard" window types because
  143. your System file has a standard WDEF resource.  Applications
  144. that want to use funny windows or people who want to write
  145. INITs that make Mac windows look like NeXT windows can
  146. simply patch the standard WDEF resource.  Some resources
  147. describe data structures and initial values for those structures,
  148. as in the case of DLOGs (dialog box window template) and DITLs
  149. (dialog item lists - buttons and their locations etc).  STR
  150. resources are an easy way to store strings that you use
  151.  
  152. often, and since they're resources, a French version of your
  153. program could be made simply by modifying the string resources
  154. and without recompiling your application.  Resources can be
  155. purged from memory (by the Memory Manager) when they're not
  156. being used.  Other resources are PICT (MacDraw picture
  157. definitions), ICON and MBAR (menu bar defs). System resources
  158. are shareable transparently when you use the resource
  159. manager - when you ask for ICON ID=128 and if your app doesn't
  160. have it, your app gets back the generic ID=128 ICON resource
  161. >From the System.
  162.  
  163. Resources are what let 128K Macs run 300K applications that
  164. were more impressive in their day compared to IBM PCs.  I'd
  165. assert that most programmers today don't know how to
  166. effectively use 1 MB of memory, our current standard, which is
  167. about to change again.
  168.  
  169.  
  170. ------------------------------------------------------
  171. MPW / Development Environments / Programming Languages
  172. ------------------------------------------------------
  173.  
  174. MPW stands for Macintosh Programmer's Workshop.  It is a very
  175. expensive, but highly powerful and expandable development
  176. environment for Macintosh programming.
  177.  
  178. You would be much better off to save yourself several hundred
  179. dollars and start with THINK C, or THINK Pascal.  These two
  180. products are incredible, similar to  Borland's Turbo products in
  181. Clone land.  The THINK Products are very high quality, reliable,
  182. cheap, and very (*** VERY ***) well supported. They also have
  183. the advantage of being very small, and about 20-100 times
  184. faster than MPW.  They will also do everything that MPW will do.
  185.  
  186. ***
  187.  
  188. MPW stands for Macintosh Programming Workbench (I think).  It
  189. is sort of a unix like shell that integrates various programming
  190. tools.  There are many different compilers that run under MPW
  191. and let you link code from different languages together into a
  192. single program.  I have never used it, since I use Think C for
  193. programming.
  194.  
  195. ***
  196.  
  197. MPW stands for Macintosh Programming Workshop, and it's a
  198. "shell" and text editor.  It runs things called "Tools", and people
  199. like to pretend MPW is a form of a Unix shell for the Macintosh.
  200. Several useful tools include compilers like MPW Pascal, MPW C
  201. and CFront (Apple's C++ preprocessor).  MPW Shell lets you edit
  202. text files usually for compilers, but not always.  It permits
  203. aliasing, it has a form of "grep", and other things you'd normally
  204. find in the Unix environment (Yuk).  I'd hate MPW to death if it
  205. weren't for an OOP (Object Oriented Programming) tool like
  206. MacApp that only works with MPW Pascal.
  207.  
  208. You will find everything unnerving and difficult until you learn
  209. the power of true OOP languages and things like MacApp, which I
  210. strongly recommend you learn as part of your Macintosh learning
  211. process.  Once you've started, I suggest you immediately
  212. consider an OOP language and an OOP tool like MacApp.  You may
  213. think it's too soon to start thinking about that, but I have a
  214. suspicion that by the time you are adept with the Macintosh,
  215. everyone else will be using OOP tools. Don't let anybody convince
  216. you otherwise.  Apple is using C++ with MacApp for their System
  217. 7.0 software, and some of the most powerful software packages
  218. are now being written using MacApp.  Consider learning
  219. Symantec's THINK C Class Library or MacApp as part of your
  220. initiation to Macintosh programming.  Most adept Mac hackers
  221. would shun such a thought, but you won't be able to survive a
  222. year from now given the order-of-magnitude increase in turn
  223. around time garnered from using OOP languages and tools.
  224.  
  225. MacApp comes with several apps (written in MacApp of course!)
  226. that allow you to edit View resources (more complicated than
  227. what ResEdit can handle) and browse C++ or Object Pascal
  228. source code in a SmallTalk sort of fashion.  APDA sells MPW,
  229. Pascal, C++ and MacApp.
  230.  
  231. ***
  232.  
  233. Pascal and C are the languages of choice on the Mac. The
  234. operating system was written in Pascal so much of the
  235. documentation from Apple is in Pascal but there's usually
  236. straightforward conversions. System 7.0 will be written in C it
  237. is rumored so that will become even more important. MPW is the
  238. Macintosh Programmer's Workshop from APDA, the Apple
  239. Programmers and Developers Association. It costs about $300
  240. for the basic shell and about $300 for each language
  241. additionally. I use Think C from Symantec which retails for
  242. about $120, highly recommended.
  243.  
  244.  
  245. ------------------------
  246. RESEDIT
  247. ------------------------
  248.  
  249. One note I would like to make concerning the info I received
  250. about ResEdit:  Everyone suggested that ResEdit is available
  251. >From the archives, but I have not been able to find it listed.
  252. Here is what people had to say about ResEdit...
  253.  
  254. Resources are usually created with Rez, or ResEdit, and stored
  255. in the resource fork of the application's file.  They can be
  256. created on the fly by the program, however.
  257.  
  258. *Warning*:  ResEdit will edit any resource, including those that
  259. the Macintosh Operating System relies on.  Use at your own risk,
  260. or face the Bomb!
  261.  
  262. ***
  263.  
  264. ResEdit is a resource editor which can be used to look at and
  265. modify things found in the resource fork. It's most often used
  266. for things like messing with icons and suchlike.
  267.  
  268. ***
  269.  
  270. ResEdit is for editing Resources.  It was
  271. written by Apple and probably is available from APDA.  It may be
  272. available for free, look in the info-mac archives.  It also comes
  273. with Think C which is how I got it.
  274.  
  275. ***
  276.  
  277. APDA is Apple's development tools distribution channel.  They
  278. sell ResEdit, but I think Apple also has it for free via FTP to
  279. Apple's FTP-able Internet workstation.  If you were at CMU, you
  280. could get it from one of our AppleShare servers - ask around for
  281. a copy, it's "free".
  282.  
  283. ***
  284.  
  285. Resedit is "the" resource editor, and is available from APDA,
  286. Aplle Computer, Inc., 20525 Mariani Avenue, M/S 33G, Cupertino,
  287. CA  95014-6299.  It's $25.
  288.  
  289.  
  290. --------------------------------------
  291. READING LIST
  292. --------------------------------------
  293.  
  294. Here are some suggestions for reading material gleaned from
  295. the messages I received (these are not in any particular order).
  296. The reason for this is just about everyone suggested I begin my
  297. reading with different books, so I leave the choices up to you.
  298.  
  299. a) There was a fairly nice article in the JUNE 1989 issue of
  300.    MACUSER on page 153 (I neglected to look at the title when I
  301.    checked the issue).  It was on using ResEdit to modify your
  302.    desktop (the spacing between icons and the way they are
  303.    arranged, for instance) which was written at a nice tutorial
  304.    level and along-the-way explained some things about ResEdit,
  305.    certain kinds of resources, data forks, and the like.  If you
  306.    don't get a better option, you might give it a look.
  307.  
  308. b) Read Inside Mac, Vol 1, 2, 4, & 5. (just 1 & 2 to start. 4 for
  309.    Hierarchical File System, List Manager, & 5 for Script
  310.    Manager, New textEdit, and color support.)
  311.  
  312. c) read Scott Knaster's "How to Write Macintosh Software."
  313.  
  314. d) Subscribe to Mactutor, but don't believe everything you need.
  315.  
  316. e) read the Tech. Notes, available by downloading or from APDA.
  317.    These, along with examples of code are readily available
  318.    from these archives.
  319.  
  320. f) Join APDA, the Apple Programmers & Developers Association.
  321.    Their catalog includes tools and prerelease software
  322.    available nowhere else. They are $20 a year, and reachable
  323.    through Apple's Cupertino number.
  324.  
  325. g) Macintosh Revealed (all three volumes).
  326.  
  327. h) Try one of the Microsoft Press books.
  328.  
  329. i) If you just want to program and have a good time, then most
  330.    of the reputable compilers come with decent examples that
  331.    are worth studying. That, and the volume of Inside Mac that
  332.    has the managers you are interested in learning, (such as Vol
  333.    1: Quickdraw) are enough to take you a long way.
  334.  
  335. j) Pick up a copy of Kurt Schmucker's "Introduction to Object
  336.    Oriented Programming on the Macintosh" which describes OOP
  337.    and the old version of MacApp.
  338.  
  339. k) A book on C programming for the Macintosh which has a
  340.    fantastic chapter on resources is from Addison-Wesley
  341.    Publishing, Scott Knaster, Macintosh Programming primer in
  342.    C. It  has some excellent example programs, easy to follow
  343.    and extensible, and a logical organization.
  344.  
  345. l) "Using the Macintosh Toolbox" w/C by Takatsuka, Huxham, & Burnard.
  346.  
  347. ------------------------------------
  348. THE PANEL OF EXPERTS
  349. ------------------------------------
  350.  
  351. These are the folks who were so helpful to me.  I'm sure that if
  352. you ask them nicely they may just be able to furnish more
  353. specific information if you needed it!
  354.  
  355.  
  356. JELLIS@BOWDOIN (Until 5/90)
  357. David Phillip Oster (Arpa: oster@dewey.soe.berkeley.edu)
  358. Joe McMahon <XRJDM@SCFVM>
  359. ELIOT@cs.umass.EDU
  360. Brian Patrick Arnold <ba0k+@andrew.cmu.edu>
  361. Jeff Meredith <meredith@erl.mit.edu>
  362. MARGARET GIBBS (GIBBSM@LL.LL.MIT.EDU)
  363.  
  364.      ___         _____________________________________________
  365.    / __        |  University Computing and Learning Services |
  366.   |_|  |  |     |              INFORMATION CENTER             |
  367.       /  /      |        Ohio University, Athens, Ohio        |
  368.      |__|       |=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=|
  369.       __        |          BITNET: kesler@ouaccvma            |
  370.      |__|       |_____________________________________________|
  371.  
  372.       "The above information is not mine, I have only edited the
  373.        info I was sent to make it a bit more coherent and presentable.
  374.        Many, many thanks to those who contributed."
  375.  
  376.