TweetFollow Us on Twitter

Dec 97 - Getting Started

Volume Number: 13 (1997)
Issue Number: 12
Column Tag: Getting Started

Getting Started With Macintosh Programming: Circa 1998

by Dave Mark , Copyright 1997, All Rights Reserved

A long, long time ago, I wrote an article for MacTech Magazine (called MacTutor, at the time) answering the question, "How do I get started with Macintosh Programming?" About once a year, I update the article and do my best to pass it around to the community. This is the 1998 version. Learning to program the Macintosh can be incredibly rewarding and enjoyable. I've been doing it for about 13 years, and I still get a charge out of seeing my thoughts and ideas come to life on my Mac's screen. If the idea of being able to build your own Mac applications sounds like fun to you, read on. Don't let the turmoil at Apple discourage you. I think Apple will be around for a good long time. I mean, think about it. Would you rather use a Mac or a Windows machine? To me there is no comparison. I want my Macintosh.

A quick caveat: Just so you know, I work for Metrowerks and write Mac programming books and both are recommended in the following pages. If you have any doubts about the contents below, find a friend with Mac programming experience (or find a newsgroup or on-line forum) and ask for yourself. I don't mind! ; ) Want to get in touch with me? Check out my web site http://www.spiderworks.com or send me email at dmark@metrowerks.com.

The Three Basic Steps

Start Off by Learning

So how do you learn to program the Macintosh? For starters, you'll need to decide on a programming language. In my opinion, there is no better way to start your programming education than with C. The C programming language is the most popular programming language in the world. Once you know C, you've got a language you can use on just about any computer in the world. More importantly, C++, Objective-C, and Java are all supersets of C. In other words, learning C will give you a leg up on learning any or all three of these important languages.

To be fair, there are other opinions on the best language to start with. For example, there are quite a few people who think that Pascal is the easiest language to assimilate. Though I agree that Pascal is a great programming language, and is less cryptic than C, there are several reasons I'd go with C as your first language. For starters, C is much more popular than Pascal. To convince yourself of this, go into a well-stocked computer bookstore and count the Pascal, C, C++, and Java books. Chances are, you'll find lots of C, C++, and Java books and perhaps one or two Pascal books (if any). The point here is, though some might say Pascal is the better language, C is clearly more popular and, therefore, better supported. Because it forms the basis for both C++ and Java syntax, learning C is a better investment in the long haul.

Still other people argue that novice programmers should start off by learning either C++ or Java as a first language. I don't like this approach. Don't be fooled. C++ and Java are both object-oriented languages and require that you master two sets of concepts: the procedural techniques and syntax of C, as well as the complexities of programming with objects. Learn to crawl, then learn to walk. That way you'll have mastered two skills and each phase of the learning process is simpler. By learning C first, you'll master the basics of procedural programming. You'll know the C language. You'll also have a much easier time learning Objective C, C++, or Java. In fact, you'll find it much easier to master all three languages. You'll be able to program in straight C if the situation calls for it.

Then Learn the Mac Toolbox

The C programming language, by itself, won't allow you to add Mac-specific features like windows, menus, icons, and dialog boxes to your programs. Your C programming environment (more on that in a bit) most likely comes with something called the C Standard Library which lets you do some very basic, text-oriented input and output. You can ask the user for input from the keyboard, process that input, and spit out results, all in a scrolling text window known as the console. Console-based programs have the smell of DOS and old technology. While they may get the job done, they are no substitute for the real thing -- a true Macintosh program.

To add all the cool Macintosh gadgets to your C programs, you'll need to learn how to use the Macintosh Toolbox, a set of functions built into each and every Macintosh computer. The universal availability of the Toolbox ensures that a window on your Macintosh looks and behaves exactly the same as on my Mac. There are Toolbox functions to create a new window, to implement a pull-down or popup menu, to draw in a window, drag the window around on the screen... in short, anything you want to implement in the way of Macintosh user interface, chances are there is already a Toolbox function to do exactly what you want.

Then Learn an Object Programming Language and Framework

Once you master the basics of programming using the Toolbox and C, you'll probably want to move up to the next level -- programming using objects. Just as the Mac Toolbox takes much of the work out of programming (by implementing the Macintosh look and feel so you don't have to), an object framework implements much of the structure of your program and wraps it in reusable chunks called objects. Objective-C, Java, and C++ are all object-oriented programming languages (programming languages that support objects). There are a variety of frameworks written in each of these languages. Once you decide on an object programming language, you'll also decide on a framework to work within. When you get on board with your programming language of choice, check out the work Metrowerks is doing with the PowerPlant framework. PowerPlant is currently the framework for Macintosh C++ programming. As Apple moves forward with Rhapsody (their new operating system), my guess is PowerPlant will also change to stay synchronized with Rhapsody and to accommodate Objective-C and Java, the official languages of Rhapsody.

Resources to Help You Get Started

Books to Help You Learn C and the Toolbox

If you are brand new to programming, you may want to check out Learn C on the Macintosh by Dave Mark (that's me). Normally, I try to avoid recommending my own books to people, but if you are new to programming or to the C programming language, I do believe Learn C is the best place to start. Learn C assumes no previous programming experience and takes you through the process of programming using C. The book comes with everything you need to get started including a copy of CodeWarrior Lite, a non-saving version of the leading Macintosh programming environment.

Most of the books, tools and products mentioned in this article can be ordered from DevDepot. Their phone number is 800.622-3381. Outside the US and Canada, the number is (805) 494-9797. Their web site is http://www.devdepot.com and email orders are orders@devdepot.com.

Once you learn C (or if you are already a C programmer), you'll want a book that teaches you how to make your programs take advantage of the Macintosh Toolbox. Fortunately, there are a great number of Mac Toolbox books. If you like the style of Learn C on the Macintosh, check out the Macintosh C Programming Primer, 2nd Edition.

But the Primer is just the tip of the iceberg. Take the time to go to a technical bookstore well-stocked in Macintosh programming books. Some other books to look for are Programming Starter Kit for Macintosh by Jim Trudeau, Power Macintosh Programming Starter Kit by Tom Thompson, and Foundations of Mac Programming by Dan Sydow. You might also take a look at How to Write Macintosh Software, 3rd Edition by Scott Knaster. This last book is pretty old, but it still remains one of my favorites. Of course, there are new Mac Toolbox books being written all the time and you should also be on the lookout for any Rhapsody-specific books as Apple's new OS release looms closer to reality.

Get CodeWarrior

As you make your way through your first few programming titles, you'll definitely want to start practicing your new found programming skills. By far, the most recommended and most widely used programming environment on the Mac is CodeWarrior. CodeWarrior is made by a company in Austin, Texas named Metrowerks. Remember, I do work at Metrowerks, so ask your Mac programming buddies about CodeWarrior.

To be fair, there are other tools you can use to create Macintosh applications, including the Macintosh Programmer's Workshop (MPW) from Apple, and a variety of visual programming tools as well. Go to the DevDepot web site http://www.devdepot.com and spend some time looking around. Get to know the alternatives. Even if you do choose CodeWarrior, you'll benefit from knowing what else is out there.

CodeWarrior is based on a front-end/back-end architecture. The front end translates your source code (your C, C++, Java, Pascal, or Objective C statements) into an internal representation. The back end translates the internal representation into machine code targeted at a specific processor type. For example, for Macintosh development CodeWarrior features back-ends for both the 680x0 series of processors as well as for the PowerPC.

More importantly, CodeWarrior also has back-ends for the x86 and Pentium series of processors, as well as for a variety of other processors. That means you can write a Windows 95 or WinNT application completely on your Macintosh. Really!

If your ultimate goal is cross platform wizardry, Metrowerks also ships versions of CodeWarrior that run under Windows 95, Windows NT, as well as under BeOS. (BeOS is a cool new operating system from Be, Inc.) If games are your thing, Metrowerks also makes the official development environment for Sony PlayStation (cool!) and the PalmPilot PDA.

CodeWarrior comes in two basic Mac flavors: a professional package called CodeWarrior, Professional Edition and a series designed for beginners called CodeWarrior, Discover Programming Edition. CodeWarrior Pro is a professional development environment and comes with everything you could ask for in a programming tool. It ships with C, C++, Java, and Pascal front-ends, as well as with PowerPC, 680x0, and x86 backends. CodeWarrior Pro includes the latest beta Rhapsody development tools as well, including an Objective-C front end. You also get a series of electronic (non-printable) programming books, including Learn C on the Macintosh, Learn C++ on the Macintosh, Programming Starter Kit for Macintosh, and CodeWarrior Software Development Using PowerPlant, as well as a series of Apple Guide files to help you get started, and a boatload of sample code, extra tools and demos.

When you buy CodeWarrior Pro, Metrowerks throws in one year's worth of updates for free. Typically, Metrowerks releases new versions of CodeWarrior in May (in time for Apple's World Wide Developer's Conference, or WWDC) and October. Prior to the May 1997 release, CodeWarrior Pro was called CodeWarrior Gold and was released three times a year. The version number was reset to 1 with the May CWPro release. At the same time, Metrowerks moved to two releases a year. For example, in January '97, Metrowerks released CW11. CodeWarrior Pro 1 was released in May. CodeWarrior Pro 2 was released in October. You get the idea.

If you plan to do any commercial software development for the Mac, CodeWarrior Pro is a must. A one year subscription is US$499. Once you are registered, a 1 year upgrade is US$299.

If that price seems a bit steep, check out CodeWarrior, Discover Programming Edition. Discover Programming is a non-commercial, Mac-only version of CodeWarrior Pro. Though you get C, C++, Pascal, and Java front ends, you only get the 680x0 and Java byte code backends. The 680x0 back-end means that all the programs you build will be in 680x0 native format. They'll run just fine on a PowerMac, but in emulation mode (a bit slower than PowerPC native mode). If you are just learning how to program, you likely won't even notice the difference. As you'd expect from a learning edition, you also get all the electronic books and sample code.

CodeWarrior, Discover Programming Edition is only $79. If you upgrade to CodeWarrior Pro directly through Metrowerks, they'll take $79 off the upgrade price. If you are just getting started, Discover Programming for Macintosh is a great deal!

By the way, there are versions of CodeWarrior Discover Programming Edition for both Macintosh and Windows. They each list for $79.

Getting Started with CodeWarrior

Once you have CodeWarrior installed, you'll want to learn how to use it. Start off by running the Apple Guide tutorials. You'll find them under the Help menu. There are tutorials that show you how to create C and Pascal console projects, and C and Pascal Mac Toolbox projects. There are also a series of Java-specific tutorials. Take the time to go through all the tutorials that apply. An important part of learning how to program is mastering your development environment. The CodeWarrior Integrated Development Environment (IDE) is a sophisticated and powerful application that will take some time to learn. The tutorials will help you get started.

Once you've created some simple applications, dig into the documentation. You'll find answers to many of your early questions in the IDE User's Guide. Once you feel comfortable with the IDE, go back and take the CodeWarrior Debugger tutorial. You'll then want to spend some time with the Debugger manual.

More Books and Tools

Once you have your development environment installed and have the basics of Macintosh C programming under your belt, you'll want to add a few more items to your programming arsenal. For starters, you'll need a copy of Inside Macintosh, the bible of the Macintosh Toolbox. Inside Macintosh consists of a series of more than 25 books, each of which completely describes some portion of the Macintosh Toolbox. These books are indispensable. These books are also expensive, especially if you intend to buy the entire series.

Though it is certainly nice to have the printed copies of the Inside Macintosh books, consider buying the electronic version instead. The Inside Macintosh CD-ROM sells for US$89.95 and includes the complete text of most every Inside Macintosh volume in a cross referenced and hyper-linked form. Get this CD-ROM.

Of particular interest is the volume called Inside Macintosh: Macintosh Human Interface Guidelines. This book covers Apple's human interface standards in great detail. They will teach you how a Macintosh application is supposed to behave, from the proper location of OK and Cancel buttons in a dialog box to the proper way to position multiple windows on the user's display. Though the interface standards might seem excessive, it's that strict attention to detail that makes a Macintosh application so recognizable. Read this book.

Another important tool that you'll want at your disposal is a resource editor. Macintosh programs store program-related data such as icons, cursors, window descriptions, and text in a special portion of your application file called a resource fork. A resource editor is essential for you to be able to edit your application's resources. Apple created a widely distributed resource editor called ResEdit. Though ResEdit does a relatively adequate job of editing most resources, once you get into some serious Macintosh programming, you'll quickly discover ResEdit's limits.

A company called Mathemaesthetics created a program called Resorcerer that goes well beyond what ResEdit can do. Mathemaesthetics charges US$256 for Resorcerer, though students can get it for half price (you'll need a student ID or educational mailing address to qualify).

You can write to Mathemaesthetics at sales@mathemaesthetics.com. Their web site is www.mathemaesthetics.com (big surprise there) and their phone number is (303) 440-0707. You should definitely check out their web site, both for their explanation of what Resorcerer can do as well as for new versions, patches, and possible price changes.

Of course, the net is also a critical resource. In addition to the myriad of programming related sites, you might want to check out this tutorial for CodeWarrior users in both Pascal and C at http://www.AmbrosiaSW.com/alt.sources.mac/macintosh-c/.

You should also check out this group of Mac programmers that help with online self study, MOST at http://www.aimed.org/most/.

And Apple offers courses and certifications at Developer University at http://www.devworld.apple.com/dev/du.shtml.

The Metrowerks site, as you might expect is http://www.metrowerks.com.

Finally, check out WarriorWorld, a site for all CodeWarriors http://www.codewarrior.org/.

Your next step should be a visit to a hard-core technical bookstore. At the very least, pick up a copy of C, A Reference Manual by Harbison and Steele. This book, affectionately known as H&S, is a terrific C programming reference that will get a lot of use as you gain experience writing C code. There are also a number of books that describe data structures, searching and sorting algorithms, as well as techniques to help avoid common programming errors. Some of these books are language independent, while others are specific to C, Pascal, Objective-C, or Java. Find a writing style that you feel comfortable with. If you find any that you found particularly useful, please do drop me a line and let me know.

Here's a list of books the folks at Metrowerks recommended:

Language Reference

  • Advanced C++ by Coplien.
  • The Annotated C++ Reference Manual by Ellis and Stroustrup.
  • STL Tutorial and Reference Guide by Musser and Saini, Addison Wesley.
  • C, A Reference Manual by Harbison & Steele.
  • C++ Primer Plus by Stephen Prata.
  • C++ The Complete Reference by Herbert Schildt.
  • The Evolution of C++ Programming by Stroustrup.
  • The Standard C Library by P.J. Plauger.
  • The Java Class Libraries: An Annotated Reference by Patrick Chan and Rosanna Lee.
  • The Java Language Specification by James Gosling, Bill Joy, and Guy Steele.
  • The Java Programming Language by Arnold and Gosling (the guy who invented JAVA).
  • Java Programming for the Internet by Thomas, Patel, Hudson, and Ball.

Avoiding Language Pitfalls

  • Effective C++ and More Effective C++ by Scott Meyers.
  • Code Complete and Rapid Development by Steve McConnell.
  • C Programming and Dynamic Memory Management by Daconta, QED publishing.
  • C++ FAQs by Cline & Lomow.
  • C Pointers and Dynamic Memory Management by Michael C. Daconta.
  • C++ Pointers and Dynamic Memory Management by Michael C. Daconta.

Algorithms

  • Algorithms in C by Sedgewick.
  • Data Structures and C Programs by Van Wyk.
  • The Knuth Computer Science series.
  • Introduction to Algorithms by Thomas Cormen, Charles Lieserson, and Ronald Rivest, McGraw Hill/The MIT Press.
  • Introducing Algorithms in Pascal by Thomas W. Parsons.

Software Design

  • Code Complete by Steve McConnell.
  • Debugging Macintosh Software by Othmer and Straus.
  • Debugging the Development Process by Steve Maguire.
  • Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides.
  • Developing Object-Oriented Software for the Macintosh by Goldstein and Alger.
  • Large-scale C++ Software Design by John Lakos.
  • No Bugs by Thielen.
  • Object-Oriented Analysis and Design With Application- by Booch.
  • Object Oriented Programming by Peter Coad & Jill Nicola.
  • Rapid Development by Steve McConnell.
  • Software Implementation by Michael Marcotty.
  • Software Tools by Kernighan and Plauger.
  • Taligent's Guide to Designing Programs. Well-mannered Object-Oriented Design in C++. Taligent Press/Addison Wesley.
  • Writing Solid Code by Steve Maguire.
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Little Snitch 3.5.3 - Alerts you about o...
Little Snitch gives you control over your private outgoing data. Track background activity As soon as your computer connects to the Internet, applications often have permission to send any... Read more
Cocktail 8.4 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
PDFKey Pro 4.3 - Edit and print password...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Kodi 15.0.beta1 - Powerful media center...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
DiskCatalogMaker 6.4.12 - Catalog your d...
DiskCatalogMaker is a simple disk management tool which catalogs disks. Simple, light-weight, and fast. Finder-like intuitive look and feel. Super-fast search algorithm. Can compress catalog data... Read more
Macs Fan Control 1.3.0.0 - Monitor and c...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more
Lyn 1.5.11 - Lightweight image browser a...
Lyn is a lightweight and fast image browser and viewer designed for photographers, graphic artists and Web designers. Featuring an extremely versatile and aesthetically pleasing interface, it... Read more
NeoOffice 2014.11 - Mac-tailored, OpenOf...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
LaunchBar 6.4 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Remotix 3.1.4 - Access all your computer...
Remotix is a fast and powerful application to easily access multiple Macs (and PCs) from your own Mac. Features Complete Apple Screen Sharing support - including Mac OS X login, clipboard... Read more

Battle of Gods: Ascension (Games)
Battle of Gods: Ascension 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: TURN-BASED TACTICAL COMBATFight tactical battles against the forces of Hades! In Battle of Gods: Ascension you play... | Read more »
Shadowmatic's Latest Update Adds a...
Shadowmatic's shadowy shadow-ness is getting a little shadowy-er thanks to a recent update that adds an Arcade Mode. [Read more] | Read more »
Sunrise Calendar and Slack Have Assimila...
Wunderlist is perhaps one of the most populat and beloved productivity apps on the App Store - and now it's gone and incorporated itself into other useful services like Sunrise Calendar and Slack. [Read more] | Read more »
Crossy Road Devs Hipster Whale are Bring...
Hipster Whale, the minds behind the rather popular (and rather great) Crossy Road, have teamed-up with Bandai Namco to create PAC-MAN 256: an absolutely bonkers looking maze runner chaser thing. | Read more »
Meet the New Spotify Music
Spotify Music  has a lot going on. They're introducing 3 new modes to serve all your musical needs, with the "Now" start page  gives you curated playlists based on your particular tastes. As you listen the app will learn more about your tastes and... | Read more »
What the Apple Watch Gets Right, and Wha...
| Read more »
Celebrate PAC-MAN's 35th Birthday W...
BANDAI NAMCO Entertainment America is celebrating PAC-MAN's 35th anniversary by releasing updates for PAC-MAN and PAC-MAN Lite for iOS. [Read more] | Read more »
Strike Wing Episode 2 has Landed on the...
Strike Wing: Raptor Rising is an exciting space combat simulator by Crescent Moon Games, which was recently updated to continue the story with Episode 2. [Read more] | Read more »
Kiqplan Expands its Interactive Coaching...
The makers of Fitbug have been hard at work on their Kiqplan lineup, and have added four new summer themed plans to help you get the most out of your workout. [Read more] | Read more »
Make a Photobook in Minutes with Pictyea...
What happens when you can't stop taking photos and have an urge to create a photobook? Pictyear saves the day. [Read more] | Read more »

Price Scanner via MacPrices.net

What Would the ideal Apple Productivity Platf...
For the past four years I’ve kept a foot in both the Mac and iPad camps respectively. my daily computing hours divided about 50/50 between the two devices with remarkable consistency. However, there’... Read more
New 13-inch 2.9GHz Retina MacBook Pro on sale...
B&H Photo has the 13″ 2.9GHz/512GB Retina MacBook Pro on sale for $1699.99 including free shipping plus NY tax only. Their price is $100 off MSRP, and it’s the lowest price for this model from... Read more
12-inch MacBook stock status for Monday, May...
The new 12″ Retina MacBooks are still on backorder at The Apple Store with a 3-5 week waiting period. However, a few models are in stock today at Apple resellers. Stock is limited, so act now if you’... Read more
New 27-inch 3.3GHz 5K iMac in stock with free...
Adorama has the new 27″ 3.3GHz 5K iMac in stock today for $1999 including free shipping plus NY & NJ sales tax only. Adorama will include a free copy of Apple’s 3-year AppleCare Protection Plan. Read more
Memorial Day Weekend Sale: New 27-inch 3.3GHz...
Best Buy has the new 27″ 3.3GHz 5K iMac on sale for $1899.99 this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders only, in-store prices may vary... Read more
OtterBox Maximizes Portability, Productivity...
From the kitchen recipe book to the boarsroom presentation, the OtterBox Agility Tablet System turns tablets into one of the most versatile pieces of handheld technology available. Available now, the... Read more
Launch of New Car App Gallery and Open Develo...
Automatic, a company on a mission to bring the power of the Internet into every car, has announced the launch of the Automatic App Gallery, an app store for nearly every car or truck on the road... Read more
Memorial Day Weekend Sale: 13-inch 1.6GHz Mac...
Best Buy has the new 13″ 1.6GHz/128GB MacBook Air on sale for $849 on their online store this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders... Read more
Memorial Day Weekend Sale: 27-inch 3.5GHz 5K...
Best Buy has the 27″ 3.5GHz 5K iMac on sale for $2099.99 this weekend. Choose free shipping or free local store pickup (if available). Sale price for online orders only, in-store prices may vary.... Read more
Sale! 16GB iPad mini 3 for $349, save $50
B&H Photo has the 16GB iPad mini 3 WiFi on sale for $349 including free shipping plus NY sales tax only. Their price is $50 off MSRP, and it’s the lowest price available for this model. Read more

Jobs Board

Architect / Senior Software Engineer, *Apple...
Changing the world is all in a day039s work at Apple . If you love innovation, here039s your chance to make a career of it. You039ll work hard. But the job comes with Read more
*Apple* Pay Support Readiness Project Manage...
Changing the world is all in a day039s work at Apple . If you love innovation, here039s your chance to make a career of it. You039ll work hard. But the job comes with Read more
Hardware Design Validation Engineer - *Apple...
**Job Summary** The Apple Watch team is looking for a Hardware Design Validation Engineer. This person will be part of the Apple Watch hardware team with Read more
Sr. Payment Program Manager, *Apple* Pay -...
**Job Summary** Apple Pay is an exciting environment and a…devices in a simple, private and secure way. The Apple Pay Team is looking for an experienced Senior Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.