Updated C Tutorial for Cocoa

Another step in revamping Cocoa Dev Central. The C Language Tutorial for Cocoa has been completely stripped down, streamlined, redesigned and rewritten. The look is in inline with the new home page, but that's just the beginning.

The earlier version of this tutorial was, I think, one of the easiest ways to get started in C programming, particularly if your main reason for learning C was to learn Cocoa. This new version is even easier to read. I chopped out all sorts of unnecessary ramblings and left the essentials: the code and the basic explanations for that code. The design is just as stripped down.

I realize this technically isn't new content, but the idea is to give the new design a test run on an existing tutorial first to work out all the details. There is a new tutorial in progress.

Something Else is Different

For a long time, I wanted Cocoa Dev Central to just be 100% free. No ads, no donations. Nothing. Three things occurred to me, though:

1. Doing really great tutorials takes time
2. People want new tutorials frequently
3. Frequent new tutorials is hard to do if they don't pay

Maybe it seems obvious that great tutorials take time, but let me explain what that means to me.

What Goes Into a Tutorial?

The Build a Core Data app tutorial is very popular. I think it's very easy to read and follow, but it does take some time to read and go through. In fact, it takes quite a while. Now, if it takes a while to read, think about how much time it took to make.

Out of everything I've done, technical writing takes absolutely the most concentration. For any block of text, I'm asking myself a number of questions:

- Is this correct?
- Does it make sense to the reader?
- Does it fit into the overall tutorial structure?
- Does it fully cover the concept in question?
- Is this concept too advanced (or too remedial)?
- Is it as simple as it can be?

That last one is the hardest, by far. It's easy to just write and write. It's hard to strip it all down to the shortest, plainest language possible. I think that's what Cocoa Dev Central stands for, though.

That's just the writing side. Most tutorials need a sample application. That means coming up with an app, designing the UI and data model, and writing the code. The Core Data tutorial also has many, many screenshots and diagrams which were painstakingly crafted to highlight only the important areas.

It's Worth It, But...

Now, I wouldn't do this if I didn't think it was all worthwhile and interesting. I also think all this effort has paid off because the Cocoa Dev Central tutorials really seem to resonate well with people. Still, a good tutorial takes a lot of time. So that leaves these options:

1. Everything stays free but new content is rare.
2. Everything stays free but corners are cut to save time.
3. Write new content, require payment.
4. Write new content, ask for donations.

We've already tried option one. I don't like option two because what's the point of doing something if you're not going to make it special? Option three takes it a bit too far. So option four is the winner. If I can make some income from writing tutorials, I can justify sitting down to write new tutorials.

So Cocoa Dev Central has officially started asking for donations. You can still read everything on the site for free (and I don't expect that to change), but if you like the content, please consider donating so that I can put more time into it.

At the moment, the donation button is only on the page for the C Tutorial. It will be added to any new or redesigned tutorials, and may end up on the home page.
Design Element
Updated C Tutorial for Cocoa
Posted Oct 19, 2006 — 15 comments below




 

Frank 'viperteq' Young — Oct 19, 06 2108

I would DEFINITELY put a donations button on the home page. It lets people know that you "aren't trying to be a greedy bastard, but it does take time and effort to make all of these tutorials, so please support". Plus with the donation button on the home page, I'd be more apt to donate first, then jump into learning some new material.

Jeroen Leenarts — Oct 20, 06 2109

I'd say, yes, put a donation button on there. And be sure to mention it at the end of every tutorial. "If you liked the tutorial, consider giving a donation to support ... etc etc..."

Done the right way people will not be offended by it. Make sure to put up a special page detailing what you just said in this blog entry too. I'd consider donating a few euro's whenever something is usefull to me and it's free.

Christian Machmeier — Oct 20, 06 2110

Great, you're in progress. Kepp it up!

Keith Duncan — Oct 20, 06 2111

Good job on the new C tutorial, when I started learning Cocoa yours was one of the first sites I found and your C tutorial was invaluable - as are the rest of your tutorials!

Rob — Oct 21, 06 2115

I have done very well with your screen saver tutorials, from a couple of months ago, THANK-YOU SOO MUCH !

Now I know that some people have complained about those tutorials as the code was certainly not an example of good coding.

I actually think that the tutorial design was brilliant -- a stroke of genius !!!

I don't think you are the first teacher to use this strategy and you run into it much because it is a risky strategy, but it is an established strategy.

The strategy was that the code is written in all sorts of ways, all the possibilities, to use as many types of C expressions as possible.

This worked GREAT for me because I have taken many C, Java, and C++ classes over the years, the last time in 2002 -- so it was a great refresher course.

And at first it was a little frustrating but then when I realize what you had done, I really liked it, and cleaned up the code myself.

The only flaw I would see with the tutorials was that I believe from reading Apple's docs that beziepaths are meant to have drawing operations continuously added to them with subsequent drawing, your tutorial does not do this, although there is plenty of opportunity to do that.

I have only looked at the second one a little bit, the first one has allowed me to go so far I am a bit preoccupied with that.

17,000 lines of code and counting !!!

Progress bar to tell the user what is being draw ...

... auto-scrolling of the About... in the dialog ...

... desktop animation and transparency ...

... so the desktop image can be seen beneath ...

... its WAY COOOOL !!!

Scott Stevenson — Oct 21, 06 2116 Scotty the Leopard

I have done very well with your screen saver tutorials, from a couple of months ago, THANK-YOU SOO MUCH !

Those were written by Brian Christensen.

Robert — Oct 21, 06 2118

Those were written by Brian Christensen.

Oh well, thanks for putting them on your site.

Dan Price — Oct 22, 06 2124

Very nice, but I still don't get a little favicon when viewing the site in Safari. Looks a little odd. I want my favicon damnit! :P

Scott Stevenson — Oct 22, 06 2126 Scotty the Leopard

Very nice, but I still don't get a little favicon when viewing the site in Safari.

I'd like to know what that's about too. Everything seems to be setup correctly.

Andrs Puiz — Oct 23, 06 2153

I like your bare-bones C tutorial a lot, it seems to cover the basics very well.
I also hope your donations system will work out, and yes, I would certainly not be too shy about putting it on the front page and at the end of each tutorial. If you implemented nag screens with countdown scripts, now, that would be a whole different story... :) But this is gentle, and feels just right and fully justified.

About the C tutorial itself: I've heard developers grumble about newbies who hardly know any C or other low-level technology, and jump right into Cocoa and Obj-C. What's your take on this?

If someone is serious about developing GUI apps in Cocoa, shouldn't he or she at least work through Kernighan and Ritchie before firing up InterfaceBuilder?

Scott Stevenson — Oct 23, 06 2154 Scotty the Leopard

I've heard developers grumble about newbies who hardly know any C or other low-level technology, and jump right into Cocoa and Obj-C. What's your take on this?

My take is do what works. If you ship an app and it makes the user happy, who cares how much you know about bit shifting?

Some people are happier learning all the lower-level stuff first, and that's fine. But not everyone is wired that way. Some people would rather learn as they go, and research lower-level things when the need arises.

If someone is serious about developing GUI apps in Cocoa, shouldn't he or she at least work through Kernighan and Ritchie before firing up InterfaceBuilder?

My opinion about that is it's a bit like learning the details of how an engine works before you're allowed to drive a car.

KR is well-respected book, but it's written for someone who's looking to write C programs. Prospective Cocoa programmers need to know C syntax to get started, not the guts of C itself.

Andras Puiz — Oct 23, 06 2156

Thanks for your reply.

My take is do what works. If you ship an app and it makes the user happy, who cares how much you know about bit shifting?

OK, let me put it this way (this is not a rhetorical question, and neither do I pretend to know the answer): Do you think that many Cocoa programmers ship apps that make users happy without knowing a bit more about C?

Some people would rather learn as they go, and research lower-level things when the need arises.

Do you only recommend that as a part of a learning process, or do you think it can also be applied when someone wants to actually develop commercial applications? Are there any well-respected Cocoa developers with a great product portfolio without a deep knowledge of C?

My gut feeling is that combining Cocoa building blocks can only take you to a certain point. If you want to add some really unique functionality to your killer app, you cannot always rely on pre-built stuff. Please correct me if I'm wrong here.

My opinion about that is it's a bit like learning the details of how an engine works before you're allowed

Funny you should say that. I've always used that analogy when discussing computers from a user's point of view: the Mac lets you just get in and drive, whereas most Linux distros will force you to get greasy up to the elbows before you can do anything.

But I wouldn't have taken this analogy so far as to include programming as part of the user experience.

Do you believe that programming in Cocoa is just a small step beyond being a power user? In my experience, a programmer is still a very unique beast, and despite the ease of Cocoa, there's still a huge chasm separating those who program from just about everyone else, including the most advanced users or even systems administrators.

I think functions in Excel or Mail rules or Automator workflows or FileMaker databases may blur the line between user and developer, but Cocoa still seems to be firmly implanted on the developer side of the great divide.

In other words: a mechanic, not a driver. And thus, some knowledge of the low-level bits would be neat.

Any thoughts?

Scott Stevenson — Oct 25, 06 2161 Scotty the Leopard

Do you think that many Cocoa programmers ship apps that make users happy without knowing a bit more about C?

It's hard to say what people know, but it wouldn't surprise me if at least some popular Cocoa apps were written by people that don't really know how a 'union' works in C.

Do you only recommend that as a part of a learning process, or do you think it can also be applied when someone wants to actually develop commercial applications?

Let me put it this way: I think the best thing you can do for your learning process to is to start writing an app and not worry about whether you're ready or not. When you run into something you don't understand, you'll know it. Then it's time to read more and ask questions.

Or maybe I should say that's what works for me, and what works for many of the people I teach. There's nothing wrong with learning the lower-level mechanics first if you want to, I just don't think it's strictly required.

If you want to add some really unique functionality to your killer app, you cannot always rely on pre-built stuff.

True. But that's step two. Building a working application (even if it's basic) is step one.

Do you believe that programming in Cocoa is just a small step beyond being a power user?

No, it's a leap.

My point, though, is that you don't need to understand all the details of how malloc() works to build a simple text editor or image viewer. Do that first and see if it interests you. Reading K&R doesn't do much to help you understand if you'll enjoy Cocoa programming.

Andrs Puiz — Nov 13, 06 2394

So I guess you disagree with Joel Spolsky on this one...
http://www.joelonsoftware.com/articles/fog0000000319.html

Scott Stevenson — Nov 13, 06 2397 Scotty the Leopard

So I guess you disagree with Joel Spolsky on this one...

He has good points, but I don't agree with all of his conclusions. If someone has a talent for designing software, I don't like the idea of them waiting around to get interest in malloc before they explore their passion.

If I had to chose between an app which is a joy to use and one which is written "properly," I'll take the former.

Code can be changed. Just start exploring, and fix stuff later if you need to. Most people learn as they go. I think the biggest potential sabotage is worrying about what others will think.




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015