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

Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »

Price Scanner via MacPrices.net

New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more
Updated Apple MacBook Price Trackers
Our Apple award-winning MacBook Price Trackers are continually updated with the latest information on prices, bundles, and availability for 16″ and 14″ MacBook Pros along with 13″ and 15″ MacBook... Read more
Every model of Apple’s 13-inch M3 MacBook Air...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices are the lowest currently available for new 13″ M3 MacBook Airs among... Read more
Sunday Sale: Apple iPad Magic Keyboards for 1...
Walmart has Apple Magic Keyboards for 12.9″ iPad Pros, in Black, on sale for $150 off MSRP on their online store. Sale price for online orders only, in-store price may vary. Order online and choose... Read more
Apple Watch Ultra 2 now available at Apple fo...
Apple has, for the first time, begun offering Certified Refurbished Apple Watch Ultra 2 models in their online store for $679, or $120 off MSRP. Each Watch includes Apple’s standard one-year warranty... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple 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
IT Systems Engineer ( *Apple* Platforms) - S...
IT Systems Engineer ( Apple Platforms) at SpaceX Hawthorne, CA SpaceX was founded under the belief that a future where humanity is out exploring the stars is Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.