I started messing around with Xcode the other day, trying (and failing) to throw an app together in AppleScript Studio. This got me reading a bunch of stuff about the other programming languages you can use in Xcode Tools, and the more I read the more confused I got.

My question at the moment is what’s the difference between all these languages? I read up on C, Objective-C, and C++ on Wikipedia, but it all left me feeling a little befuddled. Can any of you programmers out there explain in plain, simple terms that someone who knows nothing of programming why there are so many different languages and what the differences are? Is such a thing even possible, or is it like trying to explain the finer points of calculus to a cave man?

Well… It’s a little like languages in general, I guess, which is why they are called programming “languages” in the first place. That is, they are all just different ways of saying something similar. More specifically, they are all just different ways of talking to the computer. A computer, of course, thinks in binary. Any computer language is just a more human-readable way of expressing logic which is then turned into binary by a compiler (Xcode’s compiler is gcc, a well-known and respected open-source compiler).

C is one of the older languages which is therefore very mature. It is what is called a “procedural” programming language. All programs used to be “procedural”. “Procedural” just means that you program from a to b. That is, you have a main routine that may call subroutines, but everything in your code essentially happens in order, step-by-step. Of course, that is a gross oversimplification. You think of what is going to happen when the program starts, program that, then program everything else, step-by-step (there may be loops, of course), until you get to the end.

Most modern programs are written using “object oriented” programming languages. I don’t think my explanation will do this justice, but basically, all this means is that you program different objects that call on each other rather than step-by-step instructions for the computer. You create “classes”, which are essentially blueprints, and you can then make “instances” of these classes (kind of like having the computer make a car - an object - from a blueprint - the class). This sounds complicated, but to use Scrivener as an example, a window is an object, the binder is another object which contains binder documents which are also objects. The text view is an object. Each of these have their own code associated with them. So, when I need to make changes to the annotations and so forth, I can just go to my text view classes, which deal with generating text views. If I need to make changes to the binder, I can go to my binder controller class. And so on and so forth. With a program as complex as Scrivener, this makes things much simpler - one long set of instructions would be next-to-impossible to manage.

In terms of how this relates to languages, well, Cocoa uses Objective-C. Objective-C is just a subset of plain old C. In other words, it is C, but with extensions to make it object-oriented. C++ is a different subset which also adds (different) extensions to C to make it object-oriented. So, Objective-C and C++ are just very different children of C. The Microsoft Windows frameworks tend to use C++. Carbon - which was around before Cocoa - uses straight C.

That probably just confuses you more. :slight_smile: However, if you are genuinely interested in learning about Objective-C, I cannot recommend highly enough Stephen Kochan’s book ‘Programming in Objective-C’. The book assumes no prior knowledge of C and explains everything you need to know and answers all of your questions. Before reading it, I had dabbled in C, but didn’t really understand what I was doing. If you read that book and then decide you want to create fully-blown Cocoa apps, the next book to read would be Aaron Hillegaas’s Cocoa Programming for Mac OS X. Both books can be got through in a few weeks - they are not doorstoppers by a long shot - and have been the path into Cocoa programming for more than a few coders, myself included.

All the best,

Thanks, I think that helps a bit. I’ve tried to teach myself programming a few times and usually ended up as clueless as before after a few weeks. Maybe I’ll give those books a try.

Sooner or later I’m going to have to either catch on or admit defeat. Reminds me of my poor high-school algebra teachers trying to help me understand the subject…didn’t work. :slight_smile:

Honestly, if anyone can teach you, Steve Kochan can. I have dozens of programming books, but that and the Hillegaas one are the only ones I’ve read. Check out my review on Amazon:

amazon.com/Programming-Objec … 389&sr=8-1

(127 of 128 people found my review helpful - now who was the tosser who took the trouble of saying they didn’t find it helpful? :slight_smile: )


If you do want to try learning, I would strongly encourage you to follow Keith’s book suggestions as a starting path. Applescript is not the way to go. It has been characterized from the beginning as a simple language for users. It is not. It’s a simply ghastly, ungainly language that is, unfortunately, quite useful for tying together different applications and the Finder.

Whatever language you choose to learn, however, go slowly. It really does take a long time to learn a new language and trying to hurry it will just frustrate you.


Well, I successfully build my first Xcode application tonight in AppleScript Studio. It’s a very (very) simple little app—it presents a list of apps I commonly use while writing, each with a checkbox. I check the ones I want to use and hit OK, and they all start up and then hide themselves so they aren’t all in the way. If iTunes is one of the selected ones, it also begins playing the selected playlist.

Not much (and admittedly not that useful—it was mostly just experimenting), but it’s a start!

dafu - If I decide to try serious programming, don’t worry, I won’t go with AppleScript. I’m well aware of its limitations. :wink: I don’t know why you call it ‘ghastly,’ though. It’s not all that bad. It gets the job done—as much as I’ve needed done so far, anyway, and it’s started me on The Path. I consider it a very useful tool for people who want to write simple scripts but don’t want to learn more powerful languages.

Having used Applescript for over a decade in production situations I stand by my description of it as “ghastly.” I also completely agree with you that it gets the job done.


In my opinion, there is No need to learn AppleScript these days. We now have the Open Scripting Architecture which allows very powerful scripting languages such as Python, Ruby, and Perl, to interact with applications in the same way that AppleScript can, using exactly the same hooks that it does. The Ruby bridge is very slick, and allows you to manipulate applications in a very “Rubylike” way:[code]require ‘rbosa’
itunes = OSA.app(‘iTunes’)

track = itunes.current_track
p track # OSA::Itunes::FileTrack:0x1495e20
p track.name # “Over The Rainbow”
p track.artist # “Keith Jarrett”
p track.duration # 362.368988037109
p track.date_added.to_s # “2006-06-30”
p track.enabled? # true

Play the selected track.


Fade the volume.

100.times { |i| itunes.sound_volume = i; sleep 0.1 }

Set iChat’s status message to the current track.

OSA.app(‘iChat’).status_message = “Playing: #{track.name}”[/code]

Note, it is creating class methods on the fly, depending on the application’s AppleScript Dictionary. Given the wealth of things you can do with Ruby (imagine combining Ruby CGI with RubyOSA: creating a web interface with your home computer’s applications that you can access anywhere), I don’t see any reason for someone who is just learning scripting on the Mac to pick up that old archaic AppleScript. :slight_smile:

I’ve never even heard of Ruby.

I’d be careful about saying that too loudly… :smiley: I think it’s kind of like saying you haven’t heard of Linux…

I don’t “speak” ruby, but I have had to convert a program or two from ruby to perl, so that I could then modify it. I don’t have the time, or the inclination at the moment, to learn a new programming language. But if I did, I can pretty much guarantee you it would be ruby. The programs I have looked at seemed pretty elegant, even if I didn’t totally understand them.

Linux? What’s that?

P.S. - just kidding!


Now that’s just spooky. By sheer coincidence I took delivery of both these books this week. I figured it was time to jump to Objective-C and Cocoa after spending years flirting with assembly language and RAD tools such as Max/MSP :slight_smile:


Enjoy! They are great books and will have you on your way to Cocoa development in no time.
All the best,