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

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.